Skip to content

Commit 714ce07

Browse files
committed
Fix eslint
1 parent d41aaa6 commit 714ce07

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/compiler/binary-writer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ export class BinaryWriter {
5050
}
5151

5252
private getClassName(classFile: ClassFile) {
53-
const classInfo = classFile.constantPool[classFile.thisClass - 1] as ConstantClassInfo;
54-
const classNameInfo = classFile.constantPool[classInfo.nameIndex - 1] as ConstantUtf8Info;
55-
return classNameInfo.value;
53+
const classInfo = classFile.constantPool[classFile.thisClass - 1] as ConstantClassInfo
54+
const classNameInfo = classFile.constantPool[classInfo.nameIndex - 1] as ConstantUtf8Info
55+
return classNameInfo.value
5656
}
5757

5858
private toBinary(classFile: ClassFile) {

src/compiler/code-generator.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,14 @@ function compile(node: Node, cg: CodeGenerator): CompileResult {
179179
const 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

Comments
 (0)