diff options
author | Matthew Sotoudeh <matthew@masot.net> | 2023-07-27 14:26:33 -0700 |
---|---|---|
committer | Matthew Sotoudeh <matthew@masot.net> | 2023-07-27 14:26:33 -0700 |
commit | 2b8985608d33abaae7b201a008e292cbbe2167ef (patch) | |
tree | 58a76aaf7c7447988b1c78095480dc8bce5d2ab4 /python/dietc.py | |
parent | 578531395ecbabd8179e31520c2832ac7d6d3765 (diff) |
add automated refcounting pass
Diffstat (limited to 'python/dietc.py')
-rw-r--r-- | python/dietc.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/python/dietc.py b/python/dietc.py index 1101062..58d7e42 100644 --- a/python/dietc.py +++ b/python/dietc.py @@ -43,7 +43,7 @@ class Function: def code_start(self): return next(i for i, l in enumerate(self.body) - if not l.line.startswith("\tType_")) + if not l[0].startswith("Type_")) def insert(self, i, string): self.body.insert(i, Instruction(string)) @@ -71,6 +71,11 @@ class Instruction: if self[0] == "*": return program.object_types[self[1]].base return program.object_types[self[0]] + def replace_token(self, old, new): + self = Instruction(self.line) + self.tokens = [t if t != old else new for t in self.tokens] + self.line = ' '.join(self.tokens) + return self class Program: def __init__(self, string): |