From 3805e82bfad5036c89db87fb83eb8812d658100d Mon Sep 17 00:00:00 2001 From: Ajax Date: Wed, 22 Apr 2015 15:05:00 +0200 Subject: SemBuilder: Handle real variable declaration --- miasm2/core/sembuilder.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'miasm2/core/sembuilder.py') diff --git a/miasm2/core/sembuilder.py b/miasm2/core/sembuilder.py index 65e951bd..34271960 100644 --- a/miasm2/core/sembuilder.py +++ b/miasm2/core/sembuilder.py @@ -90,6 +90,7 @@ class SemBuilder(object): # Get the function AST parsed = ast.parse(inspect.getsource(func)) fc_ast = parsed.body[0] + argument_names = [name.id for name in fc_ast.args.args] body = [] # AffBlock of the current instruction @@ -99,6 +100,15 @@ class SemBuilder(object): if isinstance(statement, ast.Assign): src = self.transformer.visit(statement.value) dst = self.transformer.visit(statement.targets[0]) + + if (isinstance(dst, ast.Name) and + dst.id not in argument_names and + dst.id not in self.ctx): + # Real variable declaration + statement.value = src + body.append(statement) + continue + dst.ctx = ast.Load() res = ast.Call(func=ast.Name(id='ExprAff', -- cgit 1.4.1