Changeset 53:21791a71f718 in livinglogic.java.ul4

Show
Ignore:
Timestamp:
05/31/08 17:18:05 (11 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Use the Java implementation of the AST nodes for unary opperations.

Fix a typo in expr_not.

Remove another debug raise.

Location:
library/src/com/livinglogic/sxtl
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • library/src/com/livinglogic/sxtl/Const.java

    r47 r53  
    11package com.livinglogic.sxtl; 
    22 
    3 class Const extends AST 
     3public abstract class Const extends AST 
    44{ 
    55    public Const(int start, int end) 
    66    { 
    77        super(start, end); 
    8     } 
    9  
    10     public String getType() 
    11     { 
    12         return null; 
    138    } 
    149 
  • library/src/com/livinglogic/sxtl/Main.java

    r47 r53  
    1616        CompilerFactory factory = new CompilerFactory(); 
    1717        System.out.println("made Factory " + (time()-start)); 
    18         Template tmpl = factory.compile("<?if data?><ul><?for item in data?><?render line(item)?><?end for?></ul><?end if?>"); 
     18        Template tmpl = factory.compile("<?code x=42?><?print not (-x)?><?if data?><ul><?for item in data?><?render line(item)?><?end for?></ul><?end if?>"); 
    1919        Template linetmpl = factory.compile("<li><?print None?><?print False?><?print True?><?print 42?><?print 4.2?><?print 'gurk'?>(<?print xmlescape(data)?>)</li>"); 
    2020        System.out.println("compiled " + (time()-start)); 
  • library/src/com/livinglogic/sxtl/l4c.py

    r51 r53  
    248248            raise 
    249249        except Exception, exc: 
    250             raise 
    251250            raise Error(exc).decorate(location) 
    252251    if stack: 
     
    284283 
    285284 
    286 from com.livinglogic.sxtl import None as None_, True as True_, False as False_, Int, Float, Str, Name 
     285from com.livinglogic.sxtl import Const, None as None_, True as True_, False as False_, Int, Float, Str, Name, GetSlice, Not, Neg 
    287286 
    288287 
     
    346345        registers.free(r3) 
    347346        return r1 
    348  
    349  
    350 class Unary(AST): 
    351     opcode = None 
    352  
    353     def __init__(self, start, end, obj): 
    354         AST.__init__(self, start, end) 
    355         self.obj = obj 
    356  
    357     def __repr__(self): 
    358         return "%s(%r, %r, %r)" % (self.__class__.__name__, self.start, self.end, self.obj) 
    359  
    360     def compile(self, template, registers, location): 
    361         r = self.obj.compile(template, registers, location) 
    362         template.opcode(self.opcode, r, r, location) 
    363         return r 
    364  
    365  
    366 class GetSlice(Unary): 
    367     opcode = "getslice" 
    368  
    369  
    370 class Not(Unary): 
    371     opcode = "not" 
    372  
    373  
    374 class Neg(Unary): 
    375     opcode = "neg" 
    376347 
    377348 
     
    955926 
    956927    def expr_not(self, (_0, expr)): 
    957         if isinstance(expr1, Const): # Constant folding 
     928        if isinstance(expr, Const): # Constant folding 
    958929            return self.makeconst(_0.start, expr.end, not expr.value) 
    959930        return Not(_0.start, expr.end, expr)