@@ -1716,19 +1716,13 @@ export class Compiler extends DiagnosticEmitter {
17161716 var type = instance . type ;
17171717 var nativeThisType = this . options . nativeSizeType ;
17181718 var nativeValueType = type . toNativeType ( ) ;
1719- var varTypes : NativeType [ ] | null = null ;
17201719 var module = this . module ;
17211720 var valueExpr = module . load ( type . byteSize , type . is ( TypeFlags . SIGNED ) ,
17221721 module . local_get ( 0 , nativeThisType ) ,
17231722 nativeValueType , instance . memoryOffset
17241723 ) ;
1725-
1726- if ( type . isManaged ) {
1727- valueExpr = this . makeRetain ( valueExpr , type ) ;
1728- varTypes = [ NativeType . I32 ] ;
1729- }
1730-
1731- instance . getterRef = module . addFunction ( instance . internalGetterName , nativeThisType , nativeValueType , varTypes , valueExpr ) ;
1724+ if ( type . isManaged ) this . makeRetain ( valueExpr , type ) ;
1725+ instance . getterRef = module . addFunction ( instance . internalGetterName , nativeThisType , nativeValueType , null , valueExpr ) ;
17321726 if ( instance . setterRef ) {
17331727 instance . set ( CommonFlags . COMPILED ) ;
17341728 } else {
@@ -1748,7 +1742,7 @@ export class Compiler extends DiagnosticEmitter {
17481742 var valueExpr : ExpressionRef ;
17491743 var varTypes : NativeType [ ] | null = null ;
17501744 if ( type . isManaged ) {
1751- // Can't use makeReplace, makeRetain, or makeRelease here since there's no corresponding flow, so
1745+ // Can't use makeReplace here since there's no corresponding flow, so
17521746 // 0: this, 1: value, 2: oldValue (temp)
17531747 valueExpr = module . block ( null , [
17541748 module . if (
@@ -3624,8 +3618,7 @@ export class Compiler extends DiagnosticEmitter {
36243618 var toSignature = toType . signatureReference ;
36253619 var fromSignature = fromType . signatureReference ;
36263620 if ( toSignature !== null && fromSignature !== null && fromSignature . externalEquals ( toSignature ) && fromType . is ( TypeFlags . IN_SCOPE_CLOSURE ) ) {
3627- // When we convert from the closure type into a function pointer, we first
3628- // update the local copy of the scope with the newest values
3621+ // When a closure leaves its initial scope, we copy in the closed over locals one last time
36293622 var tempResult = this . currentFlow . getTempLocal ( fromType ) ;
36303623 var convertExpr = module . block ( null , [
36313624 module . local_set (
@@ -6872,9 +6865,6 @@ export class Compiler extends DiagnosticEmitter {
68726865 return module . unreachable ( ) ;
68736866 }
68746867 }
6875- // Once we get here, we have a function reference. With the new scheme, this function
6876- // could possibly be a closure. So here we check to see if it's a closure, then apply
6877- // the appropriate call logic
68786868 signature = assert ( signature ) ; // FIXME: asc can't see this yet
68796869 var returnType = signature . returnType ;
68806870 var tempFunctionReferenceLocal = this . currentFlow . getTempLocal ( this . options . usizeType ) ;
@@ -7551,19 +7541,15 @@ export class Compiler extends DiagnosticEmitter {
75517541
75527542 /** Makes a retain call, retaining the expression's value. */
75537543 makeRetain ( expr : ExpressionRef , type : Type ) : ExpressionRef {
7554- var module = this . module ;
75557544 var retainInstance = this . program . retainInstance ;
75567545 this . compileFunction ( retainInstance ) ;
7557-
7558- return module . call ( retainInstance . internalName , [ expr ] , this . options . nativeSizeType ) ;
7546+ return this . module . call ( retainInstance . internalName , [ expr ] , this . options . nativeSizeType ) ;
75597547 }
75607548
75617549 /** Makes a release call, releasing the expression's value. Changes the current type to void.*/
75627550 makeRelease ( expr : ExpressionRef , type : Type ) : ExpressionRef {
7563- var module = this . module ;
75647551 var releaseInstance = this . program . releaseInstance ;
75657552 this . compileFunction ( releaseInstance ) ;
7566-
75677553 return this . module . call ( releaseInstance . internalName , [ expr ] , NativeType . None ) ;
75687554 }
75697555
@@ -8027,6 +8013,7 @@ export class Compiler extends DiagnosticEmitter {
80278013 thisArg : ExpressionRef = 0 ,
80288014 immediatelyDropped : bool = false
80298015 ) : ExpressionRef {
8016+ console . log ( signature . parameterTypes ) ;
80308017 var numArguments = argumentExpressions . length ;
80318018
80328019 if ( ! this . checkCallSignature ( // reports
@@ -8302,7 +8289,7 @@ export class Compiler extends DiagnosticEmitter {
83028289 prototype . name ,
83038290 prototype ,
83048291 null ,
8305- prototype . hasNestedDefinition ? signature . toClosureSignature ( ) : signature ,
8292+ signature . toClosureSignature ( ) ,
83068293 contextualTypeArguments
83078294 ) ;
83088295 if ( ! this . compileFunction ( instance ) ) return this . module . unreachable ( ) ;
@@ -8513,6 +8500,7 @@ export class Compiler extends DiagnosticEmitter {
85138500 this . currentType = localType ;
85148501 return module . unreachable ( ) ;
85158502 }
8503+ // If this local references a context offset, load its value from the closure context
85168504 var localClosureContextOffset = local . closureContextOffset ;
85178505 if ( localClosureContextOffset > 0 ) {
85188506 let contextLocal = assert ( flow . lookupLocal ( CommonNames . this_ ) ) ;
0 commit comments