@@ -8935,40 +8935,36 @@ export class Compiler extends DiagnosticEmitter {
8935
8935
let field = < Field > member ; assert ( ! field . isAny ( CommonFlags . CONST ) ) ;
8936
8936
let fieldType = field . type ;
8937
8937
let nativeFieldType = fieldType . toNativeType ( ) ;
8938
- let initializerNode = field . prototype . initializerNode ;
8938
+ let fieldPrototype = field . prototype ;
8939
+ let initializerNode = fieldPrototype . initializerNode ;
8940
+ let parameterIndex = fieldPrototype . parameterIndex ;
8941
+ let initExpr : ExpressionRef ;
8939
8942
if ( initializerNode ) { // use initializer
8940
- let initExpr = this . compileExpression ( initializerNode , fieldType , // reports
8943
+ initExpr = this . compileExpression ( initializerNode , fieldType , // reports
8941
8944
Constraints . CONV_IMPLICIT | Constraints . WILL_RETAIN
8942
8945
) ;
8943
8946
if ( fieldType . isManaged && ! this . skippedAutoreleases . has ( initExpr ) ) {
8944
8947
initExpr = this . makeRetain ( initExpr ) ;
8945
8948
}
8946
- stmts . push (
8947
- module . store ( fieldType . byteSize ,
8948
- module . local_get ( thisLocalIndex , nativeSizeType ) ,
8949
- initExpr ,
8950
- nativeFieldType ,
8951
- field . memoryOffset
8952
- )
8953
- ) ;
8954
- } else {
8955
- let parameterIndex = field . prototype . parameterIndex ;
8956
- stmts . push (
8957
- module . store ( fieldType . byteSize ,
8958
- module . local_get ( thisLocalIndex , nativeSizeType ) ,
8959
- parameterIndex >= 0 // initialized via parameter (here: a local)
8960
- ? module . local_get (
8961
- isInline
8962
- ? assert ( flow . lookupLocal ( field . name ) ) . index
8963
- : 1 + parameterIndex , // this is local 0
8964
- nativeFieldType
8965
- )
8966
- : fieldType . toNativeZero ( module ) ,
8967
- nativeFieldType ,
8968
- field . memoryOffset
8969
- )
8949
+ } else if ( parameterIndex >= 0 ) { // initialized via parameter (here: a local)
8950
+ initExpr = module . local_get (
8951
+ isInline
8952
+ ? assert ( flow . lookupLocal ( field . name ) ) . index
8953
+ : 1 + parameterIndex , // this is local 0
8954
+ nativeFieldType
8970
8955
) ;
8956
+ if ( fieldType . isManaged ) initExpr = this . makeRetain ( initExpr ) ;
8957
+ } else { // initialize with zero
8958
+ initExpr = fieldType . toNativeZero ( module ) ;
8971
8959
}
8960
+ stmts . push (
8961
+ module . store ( fieldType . byteSize ,
8962
+ module . local_get ( thisLocalIndex , nativeSizeType ) ,
8963
+ initExpr ,
8964
+ nativeFieldType ,
8965
+ field . memoryOffset
8966
+ )
8967
+ ) ;
8972
8968
}
8973
8969
return stmts ;
8974
8970
}
0 commit comments