[pypy-svn] r18656 - in pypy/dist/pypy/translator/squeak: . test
bert at codespeak.net
bert at codespeak.net
Sat Oct 15 19:35:05 CEST 2005
Author: bert
Date: Sat Oct 15 19:35:05 2005
New Revision: 18656
Modified:
pypy/dist/pypy/translator/squeak/gensqueak.py
pypy/dist/pypy/translator/squeak/test/test_oo.py
Log:
implement setfield and getfield
Modified: pypy/dist/pypy/translator/squeak/gensqueak.py
==============================================================================
--- pypy/dist/pypy/translator/squeak/gensqueak.py (original)
+++ pypy/dist/pypy/translator/squeak/gensqueak.py Sat Oct 15 19:35:05 2005
@@ -9,8 +9,9 @@
selectormap = {
'setitem:with:': 'at:put:',
'getitem:': 'at:',
- 'new': 'new',
+ 'new': 'new',
'sameAs': 'yourself',
+ 'intAdd:': '+',
}
def camel_case(str):
@@ -39,10 +40,15 @@
if (':' in sel):
parts = []
names = sel.split(':')
+# assert len(names) == len(args)
while args:
parts.append(names.pop(0) + ': ' + args.pop(0))
return ' '.join(parts)
+ elif not sel[0].isalnum():
+# assert len(args) == 1
+ return "%s %s" %(sel, args[0])
else:
+# assert len(args) == 0
return sel
@@ -151,10 +157,18 @@
def oper(op):
args = [expr(arg) for arg in op.args]
if op.opname == "oosend":
- name = args[0]
+ name = op.args[0].value
receiver = args[1]
args = args[2:]
self.note_meth(op.args[1].concretetype, name)
+ elif op.opname == "oogetfield":
+ receiver = args[0]
+ name = op.args[1].value
+ args = args[2:]
+ elif op.opname == "oosetfield":
+ receiver = args[0]
+ name = op.args[1].value
+ args = args[2:]
else:
name = op.opname
receiver = args[0]
@@ -258,7 +272,7 @@
return str(i)
def nameof_str(self, s):
- return s
+ return "'s'"
def nameof_function(self, func):
#XXX this should actually be a StaticMeth
Modified: pypy/dist/pypy/translator/squeak/test/test_oo.py
==============================================================================
--- pypy/dist/pypy/translator/squeak/test/test_oo.py (original)
+++ pypy/dist/pypy/translator/squeak/test/test_oo.py Sat Oct 15 19:35:05 2005
@@ -12,7 +12,7 @@
t.specialize(type_system="ootype")
t.simplify()
if view:
- t.view()
+ t.viewcg()
GenSqueak(udir, t)
@@ -30,8 +30,17 @@
c = new(C)
return c.m(5)
+def f_fields():
+ c = new(C)
+ x = c.a + 1
+ c.a = x
+ return x
+
def test_simple_new():
build_sqfunc(f_new)
def test_simple_meth():
- build_sqfunc(f_meth, view=False)
+ build_sqfunc(f_meth)
+
+def test_simple_fields():
+ build_sqfunc(f_fields, view=False)
More information about the Pypy-commit
mailing list