about summary refs log tree commit diff stats
path: root/miasm/expression/expression_helper.py
diff options
context:
space:
mode:
authorserpilliere <devnull@localhost>2012-02-27 08:42:48 +0100
committerserpilliere <devnull@localhost>2012-02-27 08:42:48 +0100
commit9ada5b417a2b92aa855791fb2d4c3e282c2dcb2e (patch)
treee33dec3a2828c2f537b4228336202710b7264630 /miasm/expression/expression_helper.py
parentc127e17a303a84e1b0ad745c44cffd2f76ee202d (diff)
downloadfocaccia-miasm-9ada5b417a2b92aa855791fb2d4c3e282c2dcb2e.tar.gz
focaccia-miasm-9ada5b417a2b92aa855791fb2d4c3e282c2dcb2e.zip
expression: clean white space
Diffstat (limited to 'miasm/expression/expression_helper.py')
-rw-r--r--miasm/expression/expression_helper.py96
1 files changed, 48 insertions, 48 deletions
diff --git a/miasm/expression/expression_helper.py b/miasm/expression/expression_helper.py
index 912250c3..324c1ca8 100644
--- a/miasm/expression/expression_helper.py
+++ b/miasm/expression/expression_helper.py
@@ -57,11 +57,11 @@ def merge_sliceto_slice(args):
     for a in args:
         if max_size == None or max_size < a.stop:
             max_size = a.stop
-        
-    
+
+
 
     #first simplify all num slices
-    
+
     final_sources = []
     sorted_s = []
     for x in sources_int.values():
@@ -79,7 +79,7 @@ def merge_sliceto_slice(args):
         while sorted_s:
             if sorted_s[-1][1].stop != start:
                 break
-            
+
             start = sorted_s[-1][1].start
 
             a = uint64((int(out.arg.arg) << (out.start - start )) + sorted_s[-1][1].arg.arg)
@@ -90,9 +90,9 @@ def merge_sliceto_slice(args):
         out_type = tab_size_int[max_size]
         out.arg.arg = out_type(out.arg.arg)
         final_sources.append((start, out))
-        
+
     final_sources_int = final_sources
-    
+
     #check if same sources have corresponding start/stop
     #is slice AND is sliceto
     simp_sources = []
@@ -110,27 +110,27 @@ def merge_sliceto_slice(args):
                     break
                 if sorted_s[-1][1].arg.stop != out.arg.start:
                     break
-                
+
                 start = sorted_s[-1][1].start
                 out.arg.start = sorted_s[-1][1].arg.start
                 sorted_s.pop()
             out.start = start
 
             final_sources.append((start, out))
-        
+
         simp_sources+=final_sources
 
     simp_sources+= final_sources_int
 
     for i, v in non_slice.items():
         simp_sources.append((i, v))
-    
+
     simp_sources.sort()
-    
+
     simp_sources = [x[1] for x in simp_sources]
     return simp_sources
-    
-    
+
+
 def expr_simp(e):
     if e.is_simp:
         return e
@@ -156,7 +156,7 @@ def expr_simp_w(e):
                 return expr_simp(e.src2)
             else:
                 return expr_simp(e.src1)
-                
+
         return ExprCond(expr_simp(e.cond), expr_simp(e.src1), expr_simp(e.src2))
     elif isinstance(e, ExprMem):
         if isinstance(e.arg, ExprTop):
@@ -209,12 +209,12 @@ def expr_simp_w(e):
             if isinstance(args[1], ExprInt) and args[1].arg == 0:
                 return args[1]
 
-        #A-(-123) =>A+123    
+        #A-(-123) =>A+123
         if op == '-' and isinstance(args[1], ExprInt) and int32(args[1].arg)<0 :
             op = '+'
             args[1] = ExprInt(-args[1].arg)
 
-        #A+(-123) =>A-123    
+        #A+(-123) =>A-123
         if op == '+' and isinstance(args[1], ExprInt) and int32(args[1].arg)<0 :
             op = '-'
             args[1] = ExprInt(-args[1].arg)
@@ -229,8 +229,8 @@ def expr_simp_w(e):
             else:
                 op = op2
                 args1 = args[0].args[1].arg - args[1].arg
-                    
-                
+
+
                 #if op == '-':
                 #    args1 = -args1
             args0 = args[0].args[0]
@@ -245,7 +245,7 @@ def expr_simp_w(e):
         #0 - (a-b) => b-a
         if op == '-' and isinstance(args[0], ExprInt) and args[0].arg == 0 and isinstance(args[1], ExprOp) and args[1].op == "-":
             return expr_simp(args[1].args[1] - args[1].args[0])
-            
+
         #a<<< x <<< y => a <<< (x+y) (ou <<< >>>)
         if op in ['<<<', '>>>'] and isinstance(args[1], ExprInt) and isinstance(args[0], ExprOp) and args[0].op in ['<<<', '>>>'] and isinstance(args[0].args[1], ExprInt):
             op1 = op
@@ -256,7 +256,7 @@ def expr_simp_w(e):
             else:
                 op = op2
                 args1 = args[0].args[1].arg - args[1].arg
-                    
+
             args0 = args[0].args[0]
             args = [args0, ExprInt(args1)]
 
@@ -270,10 +270,10 @@ def expr_simp_w(e):
         if op in ['<<<', '>>>'] and isinstance(args[0], ExprOp) and args[0].op in ['<<<', '>>>'] and args[1] == args[0].args[1]:
             oo = op, args[0].op
             if oo in [('<<<', '>>>'), ('>>>', '<<<')]:
-                
+
                 e = expr_simp(args[0].args[0])
                 return e
-                
+
 
         #( a + int1 ) - (b+int2) => a - (b+ (int1-int2))
         if op in ['+', '-'] and isinstance(args[0], ExprOp) and args[0].op in ['+', '-'] and isinstance(args[1], ExprOp) and args[1].op in ['+', '-'] and isinstance(args[0].args[1], ExprInt) and isinstance(args[1].args[1], ExprInt):
@@ -296,7 +296,7 @@ def expr_simp_w(e):
                               )
                        )
             e = expr_simp(e)
-            
+
             return e
 
         #(a - (a + XXX)) => 0-XXX
@@ -311,7 +311,7 @@ def expr_simp_w(e):
                        z,
                        args[1].args[1])
             e = expr_simp(e)
-            
+
             return e
 
 
@@ -324,7 +324,7 @@ def expr_simp_w(e):
                        z,
                        args[0].args[1])
             e = expr_simp(e)
-            
+
             return e
 
         #  ((a ^ b) ^ a) => b (or commut)
@@ -364,11 +364,11 @@ def expr_simp_w(e):
                 rest_a = args[0].args[0]
                 e = expr_simp(rest_a)
                 return e
-        
+
         # a<<< a.size => a
         if op in ['<<<', '>>>'] and isinstance(args[1], ExprInt) and args[1].arg == args[0].get_size():
             return expr_simp(args[0])
-        
+
         #!!a => a
         if op == '!' and isinstance(args[0], ExprOp) and args[0].op == '!':
             new_e = args[0].args[0]
@@ -393,11 +393,11 @@ def expr_simp_w(e):
                        ,
                        args[0].args[1])
             return expr_simp(e)
-        
-        
+
+
         if op == "&" and isinstance(args[0], ExprOp) and args[0].op == '!' and isinstance(args[1], ExprOp) and args[1].op == '!' and isinstance(args[0].args[0], ExprOp) and args[0].args[0].op == '&' and isinstance(args[1].args[0], ExprOp) and args[1].args[0].op == '&':
 
-            ##############1 
+            ##############1
             a1 = args[0].args[0].args[0]
             if isinstance(a1, ExprOp) and a1.op == '!':
                 a1 = a1.args[0]
@@ -413,7 +413,7 @@ def expr_simp_w(e):
                 b1 = ExprInt(~b1.arg)
             else:
                 b1 = None
-    
+
 
             a2 = args[1].args[0].args[0]
             b2 = args[1].args[0].args[1]
@@ -439,7 +439,7 @@ def expr_simp_w(e):
                 b1 = ExprInt(~b1.arg)
             else:
                 b1 = None
-    
+
 
             a2 = args[0].args[0].args[0]
             b2 = args[0].args[0].args[1]
@@ -448,7 +448,7 @@ def expr_simp_w(e):
             if a1 != None and b1 != None and a1 == a2 and b1 == b2:
                 new_e = ExprOp('^', a1, b1)
                 return expr_simp(new_e)
-        
+
 
         # (x & mask) >> shift whith mask < 2**shift => 0
         if op == ">>" and isinstance(args[1], ExprInt) and isinstance(args[0], ExprOp) and args[0].op == "&":
@@ -465,13 +465,13 @@ def expr_simp_w(e):
             new_e = ExprSlice(ExprOp('!', args[0].arg), args[0].start, args[0].stop)
             return expr_simp(new_e)
 
-        
+
         #! int
         if op == '!' and isinstance(args[0], ExprInt):
             a = args[0]
             e = ExprInt(tab_max_uint[a.get_size()]^a.arg)
             return e
-        
+
         #a^a=>0 | a-a =>0
         if op in ['^', '-'] and args[0] == args[1]:
             tmp =  ExprInt(tab_size_int[args[0].get_size()](0))
@@ -491,11 +491,11 @@ def expr_simp_w(e):
             if isinstance(args[0], ExprOp) and args[0].op == '|' and isinstance(args[0].args[1], ExprInt) and \
                args[0].args[1].arg != 0:
                 return ExprInt(tab_size_int[args[0].get_size()](0))
-                                     
+
 
         if op == 'parity' and isinstance(args[0], ExprInt):
             return ExprInt(tab_size_int[args[0].get_size()](parity(args[0].arg)))
-        
+
         new_e = ExprOp(op, *[expr_simp(x) for x in args])
         if new_e == e:
             return new_e
@@ -521,7 +521,7 @@ def expr_simp_w(e):
         elif isinstance(arg, ExprSlice):
             if e.stop-e.start > arg.stop-arg.start:
                 raise ValueError('slice in slice: getting more val', str(e))
-            
+
             new_e = ExprSlice(expr_simp(arg.arg), e.start + arg.start, e.start + arg.start + (e.stop - e.start))
             return expr_simp(new_e)
         elif isinstance(arg, ExprCompose):
@@ -545,7 +545,7 @@ def expr_simp_w(e):
 
 
 
-        
+
         return ExprSlice(arg, e.start, e.stop)
     elif isinstance(e, ExprSliceTo):
         if isinstance(e.arg, ExprTop):
@@ -561,7 +561,7 @@ def expr_simp_w(e):
                     return expr_simp(ExprSliceTo(ExprCompose([a]), e.start, e.stop))
 
 
-            
+
         return ExprSliceTo(expr_simp(e.arg), e.start, e.stop)
     elif isinstance(e, ExprCompose):
         #(.., a_to[x:y], a[:]_to[y:z], ..) => (.., a[x:z], ..)
@@ -591,9 +591,9 @@ def expr_simp_w(e):
 
         if simp:
             return expr_simp(ExprCompose(args))
-            
-            
-        
+
+
+
         all_top = True
         for a in e.args:
             if not isinstance(a, ExprTop):
@@ -605,7 +605,7 @@ def expr_simp_w(e):
         if ExprTop() in e.args:
             return ExprTop()
         """
-        
+
         args = merge_sliceto_slice(e.args)
         if len(args) == 1:
             a = args[0]
@@ -614,14 +614,14 @@ def expr_simp_w(e):
                     print a, a.arg.get_size(), a.stop
                     raise ValueError("cast in compose!", e)
                 return a.arg
-            
+
             uu = expr_simp(a.arg)
             return uu
         if len(args) != len(e.args):
             return expr_simp(ExprCompose(args))
         else:
             return ExprCompose(args)
-    
+
     else:
         raise 'bad expr'
 
@@ -653,6 +653,6 @@ def expr_replace(e, repl):
         return ExprCompose([expr_replace(x, repl) for x in e.args])
     else:
         raise 'bad expr'
-    
-    
-    
+
+
+