@@ -358,8 +358,8 @@ export class Compiler extends DiagnosticEmitter {
358358 skippedAutoreleases : Set < ExpressionRef > = new Set ( ) ;
359359 /** Current inline functions stack. */
360360 inlineStack : Function [ ] = [ ] ;
361- /** Lazily compiled library functions. */
362- lazyLibraryFunctions : Set < Function > = new Set ( ) ;
361+ /** Lazily compiled functions. */
362+ lazyFunctions : Set < Function > = new Set ( ) ;
363363 /** Pending class-specific instanceof helpers. */
364364 pendingClassInstanceOf : Set < ClassPrototype > = new Set ( ) ;
365365 /** Functions potentially involving a virtual call. */
@@ -490,20 +490,20 @@ export class Compiler extends DiagnosticEmitter {
490490 program . registerConstantInteger ( "__GC_ALL_ACYCLIC" , Type . bool , i64_new ( 1 , 0 ) ) ;
491491 }
492492
493- // compile lazy library functions
494- var lazyLibraryFunctions = this . lazyLibraryFunctions ;
493+ // compile lazy functions
494+ var lazyFunctions = this . lazyFunctions ;
495495 do {
496496 let functionsToCompile = new Array < Function > ( ) ;
497497 // TODO: for (let instance of lazyLibraryFunctions) {
498- for ( let _values = Set_values ( lazyLibraryFunctions ) , i = 0 , k = _values . length ; i < k ; ++ i ) {
498+ for ( let _values = Set_values ( lazyFunctions ) , i = 0 , k = _values . length ; i < k ; ++ i ) {
499499 let instance = unchecked ( _values [ i ] ) ;
500500 functionsToCompile . push ( instance ) ;
501501 }
502- lazyLibraryFunctions . clear ( ) ;
502+ lazyFunctions . clear ( ) ;
503503 for ( let i = 0 , k = functionsToCompile . length ; i < k ; ++ i ) {
504504 this . compileFunction ( unchecked ( functionsToCompile [ i ] ) , true ) ;
505505 }
506- } while ( lazyLibraryFunctions . size ) ;
506+ } while ( lazyFunctions . size ) ;
507507
508508 // compile pending class-specific instanceof helpers
509509 // TODO: for (let prototype of this.pendingClassInstanceOf.values()) {
@@ -759,7 +759,7 @@ export class Compiler extends DiagnosticEmitter {
759759 global . identifierNode . range
760760 ) ;
761761 } else {
762- this . module . addGlobalExport ( element . internalName , prefix + name ) ;
762+ if ( element . is ( CommonFlags . COMPILED ) ) this . module . addGlobalExport ( element . internalName , prefix + name ) ;
763763 }
764764 break ;
765765 }
@@ -916,7 +916,7 @@ export class Compiler extends DiagnosticEmitter {
916916 // TODO: for (let element of exports.values()) {
917917 for ( let _values = Map_values ( exports ) , i = 0 , k = _values . length ; i < k ; ++ i ) {
918918 let element = unchecked ( _values [ i ] ) ;
919- this . compileElement ( element ) ;
919+ if ( ! element . hasDecorator ( DecoratorFlags . LAZY ) ) this . compileElement ( element ) ;
920920 }
921921 }
922922 var exportsStar = file . exportsStar ;
@@ -1349,7 +1349,7 @@ export class Compiler extends DiagnosticEmitter {
13491349 if ( ! forceStdAlternative ) {
13501350 if ( instance . hasDecorator ( DecoratorFlags . BUILTIN ) ) return true ;
13511351 if ( instance . hasDecorator ( DecoratorFlags . LAZY ) ) {
1352- this . lazyLibraryFunctions . add ( instance ) ;
1352+ this . lazyFunctions . add ( instance ) ;
13531353 return true ;
13541354 }
13551355 }
0 commit comments