@@ -2952,7 +2952,7 @@ export class Compiler extends DiagnosticEmitter {
2952
2952
reportNode . range ,
2953
2953
fromType . toString ( ) ,
2954
2954
toType . toString ( ) ) ;
2955
- } else {
2955
+ } else {
2956
2956
const _interface = ( < Interface > toType . classReference ! ) ;
2957
2957
let _class = fromType . classReference ! ;
2958
2958
let incorrectMethods = _interface . checkClass ( _class ) ;
@@ -2966,7 +2966,8 @@ export class Compiler extends DiagnosticEmitter {
2966
2966
toType . toString ( ) ) ;
2967
2967
let missingMethods = false ;
2968
2968
// tslint:disable-next-line: as-types
2969
- incorrectMethods . forEach ( ifunc => {
2969
+ for ( let i : i32 = 0 ; i < incorrectMethods . length ; i ++ ) {
2970
+ const ifunc = incorrectMethods [ i ] ;
2970
2971
if ( _class . members == null || ! _class . members . has ( ifunc . name ) ) {
2971
2972
if ( ! missingMethods ) {
2972
2973
missingMethods = true ;
@@ -2992,7 +2993,7 @@ export class Compiler extends DiagnosticEmitter {
2992
2993
_class . name + "." + otherFunc . name ,
2993
2994
_interface . name + "." + ifunc . name ) ;
2994
2995
}
2995
- } ) ;
2996
+ }
2996
2997
}
2997
2998
2998
2999
}
@@ -9194,8 +9195,11 @@ export class Compiler extends DiagnosticEmitter {
9194
9195
const instanceMethods : Map < number , Map < number , Function > > = new Map ( ) ;
9195
9196
const interfaceMethods : Map < number , Function [ ] > = new Map ( ) ;
9196
9197
// Gather all instatiated interface methods
9197
- for ( let _interface of interfaces ) {
9198
- for ( let func of _interface . methodInstances ) {
9198
+
9199
+ for ( let i : i32 = 0 ; i < interfaces . length ; i ++ ) {
9200
+ const _interface = interfaces [ i ] ;
9201
+ for ( let j : i32 = 0 ; j < _interface . methodInstances . length ; j ++ ) {
9202
+ const func = _interface . methodInstances [ j ] ;
9199
9203
const id = func . signature . id ;
9200
9204
if ( ! interfaceMethods . has ( id ) ) {
9201
9205
interfaceMethods . set ( id , [ ] ) ;
@@ -9205,20 +9209,18 @@ export class Compiler extends DiagnosticEmitter {
9205
9209
instanceMethods . set ( id , new Map ( ) ) ;
9206
9210
}
9207
9211
const currentMap = instanceMethods . get ( id ) ! ;
9208
- < Function [ ] > _interface . getFuncImplementations ( func ) . map (
9209
- // tslint:disable-next-line: as-types
9210
- funcP => {
9211
- // TODO: Better way to pass contextual type info
9212
- const newFunc = this . resolver . resolveFunction ( funcP , null , func . contextualTypeArguments ) ;
9213
- if ( newFunc == null ) {
9214
- throw new Error ( `Couldn't resolve ${ funcP . name } ` ) ;
9215
- }
9216
- this . compileFunction ( newFunc ) ;
9217
- this . ensureFunctionTableEntry ( newFunc ) ;
9218
- currentMap . set ( ( < Class > newFunc . parent ) . id , newFunc ) ;
9219
- return newFunc ;
9212
+ const methods = _interface . getFuncImplementations ( func ) ;
9213
+ for ( let k : i32 = 0 ; k < methods . length ; k ++ ) {
9214
+ const funcP = methods [ k ] ;
9215
+ // TODO: Better way to pass contextual type info
9216
+ const newFunc = this . resolver . resolveFunction ( funcP , null , func . contextualTypeArguments ) ;
9217
+ if ( newFunc == null ) {
9218
+ throw new Error ( `Couldn't resolve ${ funcP . name } ` ) ;
9219
+ }
9220
+ this . compileFunction ( newFunc ) ;
9221
+ this . ensureFunctionTableEntry ( newFunc ) ;
9222
+ currentMap . set ( ( < Class > newFunc . parent ) . id , newFunc ) ;
9220
9223
}
9221
- ) ;
9222
9224
}
9223
9225
}
9224
9226
@@ -9235,7 +9237,9 @@ export class Compiler extends DiagnosticEmitter {
9235
9237
for ( let index : i32 = 0 ; index < iFuncs . length ; index ++ ) {
9236
9238
const [ funcID , classes ] = iFuncs [ index ] ;
9237
9239
// Compile the interface methods with index
9238
- for ( const iFunc of interfaceMethods . get ( funcID ) ! ) {
9240
+ const IFuncs = interfaceMethods . get ( funcID ) ! ;
9241
+ for ( let i : i32 = 0 ; i < IFuncs . length ; i ++ ) {
9242
+ const iFunc = IFuncs [ i ] ;
9239
9243
iFunc . finalize ( module , this . compileInterfaceMethod ( iFunc , index ) ) ;
9240
9244
}
9241
9245
const innerBlock = relooper . addBlock ( module . nop ( ) ) ;
@@ -9288,17 +9292,16 @@ export class Compiler extends DiagnosticEmitter {
9288
9292
NativeType . I32
9289
9293
) ;
9290
9294
// module.removeFunction(member.internalName);
9295
+ const locals : usize [ ] = [ ] ;
9296
+ for ( let i : i32 = 0 ; i < func . localsByIndex . length ; i ++ ) {
9297
+ const local = func . localsByIndex [ i ] ;
9298
+ locals . push ( module . local_get ( local . index , local . type . toNativeType ( ) ) ) ;
9299
+ }
9291
9300
9292
9301
const callIndirect = module . call_indirect (
9293
9302
callVirtual ,
9294
- func . localsByIndex . map < usize > ( ( local : Local ) : usize =>
9295
- module . local_get ( local . index , local . type . toNativeType ( ) )
9296
- ) ,
9297
- Signature . makeSignatureString (
9298
- func . signature . parameterTypes ,
9299
- func . signature . returnType ,
9300
- func . signature . thisType
9301
- )
9303
+ locals ,
9304
+ func . signature . toSignatureString ( )
9302
9305
) ;
9303
9306
9304
9307
const body = module . block (
0 commit comments