@@ -1716,19 +1716,13 @@ export class Compiler extends DiagnosticEmitter {
1716
1716
var type = instance . type ;
1717
1717
var nativeThisType = this . options . nativeSizeType ;
1718
1718
var nativeValueType = type . toNativeType ( ) ;
1719
- var varTypes : NativeType [ ] | null = null ;
1720
1719
var module = this . module ;
1721
1720
var valueExpr = module . load ( type . byteSize , type . is ( TypeFlags . SIGNED ) ,
1722
1721
module . local_get ( 0 , nativeThisType ) ,
1723
1722
nativeValueType , instance . memoryOffset
1724
1723
) ;
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 ) ;
1732
1726
if ( instance . setterRef ) {
1733
1727
instance . set ( CommonFlags . COMPILED ) ;
1734
1728
} else {
@@ -1748,7 +1742,7 @@ export class Compiler extends DiagnosticEmitter {
1748
1742
var valueExpr : ExpressionRef ;
1749
1743
var varTypes : NativeType [ ] | null = null ;
1750
1744
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
1752
1746
// 0: this, 1: value, 2: oldValue (temp)
1753
1747
valueExpr = module . block ( null , [
1754
1748
module . if (
@@ -3624,8 +3618,7 @@ export class Compiler extends DiagnosticEmitter {
3624
3618
var toSignature = toType . signatureReference ;
3625
3619
var fromSignature = fromType . signatureReference ;
3626
3620
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
3629
3622
var tempResult = this . currentFlow . getTempLocal ( fromType ) ;
3630
3623
var convertExpr = module . block ( null , [
3631
3624
module . local_set (
@@ -6872,9 +6865,6 @@ export class Compiler extends DiagnosticEmitter {
6872
6865
return module . unreachable ( ) ;
6873
6866
}
6874
6867
}
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
6878
6868
signature = assert ( signature ) ; // FIXME: asc can't see this yet
6879
6869
var returnType = signature . returnType ;
6880
6870
var tempFunctionReferenceLocal = this . currentFlow . getTempLocal ( this . options . usizeType ) ;
@@ -7551,19 +7541,15 @@ export class Compiler extends DiagnosticEmitter {
7551
7541
7552
7542
/** Makes a retain call, retaining the expression's value. */
7553
7543
makeRetain ( expr : ExpressionRef , type : Type ) : ExpressionRef {
7554
- var module = this . module ;
7555
7544
var retainInstance = this . program . retainInstance ;
7556
7545
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 ) ;
7559
7547
}
7560
7548
7561
7549
/** Makes a release call, releasing the expression's value. Changes the current type to void.*/
7562
7550
makeRelease ( expr : ExpressionRef , type : Type ) : ExpressionRef {
7563
- var module = this . module ;
7564
7551
var releaseInstance = this . program . releaseInstance ;
7565
7552
this . compileFunction ( releaseInstance ) ;
7566
-
7567
7553
return this . module . call ( releaseInstance . internalName , [ expr ] , NativeType . None ) ;
7568
7554
}
7569
7555
@@ -8027,6 +8013,7 @@ export class Compiler extends DiagnosticEmitter {
8027
8013
thisArg : ExpressionRef = 0 ,
8028
8014
immediatelyDropped : bool = false
8029
8015
) : ExpressionRef {
8016
+ console . log ( signature . parameterTypes ) ;
8030
8017
var numArguments = argumentExpressions . length ;
8031
8018
8032
8019
if ( ! this . checkCallSignature ( // reports
@@ -8302,7 +8289,7 @@ export class Compiler extends DiagnosticEmitter {
8302
8289
prototype . name ,
8303
8290
prototype ,
8304
8291
null ,
8305
- prototype . hasNestedDefinition ? signature . toClosureSignature ( ) : signature ,
8292
+ signature . toClosureSignature ( ) ,
8306
8293
contextualTypeArguments
8307
8294
) ;
8308
8295
if ( ! this . compileFunction ( instance ) ) return this . module . unreachable ( ) ;
@@ -8513,6 +8500,7 @@ export class Compiler extends DiagnosticEmitter {
8513
8500
this . currentType = localType ;
8514
8501
return module . unreachable ( ) ;
8515
8502
}
8503
+ // If this local references a context offset, load its value from the closure context
8516
8504
var localClosureContextOffset = local . closureContextOffset ;
8517
8505
if ( localClosureContextOffset > 0 ) {
8518
8506
let contextLocal = assert ( flow . lookupLocal ( CommonNames . this_ ) ) ;
0 commit comments