ok we have basic decimal math 👍

This commit is contained in:
SpookyDervish
2025-09-04 07:45:20 +10:00
parent 42e718d6d3
commit 459f53a4e1
8 changed files with 162 additions and 72 deletions

View File

@@ -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