about summary refs log tree commit diff stats
path: root/example/expression/expr_c.py
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2017-02-20 14:41:08 +0100
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2017-05-15 21:29:34 +0200
commit9e79f4338ad7cae991ee73902898e24782874ad5 (patch)
treebe4f8ecc5725357feff7a8aa364569665fee2eaa /example/expression/expr_c.py
parent3260f7867827195ea7c6ec37bc3a8687ce998f6d (diff)
downloadmiasm-9e79f4338ad7cae991ee73902898e24782874ad5.tar.gz
miasm-9e79f4338ad7cae991ee73902898e24782874ad5.zip
Core/Objc: improuve internal type representation
Diffstat (limited to 'example/expression/expr_c.py')
-rw-r--r--example/expression/expr_c.py20
1 files changed, 8 insertions, 12 deletions
diff --git a/example/expression/expr_c.py b/example/expression/expr_c.py
index b3e59658..e2986c55 100644
--- a/example/expression/expr_c.py
+++ b/example/expression/expr_c.py
@@ -4,10 +4,9 @@ Parse C expression to access variables and retrieve information:
 * variable type
 """
 
-from miasm2.core.ctypesmngr import CTypesManagerNotPacked
+from miasm2.core.ctypesmngr import CTypeStruct, CAstTypes, CTypePtr
 from miasm2.arch.x86.ctype import CTypeAMD64_unk
-from miasm2.core.objc import CHandler
-from miasm2.core.objc import ObjCPtr
+from miasm2.core.objc import CTypesManagerNotPacked, CHandler
 from miasm2.expression.expression import ExprId
 
 
@@ -31,25 +30,22 @@ def test():
     """
 
     # Type manager for x86 64: structures not packed
-    my_types = CTypeAMD64_unk()
-    types_mngr = CTypesManagerNotPacked(my_types.types)
+    base_types = CTypeAMD64_unk()
+    types_ast = CAstTypes()
 
     # Add C types definition
-    types_mngr.add_c_decl(text)
+    types_ast.add_c_decl(text)
 
-    # Create the ptr variable with type "struct rectangle*"
-    void_ptr = types_mngr.void_ptr
-    rectangle = types_mngr.get_type(('rectangle',))
-    ptr_rectangle = ObjCPtr('noname', rectangle,
-                            void_ptr.align, void_ptr.size)
+    types_mngr = CTypesManagerNotPacked(types_ast, base_types)
 
+    # Create the ptr variable with type "struct rectangle*"
+    ptr_rectangle = types_mngr.get_objc(CTypePtr(CTypeStruct('rectangle')))
 
     ptr = ExprId('ptr', 64)
     expr_types = {ptr.name: ptr_rectangle}
 
     mychandler = CHandler(types_mngr, expr_types)
 
-
     # Parse some C accesses
     c_acceses = ["ptr->width",
                  "ptr->length",