Skip to content
Snippets Groups Projects
Commit 8ba08dc8 authored by pycsham's avatar pycsham
Browse files

fixed issue with method invocation. the J1_basicTest (static method invocation) now works

parent de30d33c
No related branches found
No related tags found
No related merge requests found
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
# String, String, String/None, String/None # String, String, String/None, String/None
def p(instruction, arg1, arg2="", comment=""): def p(instruction, arg1, arg2="", comment=""):
result = " " + instruction + " " + str(arg1) result = " " + instruction + " " + str(arg1)
if arg2: if arg2 or arg2 == 0:
result += ", " + arg2 result += ", " + str(arg2)
if comment: if comment:
result += " ;" + comment result += " ;" + comment
return result + "\n" return result + "\n"
...@@ -65,14 +65,8 @@ def genProcedure(content, comment): ...@@ -65,14 +65,8 @@ def genProcedure(content, comment):
# Adds method invoke prologue and eilogie around the content # Adds method invoke prologue and eilogie around the content
def genMethodInvoke(method): def genMethodInvoke(method):
pro = ";Calling a method " + method + "\n" \ pro = ";Calling a method " + method + "\n" \
+ p(instruction="push", arg1="eax", comment="saving caller-save register eax") \
+ p(instruction="push", arg1="ecx", comment="saving caller-save register ecx") \ epi = "; End of method invocation\n"
+ p(instruction="push", arg1="edx", comment="saving caller-save register edx")
epi = p(instruction="pop", arg1="edx", comment="restoring caller-save register edx") \
+ p(instruction="pop", arg1="ecx", comment="restoring caller-save register ecx") \
+ p(instruction="pop", arg1="eax", comment="restoring caller-save register eax") \
+ "; End of method invocation\n"
return (pro, epi) return (pro, epi)
......
...@@ -3,12 +3,12 @@ public class J1_basicTest { ...@@ -3,12 +3,12 @@ public class J1_basicTest {
public J1_basicTest() {} public J1_basicTest() {}
public static int test() { public static int test() {
return J1_basicTest.test2();
}
public static int test2(){
if (true) if (true)
return 123; return 123;
return 7; return 7;
} }
public static void test2(){
J1_basicTest.test();
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment