summaryrefslogtreecommitdiff
path: root/Function.py
diff options
context:
space:
mode:
Diffstat (limited to 'Function.py')
-rw-r--r--Function.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/Function.py b/Function.py
index de0c49d..38d01ea 100644
--- a/Function.py
+++ b/Function.py
@@ -19,10 +19,19 @@ __maintainer__ = "Peter Wu"
__email__ = "uwretep@gmail.com"
class Function(object):
- def __init__(self, node):
- self.name = node.decl.name
- self.node = node
+ def __init__(self, decl_node):
+ """Initializes an object for holding a function declaration and related
+ properties
+
+ Keyword arguments:
+ decl_node -- A Node object
+ """
+ assert type(decl_node).__name__ == "FuncDecl", ("decl_node is not a"
+ " function declaration")
+ self.decl_node = decl_node
+ self.name = self.decl_node.type.declname
self.reserved_stack = 0
+ self.linked_node = None
def labelBegin(self):
"""Returns a label pointing to the begin of a function"""
return "fn_" + self.name
@@ -40,3 +49,11 @@ class Function(object):
begin_address = self.reserved_stack + 1
self.reserved_stack += count
return begin_address
+ def setLinkedNode(self, linked_node):
+ """Assigns this function to a function node"""
+ assert linked_node.type == "FuncDef", ("Only function definitions can"
+ " be linked to a function")
+ self.linked_node = linked_node
+ def isLinked(self):
+ """Returns True if this function object is already linked to a node"""
+ return self.linked_node is not None