@@ -179,13 +179,14 @@ function compile(node: Node, cg: CodeGenerator): CompileResult {
179179const codeGenerators : { [ type : string ] : ( node : Node , cg : CodeGenerator ) => CompileResult } = {
180180 Block : ( node : Node , cg : CodeGenerator ) => {
181181 cg . symbolTable . extend ( )
182+ const block = node as Block
182183 let maxStack = 0
183- let resultType = ''
184- ; ( node as Block ) . blockStatements . forEach ( x => {
185- const { stackSize : stackSize , resultType : type } = compile ( x , cg )
186- maxStack = Math . max ( maxStack , stackSize )
187- resultType = type
188- } )
184+ let resultType = EMPTY_TYPE
185+ block . blockStatements . forEach ( x => {
186+ const { stackSize : stackSize , resultType : type } = compile ( x , cg )
187+ maxStack = Math . max ( maxStack , stackSize )
188+ resultType = type
189+ } )
189190 cg . symbolTable . teardown ( )
190191
191192 return { stackSize : maxStack , resultType }
@@ -548,8 +549,8 @@ const codeGenerators: { [type: string]: (node: Node, cg: CodeGenerator) => Compi
548549 } ,
549550
550551 ExpressionStatement : ( node : Node , cg : CodeGenerator ) => {
551- const n = node as ExpressionStatement
552- return compile ( n . stmtExp , cg )
552+ const { stmtExp } = node as ExpressionStatement
553+ return compile ( stmtExp , cg )
553554 } ,
554555
555556 MethodInvocation : ( node : Node , cg : CodeGenerator ) => {
@@ -803,7 +804,8 @@ const codeGenerators: { [type: string]: (node: Node, cg: CodeGenerator) => Compi
803804 field
804805 )
805806 }
806- const fetchedFieldTypeDescriptor = ( fieldInfos [ fieldInfos . length - 1 ] as FieldInfo ) . typeDescriptor
807+ const fetchedFieldTypeDescriptor = ( fieldInfos [ fieldInfos . length - 1 ] as FieldInfo )
808+ . typeDescriptor
807809 return {
808810 stackSize : 1 + ( [ 'D' , 'J' ] . includes ( fetchedFieldTypeDescriptor ) ? 1 : 0 ) ,
809811 resultType : fetchedFieldTypeDescriptor
0 commit comments