[Wisp-cvs] wisp/users/dig tran.py,1.5,1.6
Status: Alpha
Brought to you by:
digg
From: <di...@us...> - 2003-04-14 14:15:06
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv12898 Modified Files: tran.py Log Message: simplified the Register class Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- tran.py 14 Apr 2003 02:09:39 -0000 1.5 +++ tran.py 14 Apr 2003 14:15:00 -0000 1.6 @@ -34,14 +34,16 @@ except: pass return tok -class _Register (tuple): +class Register (tuple): + def __new__ (cls, *args): + return tuple.__new__(cls, args) def parent (this): - if len(this): return _Register(this[:-1]) + if len(this): return apply(Register, this[:-1]) else: return None def child_generator (this): i = 0 while 1: - yield Register(this + (i,)) + yield apply(Register, this + (i,)) i += 1 def __repr__ (this): return 'Register' + tuple.__repr__(this) @@ -50,9 +52,6 @@ def __init__ (this, id): this.id = id -def Register (*args): - return _Register(args) - def b_comma (n): if type(n) == LongType: cursect.emit_byte(n) elif type(n) == StringType: cursect.emit_byte_sum([n]) @@ -109,7 +108,7 @@ elif type(object) == StringType: yield 'sym' yield 'lit' - elif isinstance(object, _Register): + elif isinstance(object, Register): while object <> None: yield Registers[object] object = object.parent() |