From: Finn B. <bc...@us...> - 2002-01-07 20:00:13
|
Update of /cvsroot/jython/jython/Tools/jythonc In directory usw-pr-cvs1:/tmp/cvs-serv6014 Modified Files: SimpleCompiler.py Log Message: Support for the __iter__ protocol. Index: SimpleCompiler.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/SimpleCompiler.py,v retrieving revision 2.18 retrieving revision 2.19 diff -C2 -d -r2.18 -r2.19 *** SimpleCompiler.py 2001/12/07 12:58:17 2.18 --- SimpleCompiler.py 2002/01/07 20:00:10 2.19 *************** *** 696,711 **** def for_stmt(self, index, sequence, body, else_body=None): ! counter = self.frame.gettemp('int') item = self.factory.makePyObject(self.frame.gettemp("PyObject")) ! seq = self.frame.gettemp("PyObject") init = [] ! init.append( jast.Set(counter, jast.IntegerConstant(0)) ) ! init.append( jast.Set(seq, self.visit(sequence).asAny()) ) ! ! counter_inc = jast.PostOperation(counter, '++') ! test = jast.Set(item.asAny(), jast.Invoke(seq, "__finditem__", ! [counter_inc])) test = jast.Operation('!=', test, jast.Identifier('null')) --- 696,707 ---- def for_stmt(self, index, sequence, body, else_body=None): ! iter = self.frame.gettemp('PyObject') item = self.factory.makePyObject(self.frame.gettemp("PyObject")) ! seq = self.visit(sequence).asAny() init = [] ! init.append(jast.Set(iter, jast.Invoke(seq, "__iter__", []))) ! test = jast.Set(item.asAny(), jast.Invoke(iter, "__iternext__", [])) test = jast.Operation('!=', test, jast.Identifier('null')) |