Skip to content

Commit 59a83eb

Browse files
Merge pull request #33 from CompilerProgramming/develop
Small refactor to help with the incremental SSA diff
2 parents 1a934a7 + 16e7a79 commit 59a83eb

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

optvm/src/main/java/com/compilerprogramming/ezlang/compiler/CompiledFunction.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -393,23 +393,6 @@ private boolean compileSetFieldExpr(AST.SetFieldExpr setFieldExpr) {
393393
return false;
394394
}
395395

396-
private void codeNew(Type type) {
397-
var temp = createTemp(type);
398-
if (type instanceof Type.TypeArray typeArray) {
399-
code(new Instruction.NewArray(typeArray, temp));
400-
}
401-
else if (type instanceof Type.TypeStruct typeStruct) {
402-
code(new Instruction.NewStruct(typeStruct, temp));
403-
}
404-
else
405-
throw new CompilerException("Unexpected type: " + type);
406-
}
407-
408-
private void codeStoreAppend() {
409-
var operand = pop();
410-
code(new Instruction.AStoreAppend((Operand.RegisterOperand) top(), operand));
411-
}
412-
413396
private boolean compileNewExpr(AST.NewExpr newExpr) {
414397
codeNew(newExpr.type);
415398
if (newExpr.initExprList != null && !newExpr.initExprList.isEmpty()) {
@@ -636,6 +619,23 @@ else if (indexed instanceof Operand.LoadFieldOperand loadFieldOperand) {
636619
code(new Instruction.Move(value, indexed));
637620
}
638621

622+
private void codeNew(Type type) {
623+
var temp = createTemp(type);
624+
if (type instanceof Type.TypeArray typeArray) {
625+
code(new Instruction.NewArray(typeArray, temp));
626+
}
627+
else if (type instanceof Type.TypeStruct typeStruct) {
628+
code(new Instruction.NewStruct(typeStruct, temp));
629+
}
630+
else
631+
throw new CompilerException("Unexpected type: " + type);
632+
}
633+
634+
private void codeStoreAppend() {
635+
var operand = pop();
636+
code(new Instruction.AStoreAppend((Operand.RegisterOperand) top(), operand));
637+
}
638+
639639
private boolean vstackEmpty() {
640640
return virtualStack.isEmpty();
641641
}

0 commit comments

Comments
 (0)