Advertisement
Guest User

Untitled

a guest
May 28th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1. /**
  2.      * Function to resolve BoolExpr recursively, returning all arguments of the given
  3.      * expression in the form of reg-value pairs
  4.      * @return HashMap of [Register | constraint_value] pairs
  5.      * */
  6.     public HashMap getRegisterConstraintPairs(BoolExpr expr){
  7.         HashMap constraintArgs=new HashMap();
  8.         getInvdividualConsArgsHelper(expr,constraintArgs);
  9.         return  constraintArgs;
  10.  
  11.     }
  12.  
  13.     private void getInvdividualConsArgsHelper(Expr expr, HashMap constraintArgs){
  14.         try {
  15.  
  16.             if(expr.getNumArgs()<=1) return;
  17.                 //if this expression has less than 2 arguments then it must be a part of reg-value pair,
  18.                 //meaning we have gone deeper than we should, so we return to add its super expression
  19.  
  20.             if(expr.getArgs()[0].getNumArgs()<2)
  21.                 //if this expression is in the form of [register | value] pair, we add it as a key-value pair
  22.             {
  23.                 constraintArgs.put(expr.getArgs()[0], expr.getArgs()[1]);
  24.                 return;
  25.             }
  26.  
  27.             for(int i=0 ; i<expr.getArgs().length; ++i){
  28.  
  29.                 //for all sub expressions in this argument, apply same rule
  30.                 getInvdividualConsArgsHelper(expr.getArgs()[i],constraintArgs);
  31.             }
  32.  
  33.         }catch (Z3Exception e){
  34.  
  35.             e.printStackTrace();
  36.         }
  37.  
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement