Changeset 4311:46aae04d710e in livinglogic.python.xist

Show
Ignore:
Timestamp:
02/03/11 14:09:27 (8 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Fix bugs in Java conversion of UL4 template.

Implement Java conversion for function randchoice(?), abs(?) and int(?, ?).

Fix implementation of Java conversion for vars() function.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/ul4c.py

    r4310 r4311  
    18411841        self._do(u"{var}.put({arg}, com.livinglogic.ul4.Utils.truediv({var}.get({arg}), r{op.r1}));".format(var=self._stack[-1].variables, arg=misc.javastring(opcode.arg), op=opcode)) 
    18421842    def _dispatch_floordivvar(self, opcode): 
    1843         name = misc.javastring(opcode.arg) 
    18441843        self._do(u"{var}.put({arg}, com.livinglogic.ul4.Utils.floordiv({var}.get({arg}), r{op.r1}));".format(var=self._stack[-1].variables, arg=misc.javastring(opcode.arg), op=opcode)) 
    18451844    def _dispatch_modvar(self, opcode): 
     
    19651964            self._do(u"r{op.r1} = com.livinglogic.ul4.Utils.{op.arg}();".format(op=opcode)) 
    19661965        elif opcode.arg == "vars": 
    1967             self._do(u"r{op.r1} = {var};".format(op=opcode, var=variables)) 
     1966            self._do(u"r{op.r1} = {var};".format(op=opcode, var=self._stack[-1].variables)) 
    19681967        else: 
    19691968            raise UnknownFunctionError(opcode.arg) 
    19701969        self._usereg(opcode.r1) 
    19711970    def _dispatch_callfunc1(self, opcode): 
    1972         if opcode.arg in {"xmlescape", "csv", "repr", "enumerate", "chr", "ord", "hex", "oct", "bin", "sorted", "range", "type", "json", "reversed", "randrange"}: 
     1971        if opcode.arg in {"xmlescape", "csv", "repr", "enumerate", "chr", "ord", "hex", "oct", "bin", "sorted", "range", "type", "json", "reversed", "randrange", "randchoice", "abs"}: 
    19731972            self._do(u"r{op.r1} = com.livinglogic.ul4.Utils.{op.arg}(r{op.r2});".format(op=opcode)) 
    19741973        elif opcode.arg == "str": 
     
    20102009        if opcode.arg in {"range", "zip", "randrange"}: 
    20112010            self._do(u"r{op.r1} = com.livinglogic.ul4.Utils.{op.arg}(r{op.r2}, r{op.r3});".format(op=opcode)) 
     2011        elif opcode.arg == "int": 
     2012            self._do(u"r{op.r1} = com.livinglogic.ul4.Utils.toInteger(r{op.r2}, r{op.r3});".format(op=opcode)) 
    20122013        elif opcode.arg == "get": 
    20132014            self._do(u"r{op.r1} = {var}.containsKey(r{op.r2}) ? {var}.get(r{op.r2}) : r{op.r3};".format(op=opcode.r1, var=self._stack[-1].variables))