diff options
| author | Ajax <commial@gmail.com> | 2015-04-24 10:08:23 +0200 |
|---|---|---|
| committer | Ajax <commial@gmail.com> | 2015-04-24 10:08:23 +0200 |
| commit | 568dd3641a10e0887700a3a3433e2e20e8e37825 (patch) | |
| tree | d957d20917a97635d4d2b56a3d60a3360aaa1879 | |
| parent | d0fd34c341103d17c7f7a6409d23a34b7d362747 (diff) | |
| download | miasm-568dd3641a10e0887700a3a3433e2e20e8e37825.tar.gz miasm-568dd3641a10e0887700a3a3433e2e20e8e37825.zip | |
SemBuilder: PreInit context with needed values
| -rw-r--r-- | miasm2/arch/mips32/sem.py | 1 | ||||
| -rw-r--r-- | miasm2/core/sembuilder.py | 11 |
2 files changed, 10 insertions, 2 deletions
diff --git a/miasm2/arch/mips32/sem.py b/miasm2/arch/mips32/sem.py index 9589eb1e..ca368883 100644 --- a/miasm2/arch/mips32/sem.py +++ b/miasm2/arch/mips32/sem.py @@ -10,7 +10,6 @@ ctx = {"R_LO": R_LO, "R_HI": R_HI, "PC": PC, "RA": RA} -ctx.update(m2_expr.__dict__) sbuild = SemBuilder(ctx) diff --git a/miasm2/core/sembuilder.py b/miasm2/core/sembuilder.py index ba9d9d80..ddf1cb32 100644 --- a/miasm2/core/sembuilder.py +++ b/miasm2/core/sembuilder.py @@ -4,6 +4,9 @@ import inspect import ast import re +import miasm2.expression.expression as m2_expr +from miasm2.ir.ir import irbloc + class MiasmTransformer(ast.NodeTransformer): """AST visitor translating DSL to Miasm expression @@ -99,8 +102,14 @@ class SemBuilder(object): """Create a SemBuilder @ctx: context dictionnary used during parsing """ - self.ctx = dict(ctx) + # Init self.transformer = MiasmTransformer() + self.ctx = dict(m2_expr.__dict__) + self.ctx["irbloc"] = irbloc + + # Update context + self.ctx.update(ctx) + def parse(self, func): """Function decorator, returning a correct method from a pseudo-Python |