ok we have basic decimal math 👍
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from ground_ast import RootNode
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Generator:
|
||||
@@ -8,6 +9,17 @@ class Generator:
|
||||
self.code = code
|
||||
self.output_path = output_path
|
||||
self.variables = {}
|
||||
self.constants = {}
|
||||
self.constants_reverse = {}
|
||||
self.constant_counter = 0
|
||||
|
||||
def add_constant(self, value: Any):
|
||||
existing_constant_name = self.constants_reverse.get(value, None)
|
||||
if existing_constant_name != None: return f"[.{existing_constant_name}]"
|
||||
self.constants["LC" + str(self.constant_counter)] = value
|
||||
self.constants_reverse[value] = "LC" + str(self.constant_counter)
|
||||
self.constant_counter += 1
|
||||
return "[.LC" + str(self.constant_counter-1) + "]"
|
||||
|
||||
def init(self):
|
||||
pass
|
||||
|
Reference in New Issue
Block a user