Skip to content
Snippets Groups Projects

New new string

Merged Xun Yang requested to merge new-new-string into master
1 file
+ 10
2
Compare changes
  • Side-by-side
  • Inline
+ 10
2
@@ -35,6 +35,13 @@ class LiteralNode(ASTNode):
self.value = False
else:
self.value = True
if self.value == "'\\n'":
self.value = ord('\n')
elif self.name == 'char' and len(self.value) == 3:
self.value = ord(self.value[1])
elif self.name == 'char':
self.value = ord(self.value)
def linkType(self):
if self.name == "java.lang.String":
@@ -57,7 +64,8 @@ class LiteralNode(ASTNode):
# char
if self.name == 'char':
self.code += p("mov", "eax", str("dword " + self.getConstant()), " set to literal char")
# store literal char as ASCII
self.code += p("mov", "eax", str(self.getConstant()), " set to literal char")
return
# string
@@ -92,7 +100,7 @@ class LiteralNode(ASTNode):
self.code += ";Start of populating char array\n"
# loop through string
for i in range(len(value)):
self.code += p(instruction="mov", arg1="[eax+"+str(8+i*4)+"]", arg2=str("dword '"+value[i]+"'"), comment="a["+str(i)+"]="+str(value[i]))
self.code += p(instruction="mov", arg1="[eax+"+str(8+i*4)+"]", arg2="dword " + str(ord(value[i])), comment="a["+str(i)+"]="+str(value[i]))
self.code += ";End of populating char array\n"
# 5. Restoring ecx
Loading