[pypy-svn] r73728 - in pypy/trunk/pypy/jit/tl: . test
fijal at codespeak.net
fijal at codespeak.net
Wed Apr 14 07:28:15 CEST 2010
Author: fijal
Date: Wed Apr 14 07:28:14 2010
New Revision: 73728
Added:
pypy/trunk/pypy/jit/tl/test/test_tinyframe.py (contents, props changed)
Modified:
pypy/trunk/pypy/jit/tl/tinyframe.py
Log:
commit today's progress - not very much of that
Added: pypy/trunk/pypy/jit/tl/test/test_tinyframe.py
==============================================================================
--- (empty file)
+++ pypy/trunk/pypy/jit/tl/test/test_tinyframe.py Wed Apr 14 07:28:14 2010
@@ -0,0 +1,18 @@
+
+import py
+py.test.skip("work in progress")
+
+from pypy.jit.tl.tinyframe import *
+
+class TestCompile(object):
+ def test_simple(self):
+ code = compile('''
+ LOAD 0 => r1
+ LOAD 1 => r0 # comment
+ # other comment
+ ADD r0, r1 => r2
+ PRINT r2
+ ''')
+ assert disassemble(code) == [
+ LOAD, 0, 1, LOAD, 1, 0, ADD, 0, 1, 2, PRINT, 2
+ ]
Modified: pypy/trunk/pypy/jit/tl/tinyframe.py
==============================================================================
--- pypy/trunk/pypy/jit/tl/tinyframe.py (original)
+++ pypy/trunk/pypy/jit/tl/tinyframe.py Wed Apr 14 07:28:14 2010
@@ -18,11 +18,35 @@
function argument always comes in r0
"""
+opcodes = ['ADD', 'INTROSPECT', 'PRINT', 'CALL', 'LOAD']
+for i, opcode in enumerate(opcodes):
+ globals()[opcode] = i
+
class Code(object):
_immutable_ = True
def __init__(self, code):
code = code
+class Parser(object):
+ def compile(self, strrepr):
+ self.code = []
+ for line in strrepr.splitlines():
+ comment = line.find('#')
+ if comment != -1:
+ line = line[:comment]
+ line = line.strip()
+ if not line:
+ continue
+ opcode, args = line.split(" ", 1)
+ getattr(self, 'compile_' + opcode)(args)
+
+ def compile_ADD(self, args):
+ xxx
+
+ def compile_LOAD(self, args):
+ self.code.append(
+
def compile(strrepr):
- pass
+ parser = Parser()
+ return parser.compile(strrepr)
More information about the Pypy-commit
mailing list