99
1010from .branch_predictor import *
1111from ..arch import ArchX86
12+ from ..misc import check_and_eval
1213
1314class BranchPredictorX86 (BranchPredictor , ArchX86 ):
1415 """
@@ -98,12 +99,6 @@ def predict(self):
9899
99100 if prophecy .going :
100101 takeaway_list = ["ptr" , "dword" , "[" , "]" ]
101- class AST_checker (ast .NodeVisitor ):
102- def generic_visit (self , node ):
103- if type (node ) in (ast .Module , ast .Expr , ast .BinOp , ast .Constant , ast .Add , ast .Mult , ast .Sub ):
104- ast .NodeVisitor .generic_visit (self , node )
105- else :
106- raise ParseError ("malform or invalid ast node" )
107102
108103 if len (line .op_str .split ()) > 1 :
109104 new_line = line .op_str .replace (":" , "+" )
@@ -119,12 +114,8 @@ def generic_visit(self, node):
119114 if each_reg in new_line :
120115 new_line = re .sub (each_reg , hex (self .read_reg (each_reg )), new_line )
121116
122- checker = AST_checker ()
123- ast_tree = ast .parse (new_line )
124117
125- checker .visit (ast_tree )
126-
127- prophecy .where = eval (new_line )
118+ prophecy .where = check_and_eval (new_line )
128119
129120 elif line .op_str in self .ql .reg .register_mapping :
130121 prophecy .where = self .ql .reg .read (line .op_str )
0 commit comments