diff options
author | José Fonseca <[email protected]> | 2008-08-22 01:23:48 +0100 |
---|---|---|
committer | José Fonseca <[email protected]> | 2008-08-22 01:23:48 +0100 |
commit | 7f3c3683ce50bad42411547d4b78e03d7f20e498 (patch) | |
tree | 44e934ab2ad70cba06e20820c7c570442a29b05d /src/gallium/state_trackers/python/retrace/interpreter.py | |
parent | 10624065b0dc631164d786b2c39f35655e55eadf (diff) |
python/retrace: Process the trace call-by-call (instead of reading everything into memory).
Diffstat (limited to 'src/gallium/state_trackers/python/retrace/interpreter.py')
-rwxr-xr-x | src/gallium/state_trackers/python/retrace/interpreter.py | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index f596a54d102..a2f924f5280 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -22,7 +22,7 @@ import sys import gallium import model -from parser import TraceParser +import parser def make_image(surface): @@ -426,9 +426,10 @@ class Context(Object): show_image(self.cbufs[0]) -class Interpreter: +class Interpreter(parser.TraceParser): - def __init__(self): + def __init__(self, stream): + parser.TraceParser.__init__(self, stream) self.objects = {} self.result = None self.globl = Global(self, None) @@ -447,7 +448,7 @@ class Interpreter: for call in trace.calls: self.interpret_call(call) - def interpret_call(self, call): + def handle_call(self, call): sys.stderr.write("%s\n" % call) args = [self.interpret_arg(arg) for name, arg in call.args] @@ -469,18 +470,5 @@ class Interpreter: return translator.visit(node) -def main(): - for arg in sys.argv[1:]: - if arg.endswith('.gz'): - import gzip - stream = gzip.GzipFile(arg, 'rt') - else: - stream = open(arg, 'rt') - parser = TraceParser(stream) - trace = parser.parse() - interpreter = Interpreter() - interpreter.interpret(trace) - - if __name__ == '__main__': - main() + parser.main(Interpreter) |