assemblyscript/dist/assemblyscript.js

3 lines
451 KiB
JavaScript
Raw Normal View History

!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=15)}([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.DEFINITE_ASSIGNMENT=8192]="DEFINITE_ASSIGNMENT",e[e.AMBIENT=16384]="AMBIENT",e[e.GENERIC=32768]="GENERIC",e[e.GENERIC_CONTEXT=65536]="GENERIC_CONTEXT",e[e.INSTANCE=131072]="INSTANCE",e[e.CONSTRUCTOR=262144]="CONSTRUCTOR",e[e.ARROW=524288]="ARROW",e[e.MODULE_EXPORT=1048576]="MODULE_EXPORT",e[e.MODULE_IMPORT=2097152]="MODULE_IMPORT",e[e.RESOLVED=4194304]="RESOLVED",e[e.COMPILED=8388608]="COMPILED",e[e.INLINED=16777216]="INLINED",e[e.SCOPED=33554432]="SCOPED",e[e.TRAMPOLINE=67108864]="TRAMPOLINE",e[e.VIRTUAL=134217728]="VIRTUAL",e[e.MAIN=268435456]="MAIN",e[e.QUOTED=536870912]="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="",t.COLOR_YELLOW="",t.COLOR_RED="",t.COLOR_RESET="",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)+
return this.currentType=i.returnType,this.compileCallDirect(n,[],t,c,a)}return this.currentType=i.returnType,this.compileCallDirect(n,[],t,0,a)}return this.error(l.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,g.Type.bool,0),this.currentType);if(!this.options.noTreeShaking||this.currentFunction.isAny(u.CommonFlags.GENERIC|u.CommonFlags.GENERIC_CONTEXT)){var o=this.module.precomputeExpression(s);if(p.getExpressionId(o)==p.ExpressionId.Const&&1==p.getExpressionType(o))return p.getConstValueI32(o)?this.compileExpressionRetainType(r,t,0):this.compileExpressionRetainType(n,t,0);s=this.makeIsTrueish(this.compileExpressionRetainType(e.condition,g.Type.bool,0),this.currentType)}var c=a.fork();i.flow=c;var h=this.compileExpressionRetainType(r,t,0),d=this.currentType;c.free();var _=a.fork();i.flow=_;var m=this.compileExpressionRetainType(n,t,0),y=this.currentType;i.flow=_.free(),a.inheritMutual(c,_);var E=g.Type.commonCompatible(d,y,!1);return E?(h=this.convertExpression(h,d,E,1,0,r),m=this.convertExpression(m,y,E,1,0,n),this.currentType=E,this.module.createIf(s,h,m)):(this.error(l.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==g.Type.void?g.Type.i32:t,0,0);if(p.getExpressionId(i)==p.ExpressionId.Unreachable)return i;var a,s=this.currentType,o=null;switch(t!=g.Type.void&&(o=n.getTempLocal(s,!1),i=r.createTeeLocal(o.index,i)),e.operator){case d.Token.PLUS_PLUS:switch(s.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:a=r.createBinary(p.BinaryOp.AddI32,i,r.createI32(1));break;case 9:if(this.currentType.is(256)){if(u=this.currentType.classReference)if(_=u.lookupOverload(h.OperatorKind.POSTFIX_INC)){a=this.compileUnaryOverload(_,e.operand,i,e);break}return this.error(l.DiagnosticCode.Operation_not_supported,e.range),r.createUnreachable()}case 4:var c=this.options;a=r.createBinary(c.isWasm64?p.BinaryOp.AddI64:p.BinaryOp.AddI32,i,s.toNativeOne(r));break;case 3:case 8:a=r.createBinary(p.BinaryOp.AddI64,i,r.createI64(1));break;case 11:a=r.createBinary(p.BinaryOp.AddF32,i,r.createF32(1));break;case 12:a=r.createBinary(p.BinaryOp.AddF64,i,r.createF64(1));break;default:return assert(!1),r.createUnreachable()}break;case d.Token.MINUS_MINUS:switch(s.kind){case 0:case 1:case 2:case 5:case 6:case 7:case 10:a=r.createBinary(p.BinaryOp.SubI32,i,r.createI32(1));break;case 9:if(this.currentType.is(256)){var u,_;if(u=this.currentType.classReference)if(_=u.lookupOverload(h.OperatorKind.POSTFIX_DEC)){a=this.compileUnaryOverload(_,e.operand,i,e);break}return this.error(l.DiagnosticCode.Operation_not_supported,e.range),r.createUnreachable()}case 4:c=this.options;a=r.createBinary(c.isWasm64?p.BinaryOp.SubI64:p.BinaryOp.SubI32,i,s.toNativeOne(r));break;case 3:case 8:a=r.createBinary(p.BinaryOp.SubI64,i,r.createI64(1));break;case 11:a=r.createBinary(p.BinaryOp.SubF32,i,r.createF32(1));break;case 12:a=r.createBinary(p.BinaryOp.SubF64,i,r.createF64(1));break;default:return assert(!1),r.createUnreachable()}break;default:return assert(!1),r.createUnreachable()}if(!o)return this.currentType=g.Type.void,this.compileAssignmentWithValue(e.operand,a,!1);var m=this.compileAssignmentWithValue(e.operand,a,!1);this.currentType=o.type,n.freeTempLocal(o);var y=o.type.toNativeType();return r.createBlock(null,[m,r.createGetLocal(o.index,y)],y)},t.prototype.compileUnaryPrefixExpression=function(e,t){var r,n=this.module,i=!1;switch(e.operator){case d.Token.PLUS:if(r=this.compileExpression(e.operand,t==g.Type.void?g.Type.i32:t,0,0),this.currentType.is(256)){if(a=this.currentType.classReference)if(s=a.lookupOverload(h.OperatorKind.PLUS)){r=this.compileUnaryOverload(s,e.operand,r,e);break}return thi
2018-07-22 14:19:23 +02:00
//# sourceMappingURL=assemblyscript.js.map