From 3c8220075b3ac25c9dfcfd1b4daafa1b2ed39c43 Mon Sep 17 00:00:00 2001 From: Xun Yang <x299yang@uwaterloo.ca> Date: Mon, 13 Apr 2020 10:52:13 -0400 Subject: [PATCH] fix obj create --- ExprPrimaryNodes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ExprPrimaryNodes.py b/ExprPrimaryNodes.py index a66264e..cea2917 100644 --- a/ExprPrimaryNodes.py +++ b/ExprPrimaryNodes.py @@ -494,6 +494,7 @@ class ClassCreateNode(ASTNode): # 2. Pointing first item to vtable self.code += importHelper(classDef.name, self.typeName, "C_"+classDef.name) self.code += p(instruction="mov", arg1="[eax]", arg2="dword C_" + classDef.name, comment="first item is vtable pointer") + self.code += p("mov", "ebx", "eax", "store obj ptr at ebx") # 3. Calling constructor self.code += "; Calling constructor for object\n" @@ -504,7 +505,7 @@ class ClassCreateNode(ASTNode): self.args.codeGen() self.code += self.args.code - self.code += p(instruction="push", arg1="eax", comment="pushing object as last argument") + self.code += p(instruction="push", arg1="ebx", comment="pushing object as last argument") label = "M_" + self.cons.typeName + "_" + self.cons.name + "_" + self.cons.paramTypes self.code += importHelper(classDef.name, self.typeName, label) self.code += p(instruction="call", arg1=label, comment="Calling constructor") -- GitLab