[Wisp-cvs] wisp/users/dig interpreter.py,1.2,1.3
Status: Alpha
Brought to you by:
digg
From: <di...@us...> - 2003-05-17 12:02:01
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv23206 Modified Files: interpreter.py Log Message: introduced Register.names Index: interpreter.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/interpreter.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- interpreter.py 17 May 2003 11:46:36 -0000 1.2 +++ interpreter.py 17 May 2003 12:01:58 -0000 1.3 @@ -139,22 +139,24 @@ else: return Lexer.get_token(this) class Register (tuple, Stackable): - def __new__ (cls, items): - return tuple.__new__(cls, items) + def __new__ (cls, items, names = None): + this = tuple.__new__(cls, items) + this.names = names + return this def parent (this): - if len(this): return Register(this[:-1]) + if len(this): return Register(this[:-1], this.names) else: return None def next (this): l = list(this) l[-1] += 1 - return Register(l) + return Register(l, this.names) def child (this, index = 0): - return Register(this + (index,)) + return Register(this + (index,), this.names) def __repr__ (this): return 'Register' + tuple.__repr__(this) def __str__ (this): - if Registers.has_key(this): - return Registers[this] + if this.names != None and this.names.has_key(this): + return this.names[this] else: return '%' + '.'.join(map(str, this)) def contained_registers (this): |