diff --git a/src/main/java/de/hsrm/compiler/Klang/visitors/GenASM.java b/src/main/java/de/hsrm/compiler/Klang/visitors/GenASM.java index e9572c6..5bc32f2 100644 --- a/src/main/java/de/hsrm/compiler/Klang/visitors/GenASM.java +++ b/src/main/java/de/hsrm/compiler/Klang/visitors/GenASM.java @@ -567,6 +567,13 @@ public class GenASM implements Visitor { @Override 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; this.currentFunctionStartLabel = lblStart; this.currentFunctionParams = e.parameters; @@ -744,7 +751,8 @@ public class GenASM implements Visitor { 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; } @@ -769,7 +777,7 @@ public class GenASM implements Visitor { @Override 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 return null; } @@ -824,6 +832,9 @@ public class GenASM implements Visitor { @Override 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; }