wisp-cvs Mailing List for Wisp interpreter (Page 12)
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-27 12:56:20
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv17208 Modified Files: elf.py Log Message: use cleaner syntax in elf.py Index: elf.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/elf.py,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- elf.py 27 Apr 2003 12:54:15 -0000 1.39 +++ elf.py 27 Apr 2003 12:56:17 -0000 1.40 @@ -347,10 +347,10 @@ h.emit_tetra_sum(['!elf/proghdr']) h.emit_tetra_sum(['!elf/secthdr']) h.emit_tetra_sum(['#elf/flags']) - h.emit_wyde(0x34) # e_ehsize - h.emit_wyde(32) # e_phentsize + h[::2] = 0x34 # e_ehsize + h[::2] = 32 # e_phentsize h.emit_wyde_sum(['#elf/phnum']) - h.emit_wyde(40) # e_shentsize + h[::2] = 40 # e_shentsize h.emit_wyde_sum(['#elf/shnum']) h.emit_wyde_sum(['#elf/shstrndx']) return h @@ -426,7 +426,7 @@ this.emit_tetra(0) # st_size this[::1] = STB.GLOBAL << 4 | STT.NOTYPE this[::1] = 0 # st_other; reserved - this.emit_wyde(section) + this[::2] = section this._index += 1 return this._index |
From: <di...@us...> - 2003-04-27 12:54:18
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv15956 Modified Files: elf.py Log Message: use cleaner syntax in elf.py Index: elf.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/elf.py,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- elf.py 21 Apr 2003 11:35:56 -0000 1.38 +++ elf.py 27 Apr 2003 12:54:15 -0000 1.39 @@ -327,14 +327,14 @@ h = Linkie(byte_order) h.align(4) h.emit_string('\x7F' + 'ELF') # magic - h.emit_byte(ELFCLASS.TETRA) + h[::1] = ELFCLASS.TETRA if byte_order == '<': - h.emit_byte(ELFDATA.TWOLSB) + h[::1] = ELFDATA.TWOLSB elif byte_order == '>': - h.emit_byte(ELFDATA.TWOMSB) + h[::1] = ELFDATA.TWOMSB else: raise 'Invalid byte order', byte_order - h.emit_byte(EV.CURRENT) + h[::1] = EV.CURRENT h.emit_string('\0' * 9) h.emit_wyde_sum(['#elf/type']) h.emit_wyde_sum(['#elf/machine']) @@ -395,7 +395,7 @@ def __init__ (this, byte_order): Linkie.__init__(this, byte_order) this._emitted_symbols = {} - this.emit_byte(0) + this[::1] = 0 # Returns offset of the string added. # Avoids introducing duplicate entries. def emit_entry (this, s, entry_label = None): @@ -405,7 +405,7 @@ if entry_label <> None: this.place_symbol(entry_label, ofs) this._emitted_symbols[s] = ofs this.emit_string(s) - this.emit_byte(0) + this[::1] = 0 return ofs class ELF32_symtab (Linkie): @@ -424,8 +424,8 @@ if value == None: this.emit_tetra_sum([pname]) else: this.emit_tetra(value) this.emit_tetra(0) # st_size - this.emit_byte(STB.GLOBAL << 4 | STT.NOTYPE) - this.emit_byte(0) # st_other; reserved + this[::1] = STB.GLOBAL << 4 | STT.NOTYPE + this[::1] = 0 # st_other; reserved this.emit_wyde(section) this._index += 1 return this._index |
From: <di...@us...> - 2003-04-27 12:50:23
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv13772 Modified Files: makehello.py Log Message: use cleaner syntax in makehello.py Index: makehello.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/makehello.py,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- makehello.py 14 Apr 2003 22:19:55 -0000 1.25 +++ makehello.py 27 Apr 2003 12:50:20 -0000 1.26 @@ -11,18 +11,18 @@ code = Linkie('<') # ia32 code.place_symbol('&_start') -code.emit_byte(0xBA); code.emit_tetra(14) # mov edx, 14 -code.emit_byte(0xB9); code.emit_tetra_sum(['&message']) # mov ecx, message -code.emit_byte(0xBB); code.emit_tetra(1) # mov ebx, 1 -code.emit_byte(0xB8); code.emit_tetra(4) # mov eax, 4 -code.emit_byte(0xCD); code.emit_byte(0x80) # int 0x80 -code.emit_byte(0xBB); code.emit_tetra(0) # mov ebx, 0 -code.emit_byte(0xB8); code.emit_tetra(1) # mov eax, 1 -code.emit_byte(0xCD); code.emit_byte(0x80) # int 0x80 +code[::1] = 0xBA; code[::4] = 14 # mov edx, 14 +code[::1] = 0xB9; code[::4] = '&message' # mov ecx, message +code[::1] = 0xBB; code[::4] = 1 # mov ebx, 1 +code[::1] = 0xB8; code[::4] = 4 # mov eax, 4 +code[::1] = 0xCD, 0x80 # int 0x80 +code[::1] = 0xBB; code[::4] = 0 # mov ebx, 0 +code[::1] = 0xB8; code[::4] = 1 # mov eax, 1 +code[::1] = 0xCD, 0x80 # int 0x80 data = Linkie('<') # ia32 data.place_symbol('&message') -data.emit_string('Hello, world!\n') +data[::1] = map(ord, 'Hello, world!\n') print 'With symbols' hello = make_ELF32_object(text = code, data = data, flags = 's') |
From: <di...@us...> - 2003-04-27 12:48:34
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv12814 Modified Files: linkie.py Log Message: minor fix of Linkie.emit_single_item Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- linkie.py 27 Apr 2003 12:06:25 -0000 1.44 +++ linkie.py 27 Apr 2003 12:48:30 -0000 1.45 @@ -57,7 +57,8 @@ this.emit_tetra(this._emit_sum(4, addends, delta, relative)) def emit_single_item (this, step, value): if isinstance(value, str): - this._emit_sum(step, [value], delta = 0, relative = 0) + this.emit_tetra(this._emit_sum(step, [value], + delta = 0, relative = 0)) else: Bits.emit_single_item(this, step, value) def skip (this, amount): |
From: <di...@us...> - 2003-04-27 12:28:53
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv1746 Modified Files: bits.py Log Message: fixed a type dichotomy in Bits.__setitem__ Index: bits.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/bits.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- bits.py 27 Apr 2003 12:12:08 -0000 1.16 +++ bits.py 27 Apr 2003 12:28:49 -0000 1.17 @@ -65,8 +65,8 @@ else: start, stop, step = index, None, 1 if start == None: # emit - if isinstance(value, int) or isinstance(value, long): - this.emit_single_item(step, value) - else: - for v in value: this.emit_single_item(step, value) + if isinstance(value, tuple) or isinstance(value, list): + for v in value: + this.emit_single_item(step, v) + else: this.emit_single_item(step, value) else: this.set_single_item(start, step, value) |
From: <di...@us...> - 2003-04-27 12:12:12
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv19291 Modified Files: bits.py Log Message: minor fix of Bits.set_single_item Index: bits.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/bits.py,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- bits.py 27 Apr 2003 12:08:16 -0000 1.15 +++ bits.py 27 Apr 2003 12:12:08 -0000 1.16 @@ -52,11 +52,9 @@ def set_single_item (this, index, step, value): # for easy extension if index < 0 or index > len(this._contents): raise IndexError, index - if step == 1: this._contents[index] = chr(value % 0x100) - else: - tpl = this._byte_order + {2: 'H', 4: 'L'}[step] - this._contents[index : index + step] = \ - array('c', pack(tpl, value % (1L << (step << 3)))) + tpl = this._byte_order + {1: 'B', 2: 'H', 4: 'L'}[step] + this._contents[index : index + step] = \ + array('c', pack(tpl, value % (1L << (step << 3)))) def emit_single_item (this, step, value): # for easy extension this.set_single_item(len(this._contents), step, value) def __setitem__ (this, index, value): |
From: <di...@us...> - 2003-04-27 12:08:20
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv15555 Modified Files: bits.py Log Message: minor fix of Bits.set_single_item Index: bits.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/bits.py,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- bits.py 27 Apr 2003 11:37:13 -0000 1.14 +++ bits.py 27 Apr 2003 12:08:16 -0000 1.15 @@ -52,7 +52,7 @@ def set_single_item (this, index, step, value): # for easy extension if index < 0 or index > len(this._contents): raise IndexError, index - if step == 1: this._contents[start] = chr(value % 0x100) + if step == 1: this._contents[index] = chr(value % 0x100) else: tpl = this._byte_order + {2: 'H', 4: 'L'}[step] this._contents[index : index + step] = \ |
From: <di...@us...> - 2003-04-27 12:06:29
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv13906 Modified Files: linkie.py Log Message: extended Linkie.emit_single_item to accept strings and interpret them as symbol references Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- linkie.py 26 Apr 2003 21:33:49 -0000 1.43 +++ linkie.py 27 Apr 2003 12:06:25 -0000 1.44 @@ -55,6 +55,10 @@ 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 emit_single_item (this, step, value): + if isinstance(value, str): + this._emit_sum(step, [value], delta = 0, relative = 0) + else: Bits.emit_single_item(this, step, value) def skip (this, amount): """skip(amount) |
From: <di...@us...> - 2003-04-27 11:44:32
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv29531 Modified Files: make-pe-exe.py Log Message: PE32 a.out header refers to text and data segments by their RVAs, not offsets Index: make-pe-exe.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/make-pe-exe.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- make-pe-exe.py 22 Apr 2003 22:29:30 -0000 1.7 +++ make-pe-exe.py 27 Apr 2003 11:44:28 -0000 1.8 @@ -139,8 +139,8 @@ h.emit_tetra_sum(['#aout/data-size']) h.emit_tetra_sum(['#aout/bss-size']) h.emit_tetra_sum(['%_start']) - h.emit_tetra_sum(['!.text']) - h.emit_tetra_sum(['!.data']) # not present in PE32+ (?) + h.emit_tetra_sum(['%.text']) + h.emit_tetra_sum(['%.data']) # not present in PE32+ (?) # #aout/image-base must be multiple of 64ki h.emit_tetra_sum(['#aout/image-base']) h.emit_tetra_sum(['#aout/memory-align']) |
From: <di...@us...> - 2003-04-27 11:37:18
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv22906 Modified Files: bits.py Log Message: introduced Bits.emit_single_item Index: bits.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/bits.py,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- bits.py 27 Apr 2003 08:24:50 -0000 1.13 +++ bits.py 27 Apr 2003 11:37:13 -0000 1.14 @@ -57,19 +57,18 @@ tpl = this._byte_order + {2: 'H', 4: 'L'}[step] this._contents[index : index + step] = \ array('c', pack(tpl, value % (1L << (step << 3)))) + def emit_single_item (this, step, value): # for easy extension + this.set_single_item(len(this._contents), step, value) def __setitem__ (this, index, value): if isinstance(index, SliceType): start, stop, step = index.start, index.stop, index.step - if start == None: - if isinstance(value, int) or isinstance(value, long): - start = len(this._contents) - else: - for v in value: - this.__setitem__(index, v) - return if stop != None or not step in (1, 2, 4): raise 'Bad slice for Bits.__setitem__', index - if start > len(this._contents): raise IndexError, start - this.set_single_item(start, step, value) else: - this._contents[index] = chr(value % 0x100) + start, stop, step = index, None, 1 + if start == None: # emit + if isinstance(value, int) or isinstance(value, long): + this.emit_single_item(step, value) + else: + for v in value: this.emit_single_item(step, value) + else: this.set_single_item(start, step, value) |
From: <di...@us...> - 2003-04-27 08:24:53
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv2388 Modified Files: bits.py Log Message: extracted Bits.set_single_item from Bits.__setitem__ Index: bits.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/bits.py,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- bits.py 27 Apr 2003 07:53:02 -0000 1.12 +++ bits.py 27 Apr 2003 08:24:50 -0000 1.13 @@ -49,6 +49,14 @@ tpl = this._byte_order + {2: 'H', 4: 'L'}[step] return unpack(tpl, data)[0] else: return ord(this._contents[index]) + def set_single_item (this, index, step, value): # for easy extension + if index < 0 or index > len(this._contents): + raise IndexError, index + if step == 1: this._contents[start] = chr(value % 0x100) + else: + tpl = this._byte_order + {2: 'H', 4: 'L'}[step] + this._contents[index : index + step] = \ + array('c', pack(tpl, value % (1L << (step << 3)))) def __setitem__ (this, index, value): if isinstance(index, SliceType): start, stop, step = index.start, index.stop, index.step @@ -62,12 +70,6 @@ if stop != None or not step in (1, 2, 4): raise 'Bad slice for Bits.__setitem__', index if start > len(this._contents): raise IndexError, start - if step == 1: this._contents[start] = chr(value % 0x100) - else: - tpl = this._byte_order + {2: 'H', 4: 'L'}[step] - this._contents[start : start + step] = \ - array('c', pack(tpl, value % (1L << (step << 3)))) + this.set_single_item(start, step, value) else: - if index > len(this._contents): - raise IndexError, index this._contents[index] = chr(value % 0x100) |
From: <di...@us...> - 2003-04-27 07:53:06
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv16780 Modified Files: bits.py Log Message: allow sequence assignments to [::n] in Bits.__setitem__ Index: bits.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/bits.py,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- bits.py 27 Apr 2003 07:35:26 -0000 1.11 +++ bits.py 27 Apr 2003 07:53:02 -0000 1.12 @@ -52,7 +52,13 @@ def __setitem__ (this, index, value): if isinstance(index, SliceType): start, stop, step = index.start, index.stop, index.step - if start == None: start = len(this._contents) + if start == None: + if isinstance(value, int) or isinstance(value, long): + start = len(this._contents) + else: + for v in value: + this.__setitem__(index, v) + return if stop != None or not step in (1, 2, 4): raise 'Bad slice for Bits.__setitem__', index if start > len(this._contents): raise IndexError, start |
From: <di...@us...> - 2003-04-27 07:35:29
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv7422 Modified Files: bits.py Log Message: interpret assignments to [::n] as emits in Bits.__setitem__ Index: bits.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/bits.py,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- bits.py 27 Apr 2003 07:33:24 -0000 1.10 +++ bits.py 27 Apr 2003 07:35:26 -0000 1.11 @@ -52,7 +52,8 @@ def __setitem__ (this, index, value): if isinstance(index, SliceType): start, stop, step = index.start, index.stop, index.step - if start == None or stop != None or not step in (1, 2, 4): + if start == None: start = len(this._contents) + if stop != None or not step in (1, 2, 4): raise 'Bad slice for Bits.__setitem__', index if start > len(this._contents): raise IndexError, start if step == 1: this._contents[start] = chr(value % 0x100) |
From: <di...@us...> - 2003-04-27 07:33:30
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv6672 Modified Files: bits.py Log Message: minor cleanup of Bits.__getitem__ and Bits.__setitem__ Index: bits.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/bits.py,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- bits.py 26 Apr 2003 21:33:49 -0000 1.9 +++ bits.py 27 Apr 2003 07:33:24 -0000 1.10 @@ -40,27 +40,26 @@ def __getitem__ (this, index): if isinstance(index, SliceType): - if index.start == None or index.stop != None or \ - not index.step in (1, 2, 4): + start, stop, step = index.start, index.stop, index.step + if start == None or stop != None or not step in (1, 2, 4): raise 'Bad slice for Bits.__getitem__', index - if index.step == 1: return ord(this._contents[index.start]) + if step == 1: return ord(this._contents[start]) else: - data = this._contents[index.start : index.start + index.step] - tpl = this._byte_order + {2: 'H', 4: 'L'}[index.step] + data = this._contents[start : start + step] + tpl = this._byte_order + {2: 'H', 4: 'L'}[step] return unpack(tpl, data)[0] else: return ord(this._contents[index]) def __setitem__ (this, index, value): if isinstance(index, SliceType): - if index.start == None or index.stop != None or \ - not index.step in (1, 2, 4): + start, stop, step = index.start, index.stop, index.step + if start == None or stop != None or not step in (1, 2, 4): raise 'Bad slice for Bits.__setitem__', index - if index.start > len(this._contents): - raise IndexError, index.start - if index.step == 1: this._contents[index.start] = chr(value % 0x100) + if start > len(this._contents): raise IndexError, start + if step == 1: this._contents[start] = chr(value % 0x100) else: - tpl = this._byte_order + {2: 'H', 4: 'L'}[index.step] - this._contents[index.start : index.start + index.step] = \ - array('c', pack(tpl, value % (1L << (index.step << 3)))) + tpl = this._byte_order + {2: 'H', 4: 'L'}[step] + this._contents[start : start + step] = \ + array('c', pack(tpl, value % (1L << (step << 3)))) else: if index > len(this._contents): raise IndexError, index |
From: <di...@us...> - 2003-04-26 21:33:53
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv17848 Modified Files: bits.py linkie.py Log Message: moved the _skipped slot from Bits to Linkie Index: bits.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/bits.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- bits.py 26 Apr 2003 21:31:19 -0000 1.8 +++ bits.py 26 Apr 2003 21:33:49 -0000 1.9 @@ -11,8 +11,7 @@ from types import SliceType class Bits (object): - __slots__ = ['_contents', '_skipped', '_byte_order', - 'emit_wyde', 'emit_tetra'] + __slots__ = ['_contents', '_byte_order', 'emit_wyde', 'emit_tetra'] def __init__ (this, byte_order = None): this._contents = array('c') if byte_order == None: pass @@ -23,25 +22,18 @@ this.emit_wyde = this.emit_bewyde this.emit_tetra = this.emit_betetra else: raise "Unknown byte order", byte_order - this._skipped = 0 this._byte_order = byte_order def emit_byte (this, b): - if this._skipped <> 0: raise "Events out of order", this this._contents.append(chr(b & 0xff)) def emit_bewyde (this, w): - if this._skipped <> 0: raise "Events out of order", this this._contents.fromstring(pack('>H', w)) # FIXME? def emit_lewyde (this, w): - if this._skipped <> 0: raise "Events out of order", this this._contents.fromstring(pack('<H', w)) # FIXME? def emit_betetra (this, t): - if this._skipped <> 0: raise "Events out of order", this this._contents.fromstring(pack('>L', t)) # FIXME? def emit_letetra (this, t): - if this._skipped <> 0: raise "Events out of order", this this._contents.fromstring(pack('<L', t)) # FIXME? def emit_string (this, s): - if this._skipped <> 0: raise "Events out of order", this this._contents.fromstring(s) def from_array (this, a): this._contents.extend(a) Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- linkie.py 26 Apr 2003 21:22:20 -0000 1.42 +++ linkie.py 26 Apr 2003 21:33:49 -0000 1.43 @@ -12,6 +12,7 @@ class Linkie (Bits): def __init__ (this, byte_order = None): Bits.__init__(this, byte_order) + this._skipped = 0 this._byte_order = byte_order this._symbols = [] # symbol -> address this._alignment = 1 # minimal required alignment constraint |
From: <di...@us...> - 2003-04-26 21:31:22
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv16976 Modified Files: bits.py Log Message: added some range checking to Bits.__setitem__ Index: bits.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/bits.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- bits.py 26 Apr 2003 21:27:45 -0000 1.7 +++ bits.py 26 Apr 2003 21:31:19 -0000 1.8 @@ -62,9 +62,14 @@ if index.start == None or index.stop != None or \ not index.step in (1, 2, 4): raise 'Bad slice for Bits.__setitem__', index + if index.start > len(this._contents): + raise IndexError, index.start if index.step == 1: this._contents[index.start] = chr(value % 0x100) else: tpl = this._byte_order + {2: 'H', 4: 'L'}[index.step] this._contents[index.start : index.start + index.step] = \ array('c', pack(tpl, value % (1L << (index.step << 3)))) - else: this._contents[index] = chr(value % 0x100) + else: + if index > len(this._contents): + raise IndexError, index + this._contents[index] = chr(value % 0x100) |
From: <di...@us...> - 2003-04-26 21:27:49
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv15685 Modified Files: bits.py Log Message: minor fix of Bits.__setitem__ Index: bits.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/bits.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- bits.py 26 Apr 2003 21:27:28 -0000 1.6 +++ bits.py 26 Apr 2003 21:27:45 -0000 1.7 @@ -61,7 +61,7 @@ if isinstance(index, SliceType): if index.start == None or index.stop != None or \ not index.step in (1, 2, 4): - raise 'Bad slice for Bits.__getitem__', index + raise 'Bad slice for Bits.__setitem__', index if index.step == 1: this._contents[index.start] = chr(value % 0x100) else: tpl = this._byte_order + {2: 'H', 4: 'L'}[index.step] |
From: <di...@us...> - 2003-04-26 21:27:31
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv15612 Modified Files: bits.py Log Message: minor fix of Bits.__setitem__ Index: bits.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/bits.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- bits.py 26 Apr 2003 21:24:14 -0000 1.5 +++ bits.py 26 Apr 2003 21:27:28 -0000 1.6 @@ -67,4 +67,4 @@ tpl = this._byte_order + {2: 'H', 4: 'L'}[index.step] this._contents[index.start : index.start + index.step] = \ array('c', pack(tpl, value % (1L << (index.step << 3)))) - else: return ord(this._contents[index]) + else: this._contents[index] = chr(value % 0x100) |
From: <di...@us...> - 2003-04-26 21:24:18
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv14577a Modified Files: bits.py Log Message: dropped Bits.add_byte, Bits.add_wyde, and Bits.add_tetra Index: bits.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/bits.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- bits.py 26 Apr 2003 21:10:39 -0000 1.4 +++ bits.py 26 Apr 2003 21:24:14 -0000 1.5 @@ -45,10 +45,6 @@ this._contents.fromstring(s) def from_array (this, a): this._contents.extend(a) - def add_byte (this, ofs, value): - this._contents[ofs] = chr((ord(this._contents[ofs]) + value) % 0x100) - def add_wyde (this, ofs, value): this[ofs::2] += value - def add_tetra (this, ofs, value): this[ofs::4] += value def __getitem__ (this, index): if isinstance(index, SliceType): |
From: <di...@us...> - 2003-04-26 21:22:24
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv13842 Modified Files: linkie.py Log Message: simplified Linkie.link Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- linkie.py 26 Apr 2003 21:18:39 -0000 1.41 +++ linkie.py 26 Apr 2003 21:22:20 -0000 1.42 @@ -281,21 +281,11 @@ i = i - 1 offset, type, arg = this._linker_notes[i] if symbols.has_key(arg): - if type == 1: - this.add_byte(offset, symbols[arg]) - elif type == 2: - this.add_wyde(offset, symbols[arg]) - elif type == 4: - this.add_tetra(offset, symbols[arg]) - elif type == -1: - this.add_byte(offset, symbols[arg] - - (this._origin + offset)) - elif type == -2: - this.add_wyde(offset, symbols[arg] - - (this._origin + offset)) - elif type == -4: - this.add_tetra(offset, symbols[arg] - - (this._origin + offset)) + if type in (1, 2, 4): + this[offset::type] += symbols[arg] + elif type in (-1, -2, -4): + this[offset::-type] += \ + symbols[arg] - (this._origin + offset) else: raise 'Invalid linker note type', (offset, type, arg) del this._linker_notes[i] return len(this._linker_notes) |
From: <di...@us...> - 2003-04-26 21:18:44
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv12316 Modified Files: linkie.py Log Message: simplified Linkie.place_label Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- linkie.py 26 Apr 2003 17:44:25 -0000 1.40 +++ linkie.py 26 Apr 2003 21:18:39 -0000 1.41 @@ -92,14 +92,9 @@ i = i - 1 referee, type, data = this._unresolved_locals[i] if referee == label: - if type == -1: - this.add_byte(data, this._locals[label] - data) - elif type == -2: - this.add_wyde(data, this._locals[label] - data) - elif type == -4: - this.add_tetra(data, this._locals[label] - data) - else: - raise "Can't happen: unknown local reference type", this + if type in (-1, -2, -4): + this[data::-type] += this._locals[label] - data + else: raise "Can't happen: unknown local reference type", this del this._unresolved_locals[i] # close the entry def place_symbol (this, symbol, value = None): """place_symbol(symbol, value = None) => value |
From: <di...@us...> - 2003-04-26 21:10:43
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv9173 Modified Files: bits.py Log Message: simplified Bits.add_wyde and Bits.add_tetra Index: bits.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/bits.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- bits.py 26 Apr 2003 21:08:40 -0000 1.3 +++ bits.py 26 Apr 2003 21:10:39 -0000 1.4 @@ -47,14 +47,8 @@ this._contents.extend(a) def add_byte (this, ofs, value): this._contents[ofs] = chr((ord(this._contents[ofs]) + value) % 0x100) - def _add (this, ofs, value, size, tpl): - datum, = unpack(tpl, this._contents[ofs : ofs + size]) - datum += value - datum %= 1L << (size << 3) - this._contents[ofs : ofs + size] = \ - array('c', pack(this._byte_order + tpl, datum)) - def add_wyde (this, ofs, value): this._add(ofs, value, 2, 'H') - def add_tetra (this, ofs, value): this._add(ofs, value, 4, 'L') + def add_wyde (this, ofs, value): this[ofs::2] += value + def add_tetra (this, ofs, value): this[ofs::4] += value def __getitem__ (this, index): if isinstance(index, SliceType): |
From: <di...@us...> - 2003-04-26 21:08:44
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv8331 Modified Files: bits.py Log Message: introduced Bits.__setitem__ Index: bits.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/bits.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- bits.py 26 Apr 2003 20:56:56 -0000 1.2 +++ bits.py 26 Apr 2003 21:08:40 -0000 1.3 @@ -65,5 +65,16 @@ else: data = this._contents[index.start : index.start + index.step] tpl = this._byte_order + {2: 'H', 4: 'L'}[index.step] - return unpack(tpl, data) + return unpack(tpl, data)[0] + else: return ord(this._contents[index]) + def __setitem__ (this, index, value): + if isinstance(index, SliceType): + if index.start == None or index.stop != None or \ + not index.step in (1, 2, 4): + raise 'Bad slice for Bits.__getitem__', index + if index.step == 1: this._contents[index.start] = chr(value % 0x100) + else: + tpl = this._byte_order + {2: 'H', 4: 'L'}[index.step] + this._contents[index.start : index.start + index.step] = \ + array('c', pack(tpl, value % (1L << (index.step << 3)))) else: return ord(this._contents[index]) |
From: <di...@us...> - 2003-04-26 20:56:59
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv3871 Modified Files: bits.py Log Message: introduced Bits.__getitem__ Index: bits.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/bits.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- bits.py 26 Apr 2003 17:36:17 -0000 1.1 +++ bits.py 26 Apr 2003 20:56:56 -0000 1.2 @@ -8,23 +8,23 @@ from array import array from struct import pack, unpack +from types import SliceType class Bits (object): - __slots__ = ['_contents', '_skipped'] + __slots__ = ['_contents', '_skipped', '_byte_order', + 'emit_wyde', 'emit_tetra'] def __init__ (this, byte_order = None): this._contents = array('c') if byte_order == None: pass elif byte_order == '<': this.emit_wyde = this.emit_lewyde this.emit_tetra = this.emit_letetra - this.add_wyde = this.add_lewyde - this.add_tetra = this.add_letetra elif byte_order == '>': this.emit_wyde = this.emit_bewyde this.emit_tetra = this.emit_betetra - this.add_wyde = this.add_bewyde - this.add_tetra = this.add_betetra else: raise "Unknown byte order", byte_order + this._skipped = 0 + this._byte_order = byte_order def emit_byte (this, b): if this._skipped <> 0: raise "Events out of order", this this._contents.append(chr(b & 0xff)) @@ -51,9 +51,19 @@ datum, = unpack(tpl, this._contents[ofs : ofs + size]) datum += value datum %= 1L << (size << 3) - this._contents[ofs : ofs + size] = array('c', pack(tpl, datum)) - def add_lewyde (this, ofs, value): this._add(ofs, value, 2, '<H') - def add_bewyde (this, ofs, value): this._add(ofs, value, 2, '>H') - def add_letetra (this, ofs, value): this._add(ofs, value, 4, '<L') - def add_betetra (this, ofs, value): this._add(ofs, value, 4, '>L') + this._contents[ofs : ofs + size] = \ + array('c', pack(this._byte_order + tpl, datum)) + def add_wyde (this, ofs, value): this._add(ofs, value, 2, 'H') + def add_tetra (this, ofs, value): this._add(ofs, value, 4, 'L') + def __getitem__ (this, index): + if isinstance(index, SliceType): + if index.start == None or index.stop != None or \ + not index.step in (1, 2, 4): + raise 'Bad slice for Bits.__getitem__', index + if index.step == 1: return ord(this._contents[index.start]) + else: + data = this._contents[index.start : index.start + index.step] + tpl = this._byte_order + {2: 'H', 4: 'L'}[index.step] + return unpack(tpl, data) + else: return ord(this._contents[index]) |
From: <di...@us...> - 2003-04-26 17:44:29
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv30661 Modified Files: linkie.py Log Message: minor cleanup Index: linkie.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/linkie.py,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- linkie.py 26 Apr 2003 17:43:04 -0000 1.39 +++ linkie.py 26 Apr 2003 17:44:25 -0000 1.40 @@ -7,7 +7,6 @@ #### @(#) $Id$ from bits import Bits -from types import StringType from array import array class Linkie (Bits): @@ -36,7 +35,7 @@ for a in addends: if relative: s = -size; relative -= 1 - if type(a) != StringType: raise 'relative non-symbol?', a + if not isinstance(a, str): raise 'relative non-symbol?', a else: s = size if isinstance(a, int): # local reference if this._locals[a] <> None: # backwards |