diff options
author | Peter Wu <lekensteyn@gmail.com> | 2011-12-01 17:27:11 +0000 |
---|---|---|
committer | Peter Wu <lekensteyn@gmail.com> | 2011-12-01 17:27:11 +0000 |
commit | 55ad98c9c392ad92c22d25f6d00978d8cec2959a (patch) | |
tree | f5bafe593dbf82f6a4dd32805ae5bedb8252f678 | |
parent | 8247c54b7bf96d467a28774a97c963534d140a69 (diff) | |
download | pp2cc-55ad98c9c392ad92c22d25f6d00978d8cec2959a.tar.gz |
Separate Function class
-rw-r--r-- | Function.py | 30 | ||||
-rwxr-xr-x | pp2cc.py | 12 |
2 files changed, 31 insertions, 11 deletions
diff --git a/Function.py b/Function.py new file mode 100644 index 0000000..6621fb8 --- /dev/null +++ b/Function.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +"""Compiles C into assembly for the practicum processor (PP2) + +All rights reserved, you may not redistribute or use this program without prior +permission from Peter Wu or Xander Houtman. Use of this program is entirely +your own risk. In no circumstances can the authors of this program be held +responsible for any damage including, but not limited to, financial damage or +data loss. Modification of this program is not allowed without prior +permission. The generated output (assembly and messages) are not subject to +this license. +""" + +__author__ = "Peter Wu" +__copyright__ = "Copyright 2011, Peter Wu" +__credits__ = ["Peter Wu"] +__license__ = "Proprietary" +__version__ = "1.0" +__maintainer__ = "Peter Wu" +__email__ = "uwretep@gmail.com" + +class Function(object): + def __init__(self, node): + self.name = node.decl.name + self.node = node + 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 @@ -15,6 +15,7 @@ from pycparser import c_parser, c_ast from Asm import Asm from Registers import Registers from LinkedNode import LinkedNode +from Function import Function __author__ = "Peter Wu" __copyright__ = "Copyright 2011, Peter Wu" @@ -24,17 +25,6 @@ __version__ = "1.0" __maintainer__ = "Peter Wu" __email__ = "uwretep@gmail.com" -class Function(object): - def __init__(self, node): - self.name = node.decl.name - self.node = node - 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 - class Logger(object): def __init__(self): pass |