diff options
Diffstat (limited to 'Function.py')
-rw-r--r-- | Function.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Function.py b/Function.py index 6621fb8..de0c49d 100644 --- a/Function.py +++ b/Function.py @@ -22,9 +22,21 @@ class Function(object): def __init__(self, node): self.name = node.decl.name self.node = node + self.reserved_stack = 0 def labelBegin(self): """Returns a label pointing to the begin of a function""" return "fn_" + self.name def labelEnd(self): """Returns a label pointing to the end of a function""" return "fne_" + self.name + def allocStack(self, count=1): + """Reserve some memory (for local variables and params) on the stack + and return the begin of the allocated memory + + Keyword arguments: + count -- The number of words to be allocated which should be at least 1 + """ + assert count > 0, "The stack allocation count must be at least 1" + begin_address = self.reserved_stack + 1 + self.reserved_stack += count + return begin_address |