wisp-cvs Mailing List for Wisp interpreter (Page 15)
Status: Alpha
Brought to you by:
digg
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(30) |
Sep
(312) |
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(5) |
Feb
(131) |
Mar
(17) |
Apr
(184) |
May
(252) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
From: <di...@us...> - 2003-04-20 18:17:05
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv4776 Modified Files: linkie.py Log Message: minor cleanup Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- linkie.py 20 Apr 2003 18:11:52 -0000 1.29 +++ linkie.py 20 Apr 2003 18:17:02 -0000 1.30 @@ -79,11 +79,15 @@ def _emit_sum (this, size, addends, delta = 0, relative = 0): # If /relative/ is given, so many first components are PC-relative. # /relative/ must be smaller than or equal to len(addends). + # (Note: these must be symbols. PC-relativeness does not work + # for integer literals.) if this._skipped <> 0: raise "Events out of order", this if relative > len(addends): raise 'Too many relatives', (addends, relative) for a in addends: - if relative: s = -size; relative -= 1 + if relative: + s = -size; relative -= 1 + if type(a) != StringType: raise 'relative non-symbol?', a else: s = size if type(a) == IntType: # local reference if this._locals[a] <> None: # backwards |
From: <di...@us...> - 2003-04-20 18:11:55
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv3179 Modified Files: linkie.py Log Message: added the /relative/ parameter to Linkie.emit_byte_sum, Linkie.emit_wyde_sum, and Linkie.emit_tetra_sum Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- linkie.py 19 Apr 2003 09:57:31 -0000 1.28 +++ linkie.py 20 Apr 2003 18:11:52 -0000 1.29 @@ -96,12 +96,12 @@ this.notify_linker(this.memsz(), s, a) else: raise 'Invalid addend', a return delta - def emit_byte_sum (this, addends, delta = 0): - this.emit_byte(this._emit_sum(1, addends, delta)) - def emit_wyde_sum (this, addends, delta = 0): - this.emit_wyde(this._emit_sum(2, addends, delta)) - def emit_tetra_sum (this, addends, delta = 0): - this.emit_tetra(this._emit_sum(4, addends, delta)) + def emit_byte_sum (this, addends, delta = 0, relative = 0): + this.emit_byte(this._emit_sum(1, addends, delta, relative)) + def emit_wyde_sum (this, addends, delta = 0, relative = 0): + this.emit_wyde(this._emit_sum(2, addends, delta, relative)) + def emit_tetra_sum (this, addends, delta = 0, relative = 0): + this.emit_tetra(this._emit_sum(4, addends, delta, relative)) def skip (this, amount): """skip(amount) |
From: <di...@us...> - 2003-04-19 09:57:35
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv29752 Modified Files: linkie.py Log Message: added the /relative/ parameter to Linkie._emit_sum Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- linkie.py 14 Apr 2003 21:59:24 -0000 1.27 +++ linkie.py 19 Apr 2003 09:57:31 -0000 1.28 @@ -76,18 +76,24 @@ def notify_linker (this, offset, type, arg): this._linker_notes.append((offset, type, arg)) - def _emit_sum (this, size, addends, delta = 0): + def _emit_sum (this, size, addends, delta = 0, relative = 0): + # If /relative/ is given, so many first components are PC-relative. + # /relative/ must be smaller than or equal to len(addends). if this._skipped <> 0: raise "Events out of order", this + if relative > len(addends): + raise 'Too many relatives', (addends, relative) for a in addends: + if relative: s = -size; relative -= 1 + else: s = size if type(a) == IntType: # local reference if this._locals[a] <> None: # backwards delta += this._locals[a] else: # forwards - this._unresolved_locals.append((a, size, len(this._binary))) + this._unresolved_locals.append((a, s, len(this._binary))) elif type(a) == StringType: # global reference if not a[0] in '#&!%': raise 'unprefixed symbol being referred to', a - this.notify_linker(this.memsz(), size, a) + this.notify_linker(this.memsz(), s, a) else: raise 'Invalid addend', a return delta def emit_byte_sum (this, addends, delta = 0): |
From: <di...@us...> - 2003-04-17 12:33:41
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv15640 Modified Files: tran.py Log Message: better literal arithmetics Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- tran.py 17 Apr 2003 12:17:14 -0000 1.29 +++ tran.py 17 Apr 2003 12:33:36 -0000 1.30 @@ -59,11 +59,15 @@ class Constant_Sum (Stackable): def __init__ (this, plus = (), minus = (), scalar = 0L): - if isinstance(plus, Symbol_Literal) or plus == Dollar or \ - isinstance(plus, Integer_Literal): plus = plus, - if isinstance(minus, Symbol_Literal) or minus == Dollar or \ - isinstance(minus, Integer_Literal): minus = minus, this.scalar = long(scalar) + if isinstance(plus, Symbol_Literal) or plus == Dollar: + plus = plus, + if isinstance(minus, Symbol_Literal) or minus == Dollar: + minus = minus, + if isinstance(plus, Integer_Literal): + this.scalar += long(plus); plus = () + if isinstance(minus, Integer_Literal): + this.scalar -= long(minus); minus = () this.plus = []; this.minus = [] for item in plus: if isinstance(item, Symbol_Literal) or item == Dollar: @@ -263,8 +267,12 @@ current_register_index = 0 State = state_regs def plus (a, b): + if not isinstance(a, Constant_Sum): a = Constant_Sum(a) + if not isinstance(b, Constant_Sum): b = Constant_Sum(b) Regstack.append(a + b) def minus (a, b): + if not isinstance(a, Constant_Sum): a = Constant_Sum(a) + if not isinstance(b, Constant_Sum): b = Constant_Sum(b) Regstack.append(a - b) def matchers (object): @@ -281,6 +289,9 @@ elif isinstance(object, Constant_Sum): yield 'sum' yield 'const' + elif object == Dollar: + yield '$' + yield 'const' elif isinstance(object, Register): while object <> None: yield Registers[object] @@ -377,33 +388,33 @@ MA_ARGC = 007 MA_PREFIX = 010 Meaning = { - '$': ('simple', Dollar), - '+ int int': ('builtin', plus, 2), - '- int int': ('builtin', minus, 2), - '.bss': ('builtin', dot_bss, 0), - '.data': ('builtin', dot_data, 0), - '.text': ('builtin', dot_text, 0), - ':macro': ('builtin', colon_macro, 0 | MA_PREFIX), - ':regs': ('builtin', colon_regs, 0 | MA_PREFIX), - 'align int': ('builtin', align, 1), - 'any': ('simple', Class_Marker('any')), - 'b, lit': ('builtin', b_comma, 1), - 'const': ('simple', Class_Marker('const')), - 'drop any': ('builtin', drop, 1), - 'dup any': ('builtin', dup, 1), - 'include': ('include',), - 'int': ('simple', Class_Marker('int')), - 'label': ('builtin', label, 0 | MA_PREFIX), - 'lit': ('simple', Class_Marker('lit')), - 'minor reg': ('builtin', minor, 1), - 'ref': ('builtin', ref, 0 | MA_PREFIX), - 'reg': ('simple', Generic_Register), - 'reserve int': ('builtin', reserve, 1), - 'sum': ('simple', Class_Marker('sum')), - 'swap any any': ('builtin', swap, 2), - 'sym': ('simple', Class_Marker('sym')), - 't, lit': ('builtin', t_comma, 1), - 'w, lit': ('builtin', w_comma, 1), + '$': ('simple', Dollar), + '+ const const': ('builtin', plus, 2), + '- const const': ('builtin', minus, 2), + '.bss': ('builtin', dot_bss, 0), + '.data': ('builtin', dot_data, 0), + '.text': ('builtin', dot_text, 0), + ':macro': ('builtin', colon_macro, 0 | MA_PREFIX), + ':regs': ('builtin', colon_regs, 0 | MA_PREFIX), + 'align int': ('builtin', align, 1), + 'any': ('simple', Class_Marker('any')), + 'b, lit': ('builtin', b_comma, 1), + 'const': ('simple', Class_Marker('const')), + 'drop any': ('builtin', drop, 1), + 'dup any': ('builtin', dup, 1), + 'include': ('include',), + 'int': ('simple', Class_Marker('int')), + 'label': ('builtin', label, 0 | MA_PREFIX), + 'lit': ('simple', Class_Marker('lit')), + 'minor reg': ('builtin', minor, 1), + 'ref': ('builtin', ref, 0 | MA_PREFIX), + 'reg': ('simple', Generic_Register), + 'reserve int': ('builtin', reserve, 1), + 'sum': ('simple', Class_Marker('sum')), + 'swap any any': ('builtin', swap, 2), + 'sym': ('simple', Class_Marker('sym')), + 't, lit': ('builtin', t_comma, 1), + 'w, lit': ('builtin', w_comma, 1), } current_recordee = None current_register_family = 0 |
From: <di...@us...> - 2003-04-17 12:17:18
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv10060 Modified Files: tran.py Log Message: better literal arithmetics Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- tran.py 17 Apr 2003 11:50:34 -0000 1.28 +++ tran.py 17 Apr 2003 12:17:14 -0000 1.29 @@ -35,6 +35,14 @@ return str.__new__(cls, s) def __repr__ (this): return 'Symbol_Literal(%r)' % str(this) + def __add__ (this, that): + if not isinstance(this, Constant_Sum): this = Constant_Sum(this) + if not isinstance(that, Constant_Sum): that = Constant_Sum(that) + return this + that + def __sub__ (this, that): + if not isinstance(this, Constant_Sum): this = Constant_Sum(this) + if not isinstance(that, Constant_Sum): that = Constant_Sum(that) + return this - that class Unique: def __init__ (this, name): @@ -51,6 +59,10 @@ class Constant_Sum (Stackable): def __init__ (this, plus = (), minus = (), scalar = 0L): + if isinstance(plus, Symbol_Literal) or plus == Dollar or \ + isinstance(plus, Integer_Literal): plus = plus, + if isinstance(minus, Symbol_Literal) or minus == Dollar or \ + isinstance(minus, Integer_Literal): minus = minus, this.scalar = long(scalar) this.plus = []; this.minus = [] for item in plus: @@ -71,13 +83,13 @@ that = Constant_Sum(plus = [that]) return Constant_Sum(plus = this.plus + that.plus, minus = this.minus + that.minus, - scalar = this.scalar + that.scalar) + scalar = this.scalar + that.scalar).simplify() def __sub__ (this, that): if isinstance(that, Symbol_Literal) or that == Dollar: that = Constant_Sum(plus = [that]) return Constant_Sum(plus = this.plus + that.minus, minus = this.minus + that.plus, - scalar = this.scalar - that.scalar) + scalar = this.scalar - that.scalar).simplify() def __repr__ (this): arg = [] if this.plus: arg.append('plus = ' + `this.plus`) @@ -93,6 +105,12 @@ if res[0] == ' ': res = res[1:] if res[:2] == '+ ': res = res[2:] return '(' + res + ')' + def simplify (this): + if len(this.plus) == 0 and len(this.minus) == 0: + return Integer_Literal(this.scalar) + if len(this.plus) == 1 and len(this.minus) == 0 and this.scalar == 0: + return this.plus[0] + else: return this class Lexer (shlex): def __init__ (this, filename): |
From: <di...@us...> - 2003-04-17 11:50:38
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv1029 Modified Files: mswhello.tran tran.py Log Message: added the |$| word Index: mswhello.tran =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/mswhello.tran,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mswhello.tran 16 Apr 2003 08:02:48 -0000 1.3 +++ mswhello.tran 17 Apr 2003 11:50:34 -0000 1.4 @@ -10,7 +10,7 @@ include ia32 -lit :macro $call #xe8 b, $- 4 - t, ; +lit :macro $call #xe8 b, $ - 4 - t, ; \ main entry point Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- tran.py 17 Apr 2003 11:45:49 -0000 1.27 +++ tran.py 17 Apr 2003 11:50:34 -0000 1.28 @@ -359,6 +359,7 @@ MA_ARGC = 007 MA_PREFIX = 010 Meaning = { + '$': ('simple', Dollar), '+ int int': ('builtin', plus, 2), '- int int': ('builtin', minus, 2), '.bss': ('builtin', dot_bss, 0), |
From: <di...@us...> - 2003-04-17 11:45:53
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv31904 Modified Files: tran.py Log Message: renamed ClassMarker to Class_Marker Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- tran.py 17 Apr 2003 11:37:14 -0000 1.26 +++ tran.py 17 Apr 2003 11:45:49 -0000 1.27 @@ -151,7 +151,7 @@ def __repr__ (this): return 'Register' + tuple.__repr__(this) -class ClassMarker: +class Class_Marker: def __init__ (this, id): this.id = id @@ -250,7 +250,7 @@ Regstack.append(a - b) def matchers (object): - if isinstance(object, ClassMarker): + if isinstance(object, Class_Marker): yield object.id elif isinstance(object, Integer_Literal): yield 'int' @@ -367,22 +367,22 @@ ':macro': ('builtin', colon_macro, 0 | MA_PREFIX), ':regs': ('builtin', colon_regs, 0 | MA_PREFIX), 'align int': ('builtin', align, 1), - 'any': ('simple', ClassMarker('any')), + 'any': ('simple', Class_Marker('any')), 'b, lit': ('builtin', b_comma, 1), - 'const': ('simple', ClassMarker('const')), + 'const': ('simple', Class_Marker('const')), 'drop any': ('builtin', drop, 1), 'dup any': ('builtin', dup, 1), 'include': ('include',), - 'int': ('simple', ClassMarker('int')), + 'int': ('simple', Class_Marker('int')), 'label': ('builtin', label, 0 | MA_PREFIX), - 'lit': ('simple', ClassMarker('lit')), + 'lit': ('simple', Class_Marker('lit')), 'minor reg': ('builtin', minor, 1), 'ref': ('builtin', ref, 0 | MA_PREFIX), 'reg': ('simple', Generic_Register), 'reserve int': ('builtin', reserve, 1), - 'sum': ('simple', ClassMarker('sum')), + 'sum': ('simple', Class_Marker('sum')), 'swap any any': ('builtin', swap, 2), - 'sym': ('simple', ClassMarker('sym')), + 'sym': ('simple', Class_Marker('sym')), 't, lit': ('builtin', t_comma, 1), 'w, lit': ('builtin', w_comma, 1), } |
From: <di...@us...> - 2003-04-17 11:37:20
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv29104 Modified Files: tran.py Log Message: added the |const| class marker Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- tran.py 17 Apr 2003 11:16:09 -0000 1.25 +++ tran.py 17 Apr 2003 11:37:14 -0000 1.26 @@ -255,9 +255,14 @@ elif isinstance(object, Integer_Literal): yield 'int' yield 'lit' + yield 'const' elif isinstance(object, Symbol_Literal): yield 'sym' yield 'lit' + yield 'const' + elif isinstance(object, Constant_Sum): + yield 'sum' + yield 'const' elif isinstance(object, Register): while object <> None: yield Registers[object] @@ -364,6 +369,7 @@ 'align int': ('builtin', align, 1), 'any': ('simple', ClassMarker('any')), 'b, lit': ('builtin', b_comma, 1), + 'const': ('simple', ClassMarker('const')), 'drop any': ('builtin', drop, 1), 'dup any': ('builtin', dup, 1), 'include': ('include',), @@ -375,8 +381,8 @@ 'reg': ('simple', Generic_Register), 'reserve int': ('builtin', reserve, 1), 'sum': ('simple', ClassMarker('sum')), - 'sym': ('simple', ClassMarker('sym')), 'swap any any': ('builtin', swap, 2), + 'sym': ('simple', ClassMarker('sym')), 't, lit': ('builtin', t_comma, 1), 'w, lit': ('builtin', w_comma, 1), } |
From: <di...@us...> - 2003-04-17 11:16:13
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv21595 Modified Files: tran.py Log Message: wrote the Constant_Sum class Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- tran.py 16 Apr 2003 20:57:07 -0000 1.24 +++ tran.py 17 Apr 2003 11:16:09 -0000 1.25 @@ -49,6 +49,51 @@ Semicolon = Unique_Token(';') Dollar = Unique_Stackable('$') +class Constant_Sum (Stackable): + def __init__ (this, plus = (), minus = (), scalar = 0L): + this.scalar = long(scalar) + this.plus = []; this.minus = [] + for item in plus: + if isinstance(item, Symbol_Literal) or item == Dollar: + this.plus.append(item) + else: raise 'bad addee', item + for item in minus: + if isinstance(item, Symbol_Literal) or item == Dollar: + try: + i = this.plus.index(item) + this.plus.pop(i) + except ValueError: + this.minus.append(item) + else: raise 'bad subtractee', item + this.plus = tuple(this.plus); this.minus = tuple(this.minus) + def __add__ (this, that): + if isinstance(that, Symbol_Literal) or that == Dollar: + that = Constant_Sum(plus = [that]) + return Constant_Sum(plus = this.plus + that.plus, + minus = this.minus + that.minus, + scalar = this.scalar + that.scalar) + def __sub__ (this, that): + if isinstance(that, Symbol_Literal) or that == Dollar: + that = Constant_Sum(plus = [that]) + return Constant_Sum(plus = this.plus + that.minus, + minus = this.minus + that.plus, + scalar = this.scalar - that.scalar) + def __repr__ (this): + arg = [] + if this.plus: arg.append('plus = ' + `this.plus`) + if this.minus: arg.append('minus = ' + `this.minus`) + if this.scalar: arg.append('scalar = ' + `this.scalar`) + return 'Constant_Sum(%s)' % ', '.join(arg) + def __str__ (this): + res = '' + for item in this.plus: res += ' + ' + str(item) + for item in this.minus: res += ' - ' + str(item) + if this.scalar > 0: res += ' + ' + str(this.scalar) + else: res += ' - ' + str(-this.scalar) + if res[0] == ' ': res = res[1:] + if res[:2] == '+ ': res = res[2:] + return '(' + res + ')' + class Lexer (shlex): def __init__ (this, filename): shlex.__init__(this, instream = open(filename, 'r'), infile = filename) |
From: <di...@us...> - 2003-04-16 20:57:10
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv27272 Modified Files: tran.py Log Message: renamed UniqueToken and UniqueStackable to Unique_Token and Unique_Stackable, respectively Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- tran.py 16 Apr 2003 20:54:41 -0000 1.23 +++ tran.py 16 Apr 2003 20:57:07 -0000 1.24 @@ -43,11 +43,11 @@ return 'Unique(%r)' % this.name def __str__ (this): return this.name -class UniqueToken (Unique, Token): pass -class UniqueStackable (Unique, Stackable): pass +class Unique_Token (Unique, Token): pass +class Unique_Stackable (Unique, Stackable): pass -Semicolon = UniqueToken(';') -Dollar = UniqueStackable('$') +Semicolon = Unique_Token(';') +Dollar = Unique_Stackable('$') class Lexer (shlex): def __init__ (this, filename): |
From: <di...@us...> - 2003-04-16 20:54:44
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv26331 Modified Files: tran.py Log Message: added the Dollar unique stackable item Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- tran.py 16 Apr 2003 20:49:51 -0000 1.22 +++ tran.py 16 Apr 2003 20:54:41 -0000 1.23 @@ -44,8 +44,10 @@ def __str__ (this): return this.name class UniqueToken (Unique, Token): pass +class UniqueStackable (Unique, Stackable): pass Semicolon = UniqueToken(';') +Dollar = UniqueStackable('$') class Lexer (shlex): def __init__ (this, filename): |
From: <di...@us...> - 2003-04-16 20:49:56
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv24538 Modified Files: tran.py Log Message: added the Symbol_Literal class Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- tran.py 16 Apr 2003 20:22:22 -0000 1.21 +++ tran.py 16 Apr 2003 20:49:51 -0000 1.22 @@ -13,7 +13,6 @@ from getopt import getopt from linkie import Linkie from shlex import shlex -from types import * import elf import string import sys @@ -31,6 +30,11 @@ return Integer_Literal(long(this) - long(that)) def __repr__ (this): return 'Integer_Literal(%i)' % long(this) +class Symbol_Literal (str, Stackable): + def __new__ (cls, s): + return str.__new__(cls, s) + def __repr__ (this): + return 'Symbol_Literal(%r)' % str(this) class Unique: def __init__ (this, name): @@ -142,15 +146,15 @@ def b_comma (n): if isinstance(n, Integer_Literal): cursect.emit_byte(long(n) % 0x100) - elif type(n) == StringType: cursect.emit_byte_sum([n]) + elif isinstance(n, Symbol_Literal): cursect.emit_byte_sum([str(n)]) else: raise 'Literal expected', n def w_comma (n): if isinstance(n, Integer_Literal): cursect.emit_wyde(long(n) % 0x10000) - elif type(n) == StringType: cursect.emit_wyde_sum([n]) + elif isinstance(n, Symbol_Literal): cursect.emit_wyde_sum([str(n)]) else: raise 'Literal expected', n def t_comma (n): if isinstance(n, Integer_Literal): cursect.emit_tetra(long(n) % 0x100000000L) - elif type(n) == StringType: cursect.emit_tetra_sum([n]) + elif isinstance(n, Symbol_Literal): cursect.emit_tetra_sum([str(n)]) else: raise 'Literal expected', n def label (name): cursect.place_symbol('&' + name) @@ -164,7 +168,7 @@ global cursect cursect = Text def ref (name): - Regstack.append('&' + name) + Regstack.append(Symbol_Literal('&' + name)) def drop (x): pass def align (n): cursect.align(n) def reserve (n): cursect.skip(n) @@ -204,7 +208,7 @@ elif isinstance(object, Integer_Literal): yield 'int' yield 'lit' - elif type(object) == StringType: + elif isinstance(object, Symbol_Literal): yield 'sym' yield 'lit' elif isinstance(object, Register): @@ -236,9 +240,9 @@ global Regstack if isinstance(tok, Integer_Literal): Regstack.append(tok) - elif type(tok) == StringType and tok[:2] == '#/' and len(tok) == 3: + elif isinstance(tok, str) and tok[:2] == '#/' and len(tok) == 3: Regstack.append(Integer_Literal(ord(tok[2]))) - else: + elif isinstance(tok, str): root = tok mg = match_generator(root) try: @@ -259,7 +263,7 @@ arg = [] if m[2] & MA_PREFIX: tok = prep.get_token() - if type(tok) <> StringType: raise 'word expected' + if not isinstance(tok, str): raise 'word expected', tok arg.append(tok) apply(m[1], arg) elif mtype == 'macro': @@ -270,6 +274,7 @@ fn = prep.get_token() + '.tran' prep.push_file(fn) else: raise 'Unknown meaning type in', `Meaning[tok]` + else: raise 'bad token', tok def state_record (tok): global State, current_recordee if tok == Semicolon: |
From: <di...@us...> - 2003-04-16 20:22:26
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv13567 Modified Files: tran.py Log Message: added the Integer_Literal class Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- tran.py 16 Apr 2003 20:06:36 -0000 1.20 +++ tran.py 16 Apr 2003 20:22:22 -0000 1.21 @@ -22,6 +22,15 @@ class Stackable: def contained_registers (this): return () +class Integer_Literal (long, Stackable, Token): + def __new__ (cls, i): + return long.__new__(cls, i) + def __add__ (this, that): + return Integer_Literal(long(this) + long(that)) + def __sub__ (this, that): + return Integer_Literal(long(this) - long(that)) + def __repr__ (this): + return 'Integer_Literal(%i)' % long(this) class Unique: def __init__ (this, name): @@ -43,10 +52,10 @@ def get_token (this): tok = shlex.get_token(this) if tok == '': tok = None - elif tok[:2] == '#o': tok = string.atol(tok[2:], 8) - elif tok[:2] == '#x': tok = string.atol(tok[2:], 16) + elif tok[:2] == '#o': tok = Integer_Literal(string.atol(tok[2:], 8)) + elif tok[:2] == '#x': tok = Integer_Literal(string.atol(tok[2:], 16)) else: - try: tok = string.atol(tok, 10) + try: tok = Integer_Literal(string.atol(tok, 10)) except: pass if tok == ';': return Semicolon else: return tok @@ -98,15 +107,15 @@ class Sum (list): def __init__ (this, addends, scalar = 0, dollars = 0): list.__init__(this, []) - this.scalar = scalar - this.dollars = dollars + this.scalar = long(scalar) + this.dollars = long(dollars) for a in addends: if isinstance(a, Sum): this.extend(a) this.scalar += a.scalar this.dollars += a.dollars - elif type(a) == LongType or type(a) == IntType: - this.scalar += a + elif isinstance(a, Integer_Literal) or isinstance(a, IntType): + this.scalar += long(a) else: this.append(a) def __add__ (this, that): return Sum(this, that) @@ -132,15 +141,15 @@ return res def b_comma (n): - if type(n) == LongType: cursect.emit_byte(n % 0x100) + if isinstance(n, Integer_Literal): cursect.emit_byte(long(n) % 0x100) elif type(n) == StringType: cursect.emit_byte_sum([n]) else: raise 'Literal expected', n def w_comma (n): - if type(n) == LongType: cursect.emit_wyde(n % 0x10000) + if isinstance(n, Integer_Literal): cursect.emit_wyde(long(n) % 0x10000) elif type(n) == StringType: cursect.emit_wyde_sum([n]) else: raise 'Literal expected', n def t_comma (n): - if type(n) == LongType: cursect.emit_tetra(n % 0x100000000L) + if isinstance(n, Integer_Literal): cursect.emit_tetra(long(n) % 0x100000000L) elif type(n) == StringType: cursect.emit_tetra_sum([n]) else: raise 'Literal expected', n def label (name): @@ -160,7 +169,7 @@ def align (n): cursect.align(n) def reserve (n): cursect.skip(n) def minor (reg): - Regstack.append(long(reg[-1])) + Regstack.append(Integer_Literal(reg[-1])) def swap (x, y): Regstack.append(y); Regstack.append(x) def dup (x): @@ -192,7 +201,7 @@ def matchers (object): if isinstance(object, ClassMarker): yield object.id - elif type(object) == LongType: + elif isinstance(object, Integer_Literal): yield 'int' yield 'lit' elif type(object) == StringType: @@ -225,10 +234,10 @@ def state_outer (tok): global Regstack - if type(tok) == LongType: + if isinstance(tok, Integer_Literal): Regstack.append(tok) elif type(tok) == StringType and tok[:2] == '#/' and len(tok) == 3: - Regstack.append(long(ord(tok[2]))) + Regstack.append(Integer_Literal(ord(tok[2]))) else: root = tok mg = match_generator(root) |
From: <di...@us...> - 2003-04-16 20:06:40
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv6769 Modified Files: tran.py Log Message: wrote trivial Stackable.contained_registers Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- tran.py 16 Apr 2003 13:32:07 -0000 1.19 +++ tran.py 16 Apr 2003 20:06:36 -0000 1.20 @@ -19,7 +19,9 @@ import sys class Token: pass -class Stackable: pass +class Stackable: + def contained_registers (this): + return () class Unique: def __init__ (this, name): |
From: <di...@us...> - 2003-04-16 13:32:13
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv9875 Modified Files: tran.py Log Message: treat semicolon as a special token class instead of a word Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- tran.py 16 Apr 2003 13:19:06 -0000 1.18 +++ tran.py 16 Apr 2003 13:32:07 -0000 1.19 @@ -30,6 +30,8 @@ return this.name class UniqueToken (Unique, Token): pass +Semicolon = UniqueToken(';') + class Lexer (shlex): def __init__ (this, filename): shlex.__init__(this, instream = open(filename, 'r'), infile = filename) @@ -44,7 +46,8 @@ else: try: tok = string.atol(tok, 10) except: pass - return tok + if tok == ';': return Semicolon + else: return tok def push_file (this, filename): this.push_source(open(filename, 'r'), filename) @@ -258,14 +261,14 @@ else: raise 'Unknown meaning type in', `Meaning[tok]` def state_record (tok): global State, current_recordee - if tok == ';': + if tok == Semicolon: State = state_outer current_recordee = None else: current_recordee.append(tok) def state_regs (tok): global State, current_register_family, current_register_index - if tok != ';': + if tok != Semicolon: if Meaning.has_key(tok): raise 'duplicate declaration', tok r = Register(current_register_family, current_register_index) Meaning[tok] = 'simple', r |
From: <di...@us...> - 2003-04-16 13:19:13
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv3560 Modified Files: tran.py Log Message: wrote the UniqueToken class Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- tran.py 16 Apr 2003 13:15:38 -0000 1.17 +++ tran.py 16 Apr 2003 13:19:06 -0000 1.18 @@ -28,6 +28,7 @@ return 'Unique(%r)' % this.name def __str__ (this): return this.name +class UniqueToken (Unique, Token): pass class Lexer (shlex): def __init__ (this, filename): |
From: <di...@us...> - 2003-04-16 13:15:43
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv2009 Modified Files: tran.py Log Message: wrote the Token, Stackable, and Unique classes Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- tran.py 16 Apr 2003 13:01:33 -0000 1.16 +++ tran.py 16 Apr 2003 13:15:38 -0000 1.17 @@ -18,6 +18,17 @@ import string import sys +class Token: pass +class Stackable: pass + +class Unique: + def __init__ (this, name): + this.name = name + def __repr__ (this): + return 'Unique(%r)' % this.name + def __str__ (this): + return this.name + class Lexer (shlex): def __init__ (this, filename): shlex.__init__(this, instream = open(filename, 'r'), infile = filename) |
From: <di...@us...> - 2003-04-16 13:01:41
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv26686 Modified Files: tran.py Log Message: extracted the Preprocessor class Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- tran.py 16 Apr 2003 12:04:20 -0000 1.15 +++ tran.py 16 Apr 2003 13:01:33 -0000 1.16 @@ -33,9 +33,33 @@ try: tok = string.atol(tok, 10) except: pass return tok - def push (this, filename): + def push_file (this, filename): this.push_source(open(filename, 'r'), filename) +class Macro_Cursor: + def __init__ (this, sequence): + this.sequence = sequence + this.current = 0 + def get_next (this): + if this.current >= len(this.sequence): return None + datum = this.sequence[this.current] + this.current += 1 + return datum + +class Preprocessor (Lexer): + def __init__ (this, filename): + Lexer.__init__(this, filename) + this.macros = [] + def push_macro (this, l): + this.macros.append(Macro_Cursor(l)) + def get_token (this): + tok = None + while this.macros and tok == None: + tok = this.macros[-1].get_next() + if tok == None: this.macros.pop() + if tok <> None: return tok + else: return Lexer.get_token(this) + class Register (tuple): def __new__ (cls, *args): return tuple.__new__(cls, args) @@ -208,17 +232,17 @@ else: arg = [] if m[2] & MA_PREFIX: - tok = get_token() + tok = prep.get_token() if type(tok) <> StringType: raise 'word expected' arg.append(tok) apply(m[1], arg) elif mtype == 'macro': - Macrostack.append([0, m[1]]) + prep.push_macro(m[1]) elif mtype == 'simple': Regstack.append(m[1]) elif mtype == 'include': - fn = get_token() + '.tran' - lex.push(fn) + fn = prep.get_token() + '.tran' + prep.push_file(fn) else: raise 'Unknown meaning type in', `Meaning[tok]` def state_record (tok): global State, current_recordee @@ -281,31 +305,20 @@ current_recordee = None current_register_family = 0 State = state_outer -Macrostack = [] Registers = {Generic_Register: 'reg'} # for reverse translation -def get_token (): - if Macrostack: - tok = Macrostack[-1][1][Macrostack[-1][0]] - Macrostack[-1][0] += 1 - if Macrostack[-1][0] >= len(Macrostack[-1][1]): - Macrostack.pop() - return tok - else: - return lex.get_token() - def mainloop (): - tok = get_token() + tok = prep.get_token() while tok <> None: State(tok) - tok = get_token() + tok = prep.get_token() def main (): - global lex + global prep opts, args = getopt(sys.argv[1:], 'o:', ['output=']) if len(args) != 1: raise 'Invalid argument count -- must be 1', args - lex = Lexer(args[0]) + prep = Preprocessor(args[0]) output_name = 'a.out' for opt, arg in opts: if opt in ('-o', '--output'): output_name = arg |
From: <di...@us...> - 2003-04-16 12:04:24
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv31469 Modified Files: tran.py Log Message: wrote Lexer.push Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- tran.py 16 Apr 2003 11:58:47 -0000 1.14 +++ tran.py 16 Apr 2003 12:04:20 -0000 1.15 @@ -33,6 +33,8 @@ try: tok = string.atol(tok, 10) except: pass return tok + def push (this, filename): + this.push_source(open(filename, 'r'), filename) class Register (tuple): def __new__ (cls, *args): @@ -216,7 +218,7 @@ Regstack.append(m[1]) elif mtype == 'include': fn = get_token() + '.tran' - lex.push_source(open(fn), fn) + lex.push(fn) else: raise 'Unknown meaning type in', `Meaning[tok]` def state_record (tok): global State, current_recordee |
From: <di...@us...> - 2003-04-16 11:58:51
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv29009 Modified Files: tran.py Log Message: cleaned up Lexer.__init__ interface Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- tran.py 16 Apr 2003 08:04:12 -0000 1.13 +++ tran.py 16 Apr 2003 11:58:47 -0000 1.14 @@ -19,8 +19,8 @@ import sys class Lexer (shlex): - def __init__ (this, instream = None, infile = None): - shlex.__init__(this, instream = instream, infile = infile) + def __init__ (this, filename): + shlex.__init__(this, instream = open(filename, 'r'), infile = filename) this.commenters = '\\' this.quotes = '"' this.wordchars += '!#$%*+,-./:;<=>?@' @@ -303,7 +303,7 @@ opts, args = getopt(sys.argv[1:], 'o:', ['output=']) if len(args) != 1: raise 'Invalid argument count -- must be 1', args - lex = Lexer(instream = open(args[0], 'r'), infile = args[0]) + lex = Lexer(args[0]) output_name = 'a.out' for opt, arg in opts: if opt in ('-o', '--output'): output_name = arg |
From: <di...@us...> - 2003-04-16 09:00:33
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv12363 Modified Files: make-pe-exe.py Log Message: trimmed make-pe-exe.py Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- make-pe-exe.py 14 Apr 2003 21:59:25 -0000 1.5 +++ make-pe-exe.py 16 Apr 2003 09:00:25 -0000 1.6 @@ -112,7 +112,7 @@ def make_pe_aout_header (): h = Linkie('<') h.align(4) - # #aout/magic = 0x10B + # #aout/magic = 0x10B h.emit_wyde_sum(['#aout/magic']) h.emit_byte_sum(['#aout/linker-version-major']) h.emit_byte_sum(['#aout/linker-version-minor']) |
From: <di...@us...> - 2003-04-16 08:04:17
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv21858 Modified Files: tran.py Log Message: added the |sym| word Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- tran.py 16 Apr 2003 07:58:58 -0000 1.12 +++ tran.py 16 Apr 2003 08:04:12 -0000 1.13 @@ -271,6 +271,7 @@ 'reg': ('simple', Generic_Register), 'reserve int': ('builtin', reserve, 1), 'sum': ('simple', ClassMarker('sum')), + 'sym': ('simple', ClassMarker('sym')), 'swap any any': ('builtin', swap, 2), 't, lit': ('builtin', t_comma, 1), 'w, lit': ('builtin', w_comma, 1), |
From: <di...@us...> - 2003-04-16 08:02:53
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv21282 Modified Files: ia32.tran mswhello.tran Log Message: moved |$call lit| from mswhello.tran to ia32.tran Index: ia32.tran =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/ia32.tran,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ia32.tran 16 Apr 2003 07:58:58 -0000 1.1 +++ ia32.tran 16 Apr 2003 08:02:47 -0000 1.2 @@ -13,4 +13,4 @@ lit :macro $int #xCD b, b, ; reg32 lit :macro $mov swap minor #o270 + b, t, ; - +lit :macro $push #x68 b, t, ; Index: mswhello.tran =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/mswhello.tran,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mswhello.tran 16 Apr 2003 07:58:58 -0000 1.2 +++ mswhello.tran 16 Apr 2003 08:02:48 -0000 1.3 @@ -10,7 +10,6 @@ include ia32 -lit :macro $push #x68 b, t, ; lit :macro $call #xe8 b, $- 4 - t, ; \ main entry point |
From: <di...@us...> - 2003-04-16 07:59:04
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv19977 Modified Files: hello.tran mswhello.tran tran.py Added Files: ia32.tran Log Message: extracted ia32.tran from hello.tran --- NEW FILE: ia32.tran --- \\\\ ia32.tran - 32-bit Intel architecture \ \ Copyleft © 2003 by Andres Soolo (di...@us...) \ This file is licensed under the GNU GPL v2. If you \ don't know what that means, please do read the GPL. \ \\\\ @(#) $Id: ia32.tran,v 1.1 2003/04/16 07:58:58 digg Exp $ \ registers :regs reg32 %eax %ecx %edx %ebx %esp %ebp %esi %edi ; :regs reg16 %ax %cx %dx %bx %sp %bp %si %di ; :regs reg8 %al %cl %dl %bl %ah %ch %dh %bh ; lit :macro $int #xCD b, b, ; reg32 lit :macro $mov swap minor #o270 + b, t, ; Index: hello.tran =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/hello.tran,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- hello.tran 12 Apr 2003 11:17:57 -0000 1.1 +++ hello.tran 16 Apr 2003 07:58:57 -0000 1.2 @@ -8,13 +8,7 @@ \ This file is intended to be processed using tran.py -\ ia32 registers -:regs reg32 %eax %ecx %edx %ebx %esp %ebp %esi %edi ; -:regs reg16 %ax %cx %dx %bx %sp %bp %si %di ; -:regs reg8 %al %cl %dl %bl %ah %ch %dh %bh ; - -lit :macro $int #xCD b, b, ; -reg32 lit :macro $mov swap minor #o270 + b, t, ; +include ia32 \ main entry point Index: mswhello.tran =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/mswhello.tran,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- mswhello.tran 15 Apr 2003 21:12:15 -0000 1.1 +++ mswhello.tran 16 Apr 2003 07:58:58 -0000 1.2 @@ -8,14 +8,10 @@ \ NOTE that mswhello.tran is not currently translatable -\ ia32 registers -:regs reg32 %eax %ecx %edx %ebx %esp %ebp %esi %edi ; -:regs reg16 %ax %cx %dx %bx %sp %bp %si %di ; -:regs reg8 %al %cl %dl %bl %ah %ch %dh %bh ; +include ia32 -lit :macro $int #xCD b, b, ; lit :macro $push #x68 b, t, ; -reg32 lit :macro $mov swap minor #o270 + b, t, ; +lit :macro $call #xe8 b, $- 4 - t, ; \ main entry point Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- tran.py 15 Apr 2003 22:01:19 -0000 1.11 +++ tran.py 16 Apr 2003 07:58:58 -0000 1.12 @@ -214,6 +214,9 @@ Macrostack.append([0, m[1]]) elif mtype == 'simple': Regstack.append(m[1]) + elif mtype == 'include': + fn = get_token() + '.tran' + lex.push_source(open(fn), fn) else: raise 'Unknown meaning type in', `Meaning[tok]` def state_record (tok): global State, current_recordee @@ -259,6 +262,7 @@ 'b, lit': ('builtin', b_comma, 1), 'drop any': ('builtin', drop, 1), 'dup any': ('builtin', dup, 1), + 'include': ('include',), 'int': ('simple', ClassMarker('int')), 'label': ('builtin', label, 0 | MA_PREFIX), 'lit': ('simple', ClassMarker('lit')), |
From: <di...@us...> - 2003-04-15 22:01:22
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv27826 Modified Files: tran.py Log Message: added the Sum class Index: tran.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/tran.py,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- tran.py 15 Apr 2003 21:27:32 -0000 1.10 +++ tran.py 15 Apr 2003 22:01:19 -0000 1.11 @@ -52,12 +52,52 @@ def __init__ (this, id): this.id = id +class Sum (list): + def __init__ (this, addends, scalar = 0, dollars = 0): + list.__init__(this, []) + this.scalar = scalar + this.dollars = dollars + for a in addends: + if isinstance(a, Sum): + this.extend(a) + this.scalar += a.scalar + this.dollars += a.dollars + elif type(a) == LongType or type(a) == IntType: + this.scalar += a + else: this.append(a) + def __add__ (this, that): + return Sum(this, that) + def __repr__ (this): + res = `list(this)` + if this.scalar: res += ', scalar = ' + `this.scalar` + if this.dollars: res += ', dollars = ' + `this.dollars` + return 'Sum(' + res + ')' + def __str__ (this): + res = ' + '.join(map(str, this)) + if this.dollars: + if res <> '': res += ' ' + res += '- ' + if this.dollars <> 1: res += `this.dollars` + res += '$' + if this.scalar: + if this.scalar > 0: + if res <> '': res += ' + ' + res += `this.scalar` + else: + if res <> '': res += ' ' + res += '- ' + `-this.scalar` + return res + def b_comma (n): - if type(n) == LongType: cursect.emit_byte(n) + if type(n) == LongType: cursect.emit_byte(n % 0x100) elif type(n) == StringType: cursect.emit_byte_sum([n]) else: raise 'Literal expected', n +def w_comma (n): + if type(n) == LongType: cursect.emit_wyde(n % 0x10000) + elif type(n) == StringType: cursect.emit_wyde_sum([n]) + else: raise 'Literal expected', n def t_comma (n): - if type(n) == LongType: cursect.emit_tetra(n) + if type(n) == LongType: cursect.emit_tetra(n % 0x100000000L) elif type(n) == StringType: cursect.emit_tetra_sum([n]) else: raise 'Literal expected', n def label (name): @@ -215,20 +255,21 @@ ':macro': ('builtin', colon_macro, 0 | MA_PREFIX), ':regs': ('builtin', colon_regs, 0 | MA_PREFIX), 'align int': ('builtin', align, 1), - 'reserve int': ('builtin', reserve, 1), 'any': ('simple', ClassMarker('any')), 'b, lit': ('builtin', b_comma, 1), 'drop any': ('builtin', drop, 1), + 'dup any': ('builtin', dup, 1), 'int': ('simple', ClassMarker('int')), 'label': ('builtin', label, 0 | MA_PREFIX), 'lit': ('simple', ClassMarker('lit')), 'minor reg': ('builtin', minor, 1), 'ref': ('builtin', ref, 0 | MA_PREFIX), 'reg': ('simple', Generic_Register), + 'reserve int': ('builtin', reserve, 1), 'sum': ('simple', ClassMarker('sum')), 'swap any any': ('builtin', swap, 2), - 'dup any': ('builtin', dup, 1), 't, lit': ('builtin', t_comma, 1), + 'w, lit': ('builtin', w_comma, 1), } current_recordee = None current_register_family = 0 |