2018-10-03 01:32:28 +02:00
|
|
|
|
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("binaryen")):"function"==typeof define&&define.amd?define(["binaryen"],t):"object"==typeof exports?exports.assemblyscript=t(require("binaryen")):e.assemblyscript=t(e.binaryen)}("undefined"!=typeof self?self:this,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=12)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.NONE=0]="NONE",e[e.IMPORT=1]="IMPORT",e[e.EXPORT=2]="EXPORT",e[e.DECLARE=4]="DECLARE",e[e.CONST=8]="CONST",e[e.LET=16]="LET",e[e.STATIC=32]="STATIC",e[e.READONLY=64]="READONLY",e[e.ABSTRACT=128]="ABSTRACT",e[e.PUBLIC=256]="PUBLIC",e[e.PRIVATE=512]="PRIVATE",e[e.PROTECTED=1024]="PROTECTED",e[e.GET=2048]="GET",e[e.SET=4096]="SET",e[e.AMBIENT=8192]="AMBIENT",e[e.GENERIC=16384]="GENERIC",e[e.GENERIC_CONTEXT=32768]="GENERIC_CONTEXT",e[e.INSTANCE=65536]="INSTANCE",e[e.CONSTRUCTOR=131072]="CONSTRUCTOR",e[e.ARROW=262144]="ARROW",e[e.MODULE_EXPORT=524288]="MODULE_EXPORT",e[e.MODULE_IMPORT=1048576]="MODULE_IMPORT",e[e.COMPILED=2097152]="COMPILED",e[e.INLINED=4194304]="INLINED",e[e.SCOPED=8388608]="SCOPED",e[e.TRAMPOLINE=16777216]="TRAMPOLINE",e[e.VIRTUAL=33554432]="VIRTUAL",e[e.MAIN=67108864]="MAIN",e[e.QUOTED=134217728]="QUOTED"}(t.CommonFlags||(t.CommonFlags={})),t.PATH_DELIMITER="/",t.PARENT_SUBST="..",t.GETTER_PREFIX="get:",t.SETTER_PREFIX="set:",t.INSTANCE_DELIMITER="#",t.STATIC_DELIMITER=".",t.INNER_DELIMITER="~",t.LIBRARY_SUBST="~lib",t.LIBRARY_PREFIX=t.LIBRARY_SUBST+t.PATH_DELIMITER,t.FILESPACE_PREFIX="file:"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i=r(10),a=r(2),s=r(10);function o(e){switch(e){case n.INFO:return"INFO";case n.WARNING:return"WARNING";case n.ERROR:return"ERROR";default:return assert(!1),""}}function c(e){switch(e){case n.INFO:return t.COLOR_BLUE;case n.WARNING:return t.COLOR_YELLOW;case n.ERROR:return t.COLOR_RED;default:return assert(!1),""}}t.DiagnosticCode=s.DiagnosticCode,t.diagnosticCodeToString=s.diagnosticCodeToString,function(e){e[e.INFO=0]="INFO",e[e.WARNING=1]="WARNING",e[e.ERROR=2]="ERROR"}(n=t.DiagnosticCategory||(t.DiagnosticCategory={})),t.diagnosticCategoryToString=o,t.COLOR_BLUE="[96m",t.COLOR_YELLOW="[93m",t.COLOR_RED="[91m",t.COLOR_RESET="[0m",t.diagnosticCategoryToColor=c;var l=function(){function e(e,t,r){this.range=null,this.code=e,this.category=t,this.message=r}return e.create=function(t,r,n,a,s){void 0===n&&(n=null),void 0===a&&(a=null),void 0===s&&(s=null);var o=i.diagnosticCodeToString(t);return null!=n&&(o=o.replace("{0}",n)),null!=a&&(o=o.replace("{1}",a)),null!=s&&(o=o.replace("{2}",s)),new e(t,r,o)},e.createInfo=function(t,r,i){return void 0===r&&(r=null),void 0===i&&(i=null),e.create(t,n.INFO,r,i)},e.createWarning=function(t,r,i){return void 0===r&&(r=null),void 0===i&&(i=null),e.create(t,n.WARNING,r,i)},e.createError=function(t,r,i){return void 0===r&&(r=null),void 0===i&&(i=null),e.create(t,n.ERROR,r,i)},e.prototype.withRange=function(e){return this.range=e,this},e.prototype.toString=function(){return this.range?o(this.category)+" "+this.code.toString(10)+': "'+this.message+'" in '+this.range.source.normalizedPath+":"+t
|
2018-09-13 23:10:49 +02:00
|
|
|
|
return this.currentType=i.returnType,this.compileCallDirect(n,[],t,l,a)}return this.currentType=i.returnType,this.compileCallDirect(n,[],t,0,a)}return this.error(c.DiagnosticCode.Property_0_does_not_exist_on_type_1,t.range,e.simpleName,e.parent.toString()),this.module.createUnreachable()},t.prototype.compileTernaryExpression=function(e,t){var r=e.ifThen,n=e.ifElse,i=this.currentFunction,a=i.flow,s=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,_.Type.bool,0),this.currentType);if(!this.options.noTreeShaking||this.currentFunction.isAny(p.CommonFlags.GENERIC|p.CommonFlags.GENERIC_CONTEXT)){var o=this.module.precomputeExpression(s);if(l.getExpressionId(o)==l.ExpressionId.Const&&1==l.getExpressionType(o))return l.getConstValueI32(o)?this.compileExpressionRetainType(r,t,0):this.compileExpressionRetainType(n,t,0);s=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,_.Type.bool,0),this.currentType)}var u=a.fork();i.flow=u;var h=this.compileExpressionRetainType(r,t,0),d=this.currentType;u.free();var m=a.fork();i.flow=m;var g=this.compileExpressionRetainType(n,t,0),y=this.currentType;i.flow=m.free(),a.inheritMutual(u,m);var E=_.Type.commonCompatible(d,y,!1);return E?(h=this.convertExpression(h,d,E,1,0,r),g=this.convertExpression(g,y,E,1,0,n),this.currentType=E,this.module.createIf(s,h,g)):(this.error(c.DiagnosticCode.Type_0_is_not_assignable_to_type_1,e.range,d.toString(),y.toString()),this.currentType=t,this.module.createUnreachable())},t.prototype.compileUnaryPostfixExpression=function(e,t){var r=this.module,n=this.currentFunction,i=this.compileExpression(e.operand,t==_.Type.void?_.Type.i32:t,0,0);if(l.getExpressionId(i)==l.ExpressionId.Unreachable)return i;var a,s,o,p=this.currentType;switch(e.operator){case h.Token.PLUS_PLUS:if(this.currentType.is(256))return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable();switch(p.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:a=l.BinaryOp.AddI32,s=1,o=r.createI32(1);break;case 9:case 4:a=(u=this.options).isWasm64?l.BinaryOp.AddI64:l.BinaryOp.AddI32,s=u.nativeSizeType,o=p.toNativeOne(r);break;case 3:case 8:a=l.BinaryOp.AddI64,s=2,o=r.createI64(1);break;case 11:a=l.BinaryOp.AddF32,s=3,o=r.createF32(1);break;case 12:a=l.BinaryOp.AddF64,s=4,o=r.createF64(1);break;default:return assert(!1),r.createUnreachable()}break;case h.Token.MINUS_MINUS:if(this.currentType.is(256))return this.error(c.DiagnosticCode.Operation_not_supported,e.range),this.module.createUnreachable();switch(p.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:a=l.BinaryOp.SubI32,s=1,o=r.createI32(1);break;case 9:case 4:var u;a=(u=this.options).isWasm64?l.BinaryOp.SubI64:l.BinaryOp.SubI32,s=u.nativeSizeType,o=p.toNativeOne(r);break;case 3:case 8:a=l.BinaryOp.SubI64,s=2,o=r.createI64(1);break;case 11:a=l.BinaryOp.SubF32,s=3,o=r.createF32(1);break;case 12:a=l.BinaryOp.SubF64,s=4,o=r.createF64(1);break;default:return assert(!1),r.createUnreachable()}break;default:return assert(!1),r.createUnreachable()}if(t==_.Type.void)return this.compileAssignmentWithValue(e.operand,r.createBinary(a,i,o),!1);var d=n.getTempLocal(p,!1),m=this.compileAssignmentWithValue(e.operand,r.createBinary(a,this.module.createGetLocal(d.index,s),o),!1);this.currentType=assert(d).type,n.freeTempLocal(d);var g=d.index;return r.createBlock(null,[r.createSetLocal(g,i),m,r.createGetLocal(g,s)],s)},t.prototype.compileUnaryPrefixExpression=function(e,t){var r,n=this.module,i=!1;switch(e.operator){case h.Token.PLUS:if(r=this.compileExpression(e.operand,t==_.Type.void?_.Type.i32:t,0,0),this.currentType.is(256)){if(a=this.currentType.classReference)if(s=a.lookupOverload(u.OperatorKind.PLUS)){r=this.compileUnaryOverload(s,e.operand,r,e);break}return this.error(c.DiagnosticCode.Operation_not_supported,e.range),n.createUnreachable()}break;case h.Token.MINUS:if(e.operand.kind==d.NodeKind.LITERAL&&(e.operand.literalKind==d.LiteralKind.INTEGER||e.operand.literalKind==d.LiteralKind.FLOAT)){r=this.compileLiteralExpression(e.operand,t,!0),this.options.sourceMap&&this.addDebugLocation(r,e.rang
|