diff options
author | Peter Johnson <peter@tortall.net> | 2006-12-10 07:05:06 +0000 |
---|---|---|
committer | Peter Johnson <peter@tortall.net> | 2006-12-10 07:05:06 +0000 |
commit | 9ab89fdfe6147125a3be31c89296e4d8144e9132 (patch) | |
tree | 86217da93c5e3c786327a3c5f3534cd6b0a0e7c5 /tools | |
parent | b1d27878fdbff4e7e2a7fa6ebf0c0726bf12cf16 (diff) | |
download | yasm-9ab89fdfe6147125a3be31c89296e4d8144e9132.tar.gz |
Take [1423] to the next logical step by supporting the general case of
(sym in other section)-(sym in this section) rather than just
(sym in other section)-(curpos) (e.g. sym-$). Unfortunately supporting
this required precbc to be flowed down to the value_finalize functions,
but it's relatively reasonable to do so, as all of the _finalize() routines
have access to precbc.
Reported by: Peter Tanski <peter_tanski@cox.net>
svn path=/trunk/yasm/; revision=1705
Diffstat (limited to 'tools')
-rw-r--r-- | tools/python-yasm/bytecode.pxi | 17 | ||||
-rw-r--r-- | tools/python-yasm/value.pxi | 15 |
2 files changed, 22 insertions, 10 deletions
diff --git a/tools/python-yasm/bytecode.pxi b/tools/python-yasm/bytecode.pxi index 913a4081..50c72ae7 100644 --- a/tools/python-yasm/bytecode.pxi +++ b/tools/python-yasm/bytecode.pxi @@ -47,7 +47,7 @@ cdef extern from "libyasm/bytecode.h": cdef struct yasm_dataval cdef struct yasm_datavalhead - cdef yasm_immval* yasm_imm_create_expr(yasm_expr *e) + cdef yasm_immval* yasm_imm_create_expr(yasm_expr *e, yasm_bytecode *precbc) cdef yasm_expr* yasm_ea_get_disp(yasm_effaddr *ea) cdef void yasm_ea_set_len(yasm_effaddr *ea, unsigned int len) cdef void yasm_ea_set_nosplit(yasm_effaddr *ea, unsigned int nosplit) @@ -159,14 +159,21 @@ cdef object __make_immval(yasm_immval *imm): cdef class ImmVal: cdef yasm_immval *imm - def __new__(self, value): + def __new__(self, value, precbc=None): if isinstance(value, Expression): - self.imm = yasm_imm_create_expr( - yasm_expr_copy((<Expression>value).expr)) + if precbc is None: + self.imm = yasm_imm_create_expr( + yasm_expr_copy((<Expression>value).expr), NULL) + elif isinstance(precbc, Bytecode): + self.imm = yasm_imm_create_expr( + yasm_expr_copy((<Expression>value).expr), + (<Bytecode>precbc).bc) + else: + raise TypeError("Invalid precbc type '%s'" % type(precbc)) elif PyCObject_Check(value): self.imm = <yasm_immval *>__get_voidp(value, ImmVal) else: - raise TypeError + raise TypeError("Invalid value type '%s'" % type(value)) cdef class Bytecode: cdef yasm_bytecode *bc diff --git a/tools/python-yasm/value.pxi b/tools/python-yasm/value.pxi index 2e89c0f7..98ba14ea 100644 --- a/tools/python-yasm/value.pxi +++ b/tools/python-yasm/value.pxi @@ -29,9 +29,9 @@ cdef extern from "libyasm/value.h": cdef void yasm_value_init_sym(yasm_value *value, yasm_symrec *sym, unsigned int size) cdef void yasm_value_delete(yasm_value *value) - cdef int yasm_value_finalize(yasm_value *value) + cdef int yasm_value_finalize(yasm_value *value, yasm_bytecode *precbc) cdef int yasm_value_finalize_expr(yasm_value *value, yasm_expr *e, - unsigned int size) + yasm_bytecode *precbc, unsigned int size) cdef yasm_intnum *yasm_value_get_intnum(yasm_value *value, yasm_bytecode *bc) cdef int yasm_value_output_basic(yasm_value *value, unsigned char *buf, @@ -56,11 +56,16 @@ cdef class Value: elif isinstance(value, Symbol): yasm_value_init_sym(&self.value, (<Symbol>value).sym, sz) else: - raise ValueError("Invalid value type '%s'" % type(value)) + raise TypeError("Invalid value type '%s'" % type(value)) def __dealloc__(self): yasm_value_delete(&self.value) - def finalize(self): - return yasm_value_finalize(&self.value) + def finalize(self, precbc=None): + if precbc is None: + return yasm_value_finalize(&self.value, NULL) + elif isinstance(precbc, Bytecode): + return yasm_value_finalize(&self.value, (<Bytecode>precbc).bc) + else: + raise TypeError("Invalid precbc type '%s'" % type(precbc)) |