feature/add-enum-support #1
@@ -567,6 +567,13 @@ public class GenASM implements Visitor<Void> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visit(FunctionDefinition e) {
|
public Void visit(FunctionDefinition e) {
|
||||||
|
// If the user chooses "main" as one of his function names then
|
||||||
|
// rename it and hope that they didn't use the renamed function name
|
||||||
|
// as well :D
|
||||||
|
if (e.name.equals("main")) {
|
||||||
|
e.name = "main_by_user";
|
||||||
|
}
|
||||||
|
|
||||||
int lblStart = ++lCount;
|
int lblStart = ++lCount;
|
||||||
this.currentFunctionStartLabel = lblStart;
|
this.currentFunctionStartLabel = lblStart;
|
||||||
this.currentFunctionParams = e.parameters;
|
this.currentFunctionParams = e.parameters;
|
||||||
@@ -744,7 +751,8 @@ public class GenASM implements Visitor<Void> {
|
|||||||
asm.add("q", stackStartOffset, "%rsp");
|
asm.add("q", stackStartOffset, "%rsp");
|
||||||
}
|
}
|
||||||
|
|
||||||
asm.call(e.name);
|
// We rename a function name if it is "main"
|
||||||
|
asm.call(e.name.equals("main") ? "main_by_user": e.name);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -769,7 +777,7 @@ public class GenASM implements Visitor<Void> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visit(Parameter e) {
|
public Void visit(Parameter e) {
|
||||||
// The work for a paremeter node is implement
|
// The work for a parameter node is implement
|
||||||
// in the function definition visitor
|
// in the function definition visitor
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -824,6 +832,9 @@ public class GenASM implements Visitor<Void> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void visit(EnumAccessExpression e) {
|
public Void visit(EnumAccessExpression e) {
|
||||||
|
// Since the access to an enum simply results in an integer (i.e. the index
|
||||||
|
// of the enum value), we can just let IntegerExpression handle the expected behaviour.
|
||||||
|
new IntegerExpression(e.enumValue.index).welcome(this);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user