@@ -375,8 +375,8 @@ export class Program extends DiagnosticEmitter {
375375 f64ArrayPrototype : ClassPrototype ;
376376 /** String instance reference. */
377377 stringInstance : Class ;
378- /** Abort function reference, if present . */
379- abortInstance : Function ;
378+ /** Abort function reference, if not explicitly disabled . */
379+ abortInstance : Function | null ;
380380
381381 // runtime references
382382
@@ -861,7 +861,7 @@ export class Program extends DiagnosticEmitter {
861861 this . fixedArrayPrototype = < ClassPrototype > this . require ( CommonSymbols . FixedArray , ElementKind . CLASS_PROTOTYPE ) ;
862862 this . setPrototype = < ClassPrototype > this . require ( CommonSymbols . Set , ElementKind . CLASS_PROTOTYPE ) ;
863863 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
865865 this . allocInstance = this . requireFunction ( CommonSymbols . alloc ) ;
866866 this . reallocInstance = this . requireFunction ( CommonSymbols . realloc ) ;
867867 this . freeInstance = this . requireFunction ( CommonSymbols . free ) ;
@@ -897,6 +897,13 @@ export class Program extends DiagnosticEmitter {
897897 return resolved ;
898898 }
899899
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+
900907 /** Requires that a non-generic global function is present and returns it. */
901908 private requireFunction ( name : string ) : Function {
902909 var prototype = this . require ( name , ElementKind . FUNCTION_PROTOTYPE ) ;
0 commit comments