Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -393,23 +393,6 @@ private boolean compileSetFieldExpr(AST.SetFieldExpr setFieldExpr) {
return false;
}

private void codeNew(Type type) {
var temp = createTemp(type);
if (type instanceof Type.TypeArray typeArray) {
code(new Instruction.NewArray(typeArray, temp));
}
else if (type instanceof Type.TypeStruct typeStruct) {
code(new Instruction.NewStruct(typeStruct, temp));
}
else
throw new CompilerException("Unexpected type: " + type);
}

private void codeStoreAppend() {
var operand = pop();
code(new Instruction.AStoreAppend((Operand.RegisterOperand) top(), operand));
}

private boolean compileNewExpr(AST.NewExpr newExpr) {
codeNew(newExpr.type);
if (newExpr.initExprList != null && !newExpr.initExprList.isEmpty()) {
Expand Down Expand Up @@ -636,6 +619,23 @@ else if (indexed instanceof Operand.LoadFieldOperand loadFieldOperand) {
code(new Instruction.Move(value, indexed));
}

private void codeNew(Type type) {
var temp = createTemp(type);
if (type instanceof Type.TypeArray typeArray) {
code(new Instruction.NewArray(typeArray, temp));
}
else if (type instanceof Type.TypeStruct typeStruct) {
code(new Instruction.NewStruct(typeStruct, temp));
}
else
throw new CompilerException("Unexpected type: " + type);
}

private void codeStoreAppend() {
var operand = pop();
code(new Instruction.AStoreAppend((Operand.RegisterOperand) top(), operand));
}

private boolean vstackEmpty() {
return virtualStack.isEmpty();
}
Expand Down