Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Function to resolve BoolExpr recursively, returning all arguments of the given
- * expression in the form of reg-value pairs
- * @return HashMap of [Register | constraint_value] pairs
- * */
- public HashMap getRegisterConstraintPairs(BoolExpr expr){
- HashMap constraintArgs=new HashMap();
- getInvdividualConsArgsHelper(expr,constraintArgs);
- return constraintArgs;
- }
- private void getInvdividualConsArgsHelper(Expr expr, HashMap constraintArgs){
- try {
- if(expr.getNumArgs()<=1) return;
- //if this expression has less than 2 arguments then it must be a part of reg-value pair,
- //meaning we have gone deeper than we should, so we return to add its super expression
- if(expr.getArgs()[0].getNumArgs()<2)
- //if this expression is in the form of [register | value] pair, we add it as a key-value pair
- {
- constraintArgs.put(expr.getArgs()[0], expr.getArgs()[1]);
- return;
- }
- for(int i=0 ; i<expr.getArgs().length; ++i){
- //for all sub expressions in this argument, apply same rule
- getInvdividualConsArgsHelper(expr.getArgs()[i],constraintArgs);
- }
- }catch (Z3Exception e){
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement