@@ -2952,7 +2952,7 @@ export class Compiler extends DiagnosticEmitter {
29522952 reportNode . range ,
29532953 fromType . toString ( ) ,
29542954 toType . toString ( ) ) ;
2955- } else {
2955+ } else {
29562956 const _interface = ( < Interface > toType . classReference ! ) ;
29572957 let _class = fromType . classReference ! ;
29582958 let incorrectMethods = _interface . checkClass ( _class ) ;
@@ -2966,7 +2966,8 @@ export class Compiler extends DiagnosticEmitter {
29662966 toType . toString ( ) ) ;
29672967 let missingMethods = false ;
29682968 // 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 ] ;
29702971 if ( _class . members == null || ! _class . members . has ( ifunc . name ) ) {
29712972 if ( ! missingMethods ) {
29722973 missingMethods = true ;
@@ -2992,7 +2993,7 @@ export class Compiler extends DiagnosticEmitter {
29922993 _class . name + "." + otherFunc . name ,
29932994 _interface . name + "." + ifunc . name ) ;
29942995 }
2995- } ) ;
2996+ }
29962997 }
29972998
29982999 }
@@ -9194,8 +9195,11 @@ export class Compiler extends DiagnosticEmitter {
91949195 const instanceMethods : Map < number , Map < number , Function > > = new Map ( ) ;
91959196 const interfaceMethods : Map < number , Function [ ] > = new Map ( ) ;
91969197 // 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 ] ;
91999203 const id = func . signature . id ;
92009204 if ( ! interfaceMethods . has ( id ) ) {
92019205 interfaceMethods . set ( id , [ ] ) ;
@@ -9205,20 +9209,18 @@ export class Compiler extends DiagnosticEmitter {
92059209 instanceMethods . set ( id , new Map ( ) ) ;
92069210 }
92079211 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 ) ;
92209223 }
9221- ) ;
92229224 }
92239225 }
92249226
@@ -9235,7 +9237,9 @@ export class Compiler extends DiagnosticEmitter {
92359237 for ( let index : i32 = 0 ; index < iFuncs . length ; index ++ ) {
92369238 const [ funcID , classes ] = iFuncs [ index ] ;
92379239 // 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 ] ;
92399243 iFunc . finalize ( module , this . compileInterfaceMethod ( iFunc , index ) ) ;
92409244 }
92419245 const innerBlock = relooper . addBlock ( module . nop ( ) ) ;
@@ -9288,17 +9292,16 @@ export class Compiler extends DiagnosticEmitter {
92889292 NativeType . I32
92899293 ) ;
92909294 // 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+ }
92919300
92929301 const callIndirect = module . call_indirect (
92939302 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 ( )
93029305 ) ;
93039306
93049307 const body = module . block (
0 commit comments