diff --git a/ExprPrimaryNodes.py b/ExprPrimaryNodes.py index a66264e1e879fab17431bd08a95600b5de653432..cea29170ba30fc0ab5b163c10937ae56902d5477 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")