@@ -375,8 +375,8 @@ export class Program extends DiagnosticEmitter {
375
375
f64ArrayPrototype : ClassPrototype ;
376
376
/** String instance reference. */
377
377
stringInstance : Class ;
378
- /** Abort function reference, if present . */
379
- abortInstance : Function ;
378
+ /** Abort function reference, if not explicitly disabled . */
379
+ abortInstance : Function | null ;
380
380
381
381
// runtime references
382
382
@@ -861,7 +861,7 @@ export class Program extends DiagnosticEmitter {
861
861
this . fixedArrayPrototype = < ClassPrototype > this . require ( CommonSymbols . FixedArray , ElementKind . CLASS_PROTOTYPE ) ;
862
862
this . setPrototype = < ClassPrototype > this . require ( CommonSymbols . Set , ElementKind . CLASS_PROTOTYPE ) ;
863
863
this . mapPrototype = < ClassPrototype > this . require ( CommonSymbols . Map , ElementKind . CLASS_PROTOTYPE ) ;
864
- this . abortInstance = this . requireFunction ( CommonSymbols . abort ) ;
864
+ this . abortInstance = this . lookupFunction ( CommonSymbols . abort ) ; // can be disabled
865
865
this . allocInstance = this . requireFunction ( CommonSymbols . alloc ) ;
866
866
this . reallocInstance = this . requireFunction ( CommonSymbols . realloc ) ;
867
867
this . freeInstance = this . requireFunction ( CommonSymbols . free ) ;
@@ -897,6 +897,13 @@ export class Program extends DiagnosticEmitter {
897
897
return resolved ;
898
898
}
899
899
900
+ /** Obtains a non-generic global function and returns it. Returns `null` if it does not exist. */
901
+ private lookupFunction ( name : string ) : Function | null {
902
+ var prototype = this . lookupGlobal ( name ) ;
903
+ if ( ! prototype || prototype . kind != ElementKind . FUNCTION_PROTOTYPE ) return null ;
904
+ return this . resolver . resolveFunction ( < FunctionPrototype > prototype , null ) ;
905
+ }
906
+
900
907
/** Requires that a non-generic global function is present and returns it. */
901
908
private requireFunction ( name : string ) : Function {
902
909
var prototype = this . require ( name , ElementKind . FUNCTION_PROTOTYPE ) ;
0 commit comments