1 19 20 package soot.dava.internal.AST; 21 22 import soot.*; 23 import soot.dava.*; 24 import soot.dava.toolkits.base.AST.analysis.*; 25 26 public class ASTAndCondition extends ASTAggregatedCondition{ 27 28 public ASTAndCondition(ASTCondition left, ASTCondition right){ 29 super(left,right); 30 } 31 32 public void apply(Analysis a){ 33 a.caseASTAndCondition(this); 34 } 35 36 public String toString(){ 37 if(left instanceof ASTUnaryBinaryCondition){ 38 if(right instanceof ASTUnaryBinaryCondition){ 39 if(not) 40 return "!("+ left.toString() + " && "+ right.toString()+")"; 41 else 42 return left.toString() + " && "+ right.toString(); 43 } 44 else{ if(not) 46 return "!("+left.toString() + " && ("+right.toString() +" ))"; 47 else 48 return left.toString() + " && ("+right.toString() +" )"; 49 } 50 } 51 else{ if(right instanceof ASTUnaryBinaryCondition){ 53 if(not) 54 return "!(( "+left.toString() + ") && "+ right.toString()+")"; 55 else 56 return "( "+left.toString() + ") && "+ right.toString(); 57 } 58 else{ if(not) 60 return "!(( "+left.toString() + ") && ("+right.toString() +" ))"; 61 else 62 return "( "+left.toString() + ") && ("+right.toString() +" )"; 63 } 64 } 65 } 66 67 public void toString(UnitPrinter up){ 68 if(up instanceof DavaUnitPrinter){ 69 70 if(not){ 71 ((DavaUnitPrinter)up).addNot(); 73 ((DavaUnitPrinter)up).addLeftParen(); 75 } 76 77 if(left instanceof ASTUnaryBinaryCondition){ 78 if(right instanceof ASTUnaryBinaryCondition){ 79 80 left.toString(up); 81 82 ((DavaUnitPrinter)up).addAggregatedAnd(); 83 84 right.toString(up); 85 } 86 else{ 88 left.toString(up); 89 90 ((DavaUnitPrinter)up).addAggregatedAnd(); 91 92 ((DavaUnitPrinter)up).addLeftParen(); 93 right.toString(up); 94 ((DavaUnitPrinter)up).addRightParen(); 95 } 96 } 97 else{ if(right instanceof ASTUnaryBinaryCondition){ 99 100 ((DavaUnitPrinter)up).addLeftParen(); 101 left.toString(up); 102 ((DavaUnitPrinter)up).addRightParen(); 103 104 ((DavaUnitPrinter)up).addAggregatedAnd(); 105 106 right.toString(up); 107 } 108 else{ 110 ((DavaUnitPrinter)up).addLeftParen(); 111 left.toString(up); 112 ((DavaUnitPrinter)up).addRightParen(); 113 114 ((DavaUnitPrinter)up).addAggregatedAnd(); 115 116 ((DavaUnitPrinter)up).addLeftParen(); 117 right.toString(up); 118 ((DavaUnitPrinter)up).addRightParen(); 119 } 120 } 121 122 if(not){ 123 ((DavaUnitPrinter)up).addRightParen(); 125 } 126 } 127 else 128 throw new RuntimeException (); 129 } 130 131 } 132 | Popular Tags |