about summary refs log tree commit diff stats
path: root/test/core/sembuilder.py
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2015-04-24 13:11:24 +0200
committerAjax <commial@gmail.com>2015-04-24 13:11:24 +0200
commita300ef578432b16c4d7e6de04a638834b73f82c7 (patch)
tree24fb1a1099b50d4296105e74fd85da2812366e31 /test/core/sembuilder.py
parent9536200d7787797c34635dce16462164530f8eaa (diff)
downloadfocaccia-miasm-a300ef578432b16c4d7e6de04a638834b73f82c7.tar.gz
focaccia-miasm-a300ef578432b16c4d7e6de04a638834b73f82c7.zip
SemBuilder: Introduce the 'if cond' statement, building a new IRBlock
Diffstat (limited to 'test/core/sembuilder.py')
-rw-r--r--test/core/sembuilder.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/test/core/sembuilder.py b/test/core/sembuilder.py
index 8d61c1b8..468e3ef5 100644
--- a/test/core/sembuilder.py
+++ b/test/core/sembuilder.py
@@ -3,7 +3,20 @@ from pdb import pm
 
 from miasm2.core.sembuilder import SemBuilder
 import miasm2.expression.expression as m2_expr
+from miasm2.core.asmbloc import asm_label
 
+# Test classes
+class IR(object):
+
+    IRDst = m2_expr.ExprId("IRDst")
+
+    def get_next_instr(self, _):
+        return asm_label("NEXT")
+
+    def gen_label(self):
+        return asm_label("GEN")
+
+# Test
 sb = SemBuilder(m2_expr.__dict__)
 
 @sb.parse
@@ -16,13 +29,24 @@ def test(Arg1, Arg2, Arg3):
     tmpvar = 'myop'(i32(2))
     Arg2 = ('myopsize%d' % Arg1.size)(tmpvar, Arg1)
 
+    if not Arg1:
+        Arg2 = Arg3
+
 a = m2_expr.ExprId('A')
 b = m2_expr.ExprId('B')
 c = m2_expr.ExprId('C')
-ir = None
+ir = IR()
 instr = None
 res = test(ir, instr, a, b, c)
+
+print "[+] Returned:"
 print res
+print "[+] DocString:", test.__doc__
+
+print "[+] Cur instr:"
 for statement in res[0]:
     print statement
-print test.__doc__
+
+print "[+] Blocks:"
+for block in res[1]:
+    print block