Changeset 5345:d6cc4c625482 in livinglogic.python.xist for src/ll/ul4c.py

Show
Ignore:
Timestamp:
02/12/13 13:52:25 (7 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Move stuff around.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/ul4c.py

    r5344 r5345  
    243243 
    244244### 
    245 ### Compiler stuff: Nodes for the AST 
     245### Helper functions 
    246246### 
     247 
    247248 
    248249def handleeval(f): 
     
    265266        return "({})".format(", ".join(_formatnestednameul4(name) for name in name)) 
    266267 
     268 
     269 
     270def _unpackvar(vars, name, value): 
     271    if isinstance(name, str): 
     272        vars[name] = value 
     273    else: 
     274        if len(name) > len(value): 
     275            raise TypeError("too many values to unpack (expected {})".format(len(name))) 
     276        elif len(name) < len(value): 
     277            raise TypeError("need more than {} value{} to unpack)".format(len(values), "ss" if len(values) != 1 else "")) 
     278        for (name, value) in zip(name, value): 
     279            _unpackvar(vars, name, value) 
     280 
     281 
     282### 
     283### Compiler stuff: Nodes for the AST 
     284### 
    267285 
    268286class AST(Object): 
     
    34143432                p.breakable() 
    34153433                p.text("at {:#x}".format(id(self))) 
    3416  
    3417  
    3418 ### 
    3419 ### Helper classes/functions used at runtime 
    3420 ### 
    3421  
    3422 def _unpackvar(vars, name, value): 
    3423     if isinstance(name, str): 
    3424         vars[name] = value 
    3425     else: 
    3426         if len(name) > len(value): 
    3427             raise TypeError("too many values to unpack (expected {})".format(len(name))) 
    3428         elif len(name) < len(value): 
    3429             raise TypeError("need more than {} value{} to unpack)".format(len(values), "ss" if len(values) != 1 else "")) 
    3430         for (name, value) in zip(name, value): 
    3431             _unpackvar(vars, name, value)