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 ASTOrCondition extends ASTAggregatedCondition{ 27 public ASTOrCondition(ASTCondition left, ASTCondition right){ 28 super(left,right); 29 } 30 31 public void apply(Analysis a){ 32 a.caseASTOrCondition(this); 33 } 34 35 public String toString(){ 36 if(left instanceof ASTUnaryBinaryCondition){ 37 if(right instanceof ASTUnaryBinaryCondition){ 38 if(not) 39 return "!(" + left.toString() + " || "+ right.toString()+")"; 40 else 41 return left.toString() + " || "+ right.toString(); 42 } 43 else{ if(not) 45 return "!("+left.toString() + " || ("+right.toString() +" ))"; 46 else 47 return left.toString() + " || ("+right.toString() +" )"; 48 } 49 } 50 else{ if(right instanceof ASTUnaryBinaryCondition){ 52 if(not) 53 return "!(( "+ left.toString() + ") || "+ right.toString()+")"; 54 else 55 return "( "+ left.toString() + ") || "+ right.toString(); 56 } 57 else{ if(not) 59 return "!(( "+left.toString() + ") || ("+right.toString() +" ))"; 60 else 61 return "( "+left.toString() + ") || ("+right.toString() +" )"; 62 } 63 } 64 } 65 66 public void toString(UnitPrinter up){ 67 if(up instanceof DavaUnitPrinter){ 68 69 if(not){ 70 ((DavaUnitPrinter)up).addNot(); 72 ((DavaUnitPrinter)up).addLeftParen(); 74 } 75 if(left instanceof ASTUnaryBinaryCondition){ 76 if(right instanceof ASTUnaryBinaryCondition){ 77 78 left.toString(up); 79 80 ((DavaUnitPrinter)up).addAggregatedOr(); 81 82 right.toString(up); 83 } 84 else{ 86 left.toString(up); 87 88 ((DavaUnitPrinter)up).addAggregatedOr(); 89 90 ((DavaUnitPrinter)up).addLeftParen(); 91 right.toString(up); 92 ((DavaUnitPrinter)up).addRightParen(); 93 } 94 } 95 else{ if(right instanceof ASTUnaryBinaryCondition){ 97 98 ((DavaUnitPrinter)up).addLeftParen(); 99 left.toString(up); 100 ((DavaUnitPrinter)up).addRightParen(); 101 102 ((DavaUnitPrinter)up).addAggregatedOr(); 103 104 right.toString(up); 105 } 106 else{ 108 ((DavaUnitPrinter)up).addLeftParen(); 109 left.toString(up); 110 ((DavaUnitPrinter)up).addRightParen(); 111 112 ((DavaUnitPrinter)up).addAggregatedOr(); 113 114 ((DavaUnitPrinter)up).addLeftParen(); 115 right.toString(up); 116 ((DavaUnitPrinter)up).addRightParen(); 117 } 118 } 119 if(not) 120 ((DavaUnitPrinter)up).addRightParen(); 121 } 122 else 123 throw new RuntimeException (); 124 } 125 126 } 127 | Popular Tags |