@@ -2323,6 +2323,8 @@ declare module 'assemblyscript/src/types' {
2323
2323
constructor ( kind : TypeKind , flags : TypeFlags , size : u32 ) ;
2324
2324
/** Returns the closest int type representing this type. */
2325
2325
readonly intType : Type ;
2326
+ /** Substitutes this type with the auto type if this type is void. */
2327
+ readonly exceptVoid : Type ;
2326
2328
/** Gets this type's logarithmic alignment in memory. */
2327
2329
readonly alignLog2 : i32 ;
2328
2330
/** Tests if this is a managed type that needs GC hooks. */
@@ -2395,6 +2397,8 @@ declare module 'assemblyscript/src/types' {
2395
2397
static readonly v128 : Type ;
2396
2398
/** No return type. */
2397
2399
static readonly void : Type ;
2400
+ /** Alias of i32 indicating type inference of locals and globals with just an initializer. */
2401
+ static readonly auto : Type ;
2398
2402
}
2399
2403
/** Converts an array of types to an array of native types. */
2400
2404
export function typesToNativeTypes ( types : Type [ ] ) : NativeType [ ] ;
@@ -2465,26 +2469,28 @@ declare module 'assemblyscript/src/flow' {
2465
2469
ALLOCATES = 64 ,
2466
2470
/** This flow calls super. Constructors only. */
2467
2471
CALLS_SUPER = 128 ,
2472
+ /** This flow terminates (returns, throws or continues). */
2473
+ TERMINATES = 256 ,
2468
2474
/** This flow conditionally returns in a child flow. */
2469
- CONDITIONALLY_RETURNS = 256 ,
2475
+ CONDITIONALLY_RETURNS = 512 ,
2470
2476
/** This flow conditionally throws in a child flow. */
2471
- CONDITIONALLY_THROWS = 512 ,
2477
+ CONDITIONALLY_THROWS = 1024 ,
2478
+ /** This flow conditionally terminates in a child flow. */
2479
+ CONDITIONALLY_TERMINATES = 2048 ,
2472
2480
/** This flow conditionally breaks in a child flow. */
2473
- CONDITIONALLY_BREAKS = 1024 ,
2481
+ CONDITIONALLY_BREAKS = 4096 ,
2474
2482
/** This flow conditionally continues in a child flow. */
2475
- CONDITIONALLY_CONTINUES = 2048 ,
2483
+ CONDITIONALLY_CONTINUES = 8192 ,
2476
2484
/** This flow conditionally allocates in a child flow. Constructors only. */
2477
- CONDITIONALLY_ALLOCATES = 4096 ,
2485
+ CONDITIONALLY_ALLOCATES = 16384 ,
2478
2486
/** This is an inlining flow. */
2479
- INLINE_CONTEXT = 8192 ,
2487
+ INLINE_CONTEXT = 32768 ,
2480
2488
/** This is a flow with explicitly disabled bounds checking. */
2481
- UNCHECKED_CONTEXT = 16384 ,
2482
- /** Any terminating flag. */
2483
- ANY_TERMINATING = 57 ,
2489
+ UNCHECKED_CONTEXT = 65536 ,
2484
2490
/** Any categorical flag. */
2485
- ANY_CATEGORICAL = 255 ,
2491
+ ANY_CATEGORICAL = 511 ,
2486
2492
/** Any conditional flag. */
2487
- ANY_CONDITIONAL = 7936
2493
+ ANY_CONDITIONAL = 30208
2488
2494
}
2489
2495
/** Flags indicating the current state of a local. */
2490
2496
export enum LocalFlags {
@@ -3781,23 +3787,21 @@ declare module 'assemblyscript/src/compiler' {
3781
3787
/** Tests if a specific feature is activated. */
3782
3788
hasFeature ( feature : Feature ) : bool ;
3783
3789
}
3784
- /** Requests or indicates compilation conditions of statements and expressions . */
3785
- export const enum ContextualFlags {
3790
+ /** Various constraints in expression compilation . */
3791
+ export const enum Constraints {
3786
3792
NONE = 0 ,
3787
- /** Implicit conversion required . */
3788
- IMPLICIT = 1 ,
3789
- /** Explicit conversion required . */
3790
- EXPLICIT = 2 ,
3791
- /** Small integer wrap required . */
3792
- WRAP = 4 ,
3793
- /** Value is known to be immediately dropped. */
3793
+ /** Must implicitly convert to the target type . */
3794
+ CONV_IMPLICIT = 1 ,
3795
+ /** Must explicitly convert to the target type . */
3796
+ CONV_EXPLICIT = 2 ,
3797
+ /** Must wrap small integer values to match the target type . */
3798
+ MUST_WRAP = 4 ,
3799
+ /** Indicates that the value will be dropped immediately . */
3794
3800
WILL_DROP = 8 ,
3795
- /** Value is known to be immediately assigned to a retaining target. */
3796
- SKIP_AUTORELEASE = 16 ,
3797
- /** Is the last statement in a function body. */
3798
- LAST_IN_BODY = 32 ,
3799
- /** Data can be compiled statically. */
3800
- STATIC_CAPABLE = 64
3801
+ /** Indicates that the value will be retained immediately. */
3802
+ WILL_RETAIN = 16 ,
3803
+ /** Indicates that static data is preferred. */
3804
+ PREFER_STATIC = 32
3801
3805
}
3802
3806
/** Runtime features to be activated by the compiler. */
3803
3807
export const enum RuntimeFeatures {
@@ -3897,31 +3901,29 @@ declare module 'assemblyscript/src/compiler' {
3897
3901
/** Ensures that a table entry exists for the specified function and returns its index. */
3898
3902
ensureFunctionTableEntry ( func : Function ) : i32 ;
3899
3903
compileTopLevelStatement ( statement : Statement , body : ExpressionRef [ ] ) : void ;
3900
- compileStatement ( statement : Statement , contextualFlags ?: ContextualFlags ) : ExpressionRef ;
3904
+ compileStatement ( statement : Statement , isLastInBody ?: bool ) : ExpressionRef ;
3901
3905
compileStatements ( statements : Statement [ ] , isBody ?: bool , stmts ?: ExpressionRef [ ] | null ) : ExpressionRef [ ] ;
3902
- compileBlockStatement ( statement : BlockStatement , contextualFlags : ContextualFlags ) : ExpressionRef ;
3903
- compileBreakStatement ( statement : BreakStatement , contextualFlags : ContextualFlags ) : ExpressionRef ;
3904
- compileContinueStatement ( statement : ContinueStatement , contextualFlags : ContextualFlags ) : ExpressionRef ;
3905
- compileDoStatement ( statement : DoStatement , contextualFlags : ContextualFlags ) : ExpressionRef ;
3906
- compileEmptyStatement ( statement : EmptyStatement , contextualFlags : ContextualFlags ) : ExpressionRef ;
3907
- compileExpressionStatement ( statement : ExpressionStatement , contextualFlags : ContextualFlags ) : ExpressionRef ;
3908
- compileForStatement ( statement : ForStatement , contextualFlags : ContextualFlags ) : ExpressionRef ;
3909
- compileIfStatement ( statement : IfStatement , contextualFlags : ContextualFlags ) : ExpressionRef ;
3910
- compileReturnStatement ( statement : ReturnStatement , contextualFlags : ContextualFlags ) : ExpressionRef ;
3911
- compileSwitchStatement ( statement : SwitchStatement , contextualFlags : ContextualFlags ) : ExpressionRef ;
3912
- compileThrowStatement ( statement : ThrowStatement , contextualFlags : ContextualFlags ) : ExpressionRef ;
3913
- compileTryStatement ( statement : TryStatement , contextualFlags : ContextualFlags ) : ExpressionRef ;
3906
+ compileBlockStatement ( statement : BlockStatement ) : ExpressionRef ;
3907
+ compileBreakStatement ( statement : BreakStatement ) : ExpressionRef ;
3908
+ compileContinueStatement ( statement : ContinueStatement ) : ExpressionRef ;
3909
+ compileDoStatement ( statement : DoStatement ) : ExpressionRef ;
3910
+ compileEmptyStatement ( statement : EmptyStatement ) : ExpressionRef ;
3911
+ compileExpressionStatement ( statement : ExpressionStatement ) : ExpressionRef ;
3912
+ compileForStatement ( statement : ForStatement ) : ExpressionRef ;
3913
+ compileIfStatement ( statement : IfStatement ) : ExpressionRef ;
3914
+ compileReturnStatement ( statement : ReturnStatement , isLastInBody : bool ) : ExpressionRef ;
3915
+ compileSwitchStatement ( statement : SwitchStatement ) : ExpressionRef ;
3916
+ compileThrowStatement ( statement : ThrowStatement ) : ExpressionRef ;
3917
+ compileTryStatement ( statement : TryStatement ) : ExpressionRef ;
3914
3918
/** Compiles a variable statement. Returns `0` if an initializer is not necessary. */
3915
- compileVariableStatement ( statement : VariableStatement , contextualFlags : ContextualFlags ) : ExpressionRef ;
3916
- compileVoidStatement ( statement : VoidStatement , contextualFlags : ContextualFlags ) : ExpressionRef ;
3917
- compileWhileStatement ( statement : WhileStatement , contextualFlags : ContextualFlags ) : ExpressionRef ;
3919
+ compileVariableStatement ( statement : VariableStatement ) : ExpressionRef ;
3920
+ compileVoidStatement ( statement : VoidStatement ) : ExpressionRef ;
3921
+ compileWhileStatement ( statement : WhileStatement ) : ExpressionRef ;
3918
3922
/** Compiles the value of an inlined constant element. */
3919
- compileInlineConstant ( element : VariableLikeElement , contextualType : Type , contextualFlags : ContextualFlags ) : ExpressionRef ;
3920
- compileExpression ( expression : Expression , contextualType : Type , contextualFlags ?: ContextualFlags ) : ExpressionRef ;
3921
- /** Compiles an expression while retaining the type, that is not void, it ultimately compiles to. */
3922
- compileExpressionRetainType ( expression : Expression , contextualType : Type , contextualFlags ?: ContextualFlags ) : ExpressionRef ;
3923
+ compileInlineConstant ( element : VariableLikeElement , contextualType : Type , constraints : Constraints ) : ExpressionRef ;
3924
+ compileExpression ( expression : Expression , contextualType : Type , constraints ?: Constraints ) : ExpressionRef ;
3923
3925
/** Compiles and precomputes an expression, possibly yielding a costant value. */
3924
- precomputeExpression ( expression : Expression , contextualType : Type , contextualFlags ?: ContextualFlags ) : ExpressionRef ;
3926
+ precomputeExpression ( expression : Expression , contextualType : Type , constraints ?: Constraints ) : ExpressionRef ;
3925
3927
convertExpression ( expr : ExpressionRef ,
3926
3928
/** Original type. */
3927
3929
fromType : Type ,
@@ -3931,12 +3933,12 @@ declare module 'assemblyscript/src/compiler' {
3931
3933
explicit : bool ,
3932
3934
/** Whether the result should be wrapped, if a small integer. */
3933
3935
wrap : bool , reportNode : Node ) : ExpressionRef ;
3934
- compileAssertionExpression ( expression : AssertionExpression , contextualType : Type , contextualFlags : ContextualFlags ) : ExpressionRef ;
3936
+ compileAssertionExpression ( expression : AssertionExpression , contextualType : Type , constraints : Constraints ) : ExpressionRef ;
3935
3937
private f32ModInstance ;
3936
3938
private f64ModInstance ;
3937
3939
private f32PowInstance ;
3938
3940
private f64PowInstance ;
3939
- compileBinaryExpression ( expression : BinaryExpression , contextualType : Type , contextualFlags : ContextualFlags ) : ExpressionRef ;
3941
+ compileBinaryExpression ( expression : BinaryExpression , contextualType : Type , constraints : Constraints ) : ExpressionRef ;
3940
3942
compileUnaryOverload ( operatorInstance : Function , value : Expression , valueExpr : ExpressionRef , reportNode : Node ) : ExpressionRef ;
3941
3943
compileBinaryOverload ( operatorInstance : Function , left : Expression , leftExpr : ExpressionRef , right : Expression , reportNode : Node ) : ExpressionRef ;
3942
3944
compileAssignment ( expression : Expression , valueExpression : Expression , contextualType : Type ) : ExpressionRef ;
@@ -3974,16 +3976,16 @@ declare module 'assemblyscript/src/compiler' {
3974
3976
expression : CallExpression ,
3975
3977
/** Contextual type indicating the return type the caller expects, if any. */
3976
3978
contextualType : Type ,
3977
- /** Contextual flags indicating contextual conditions. */
3978
- contextualFlags : ContextualFlags ) : ExpressionRef ;
3979
+ /** Constraints indicating contextual conditions. */
3980
+ constraints : Constraints ) : ExpressionRef ;
3979
3981
private compileCallExpressionBuiltin ;
3980
3982
/**
3981
3983
* Checks that a call with the given number as arguments can be performed according to the
3982
3984
* specified signature.
3983
3985
*/
3984
3986
checkCallSignature ( signature : Signature , numArguments : i32 , hasThis : bool , reportNode : Node ) : bool ;
3985
3987
/** Compiles a direct call to a concrete function. */
3986
- compileCallDirect ( instance : Function , argumentExpressions : Expression [ ] , reportNode : Node , thisArg ?: ExpressionRef , contextualFlags ?: ContextualFlags ) : ExpressionRef ;
3988
+ compileCallDirect ( instance : Function , argumentExpressions : Expression [ ] , reportNode : Node , thisArg ?: ExpressionRef , constraints ?: Constraints ) : ExpressionRef ;
3987
3989
makeCallInline ( instance : Function , operands : ExpressionRef [ ] | null , thisArg ?: ExpressionRef , immediatelyDropped ?: bool ) : ExpressionRef ;
3988
3990
/** Gets the trampoline for the specified function. */
3989
3991
ensureTrampoline ( original : Function ) : Function ;
@@ -4023,23 +4025,23 @@ declare module 'assemblyscript/src/compiler' {
4023
4025
compileCallIndirect ( signature : Signature , indexArg : ExpressionRef , argumentExpressions : Expression [ ] , reportNode : Node , thisArg ?: ExpressionRef , immediatelyDropped ?: bool ) : ExpressionRef ;
4024
4026
/** Creates an indirect call to the function at `indexArg` in the function table. */
4025
4027
makeCallIndirect ( signature : Signature , indexArg : ExpressionRef , operands ?: ExpressionRef [ ] | null , immediatelyDropped ?: bool ) : ExpressionRef ;
4026
- compileCommaExpression ( expression : CommaExpression , contextualType : Type , contextualFlags : ContextualFlags ) : ExpressionRef ;
4027
- compileElementAccessExpression ( expression : ElementAccessExpression , contextualType : Type , contextualFlags : ContextualFlags ) : ExpressionRef ;
4028
- compileFunctionExpression ( expression : FunctionExpression , contextualSignature : Signature | null , contextualFlags : ContextualFlags ) : ExpressionRef ;
4028
+ compileCommaExpression ( expression : CommaExpression , contextualType : Type , constraints : Constraints ) : ExpressionRef ;
4029
+ compileElementAccessExpression ( expression : ElementAccessExpression , contextualType : Type , constraints : Constraints ) : ExpressionRef ;
4030
+ compileFunctionExpression ( expression : FunctionExpression , contextualSignature : Signature | null , constraints : Constraints ) : ExpressionRef ;
4029
4031
/** Makes sure the enclosing source file of the specified expression has been compiled. */
4030
4032
private maybeCompileEnclosingSource ;
4031
4033
/**
4032
4034
* Compiles an identifier in the specified context.
4033
4035
* @param retainConstantType Retains the type of inlined constants if `true`, otherwise
4034
4036
* precomputes them according to context.
4035
4037
*/
4036
- compileIdentifierExpression ( expression : IdentifierExpression , contextualType : Type , contextualFlags : ContextualFlags ) : ExpressionRef ;
4037
- compileInstanceOfExpression ( expression : InstanceOfExpression , contextualType : Type , contextualFlags : ContextualFlags ) : ExpressionRef ;
4038
- compileLiteralExpression ( expression : LiteralExpression , contextualType : Type , contextualFlags : ContextualFlags , implicitlyNegate ?: bool ) : ExpressionRef ;
4038
+ compileIdentifierExpression ( expression : IdentifierExpression , contextualType : Type , constraints : Constraints ) : ExpressionRef ;
4039
+ compileInstanceOfExpression ( expression : InstanceOfExpression , contextualType : Type , constraints : Constraints ) : ExpressionRef ;
4040
+ compileLiteralExpression ( expression : LiteralExpression , contextualType : Type , constraints : Constraints , implicitlyNegate ?: bool ) : ExpressionRef ;
4039
4041
compileStringLiteral ( expression : StringLiteralExpression ) : ExpressionRef ;
4040
- compileArrayLiteral ( elementType : Type , expressions : ( Expression | null ) [ ] , isConst : bool , contextualFlags : ContextualFlags , reportNode : Node ) : ExpressionRef ;
4042
+ compileArrayLiteral ( elementType : Type , expressions : ( Expression | null ) [ ] , constraints : Constraints , reportNode : Node ) : ExpressionRef ;
4041
4043
compileObjectLiteral ( expression : ObjectLiteralExpression , contextualType : Type ) : ExpressionRef ;
4042
- compileNewExpression ( expression : NewExpression , contextualType : Type , contextualFlags : ContextualFlags ) : ExpressionRef ;
4044
+ compileNewExpression ( expression : NewExpression , contextualType : Type , constraints : Constraints ) : ExpressionRef ;
4043
4045
/** Gets the compiled constructor of the specified class or generates one if none is present. */
4044
4046
ensureConstructor ( classInstance : Class , reportNode : Node ) : Function ;
4045
4047
compileInstantiate (
@@ -4048,18 +4050,18 @@ declare module 'assemblyscript/src/compiler' {
4048
4050
/** Constructor arguments. */
4049
4051
argumentExpressions : Expression [ ] ,
4050
4052
/** Contextual flags. */
4051
- contextualFlags : ContextualFlags ,
4053
+ constraints : Constraints ,
4052
4054
/** Node to report on. */
4053
4055
reportNode : Node ) : ExpressionRef ;
4054
4056
/**
4055
4057
* Compiles a property access in the specified context.
4056
4058
* @param retainConstantType Retains the type of inlined constants if `true`, otherwise
4057
4059
* precomputes them according to context.
4058
4060
*/
4059
- compilePropertyAccessExpression ( propertyAccess : PropertyAccessExpression , contextualType : Type , contextualFlags : ContextualFlags ) : ExpressionRef ;
4060
- compileTernaryExpression ( expression : TernaryExpression , contextualType : Type , contextualFlags : ContextualFlags ) : ExpressionRef ;
4061
- compileUnaryPostfixExpression ( expression : UnaryPostfixExpression , contextualType : Type , contextualFlags : ContextualFlags ) : ExpressionRef ;
4062
- compileUnaryPrefixExpression ( expression : UnaryPrefixExpression , contextualType : Type , contextualFlags : ContextualFlags ) : ExpressionRef ;
4061
+ compilePropertyAccessExpression ( propertyAccess : PropertyAccessExpression , contextualType : Type , constraints : Constraints ) : ExpressionRef ;
4062
+ compileTernaryExpression ( expression : TernaryExpression , contextualType : Type , constraints : Constraints ) : ExpressionRef ;
4063
+ compileUnaryPostfixExpression ( expression : UnaryPostfixExpression , contextualType : Type , constraints : Constraints ) : ExpressionRef ;
4064
+ compileUnaryPrefixExpression ( expression : UnaryPrefixExpression , contextualType : Type , constraints : Constraints ) : ExpressionRef ;
4063
4065
/** Makes sure that a 32-bit integer value is wrapped to a valid value of the specified type. */
4064
4066
ensureSmallIntegerWrap ( expr : ExpressionRef , type : Type ) : ExpressionRef ;
4065
4067
/** Adds the debug location of the specified expression at the specified range to the source map. */
0 commit comments