1 21 22 package org.apache.derby.impl.sql.compile; 23 24 import org.apache.derby.iapi.sql.dictionary.DataDictionary; 25 import org.apache.derby.iapi.services.sanity.SanityManager; 26 import org.apache.derby.iapi.error.StandardException; 27 28 import org.apache.derby.iapi.sql.compile.NodeFactory; 29 30 import org.apache.derby.iapi.types.BooleanDataValue; 31 32 import org.apache.derby.iapi.services.compiler.MethodBuilder; 33 34 import org.apache.derby.impl.sql.compile.ExpressionClassBuilder; 35 import org.apache.derby.impl.sql.compile.ActivationClassBuilder; 36 import org.apache.derby.iapi.reference.ClassName; 37 import org.apache.derby.iapi.services.classfile.VMOpcode; 38 39 import java.lang.reflect.Modifier ; 40 41 import java.util.Vector ; 42 43 public class IsNode extends BinaryLogicalOperatorNode 44 { 45 private boolean notMe; 47 54 55 public void init( 56 Object leftOperand, 57 Object rightOperand, 58 Object notMe ) 59 { 60 super.init(leftOperand, rightOperand, "is" ); 62 this.notMe = ((Boolean ) notMe).booleanValue(); 63 } 64 65 78 79 public ValueNode bindExpression( 80 FromList fromList, SubqueryList subqueryList, 81 Vector aggregateVector) 82 throws StandardException 83 { 84 super.bindExpression(fromList, subqueryList, aggregateVector); 85 86 leftOperand.checkIsBoolean(); 87 rightOperand.checkIsBoolean(); 88 89 setType(leftOperand.getTypeServices()); 90 91 return this; 92 } 93 94 95 106 ValueNode eliminateNots(boolean underNotNode) 107 throws StandardException 108 { 109 if ( underNotNode ) { notMe = !notMe; } 110 111 leftOperand = leftOperand.eliminateNots( false); 112 rightOperand = rightOperand.eliminateNots( false ); 113 114 return this; 115 } 116 117 126 public ValueNode putAndsOnTop() 127 throws StandardException 128 { 129 leftOperand = leftOperand.putAndsOnTop(); 130 rightOperand = rightOperand.putAndsOnTop(); 131 132 return this; 133 } 134 135 141 public boolean verifyPutAndsOnTop() 142 { 143 return ( leftOperand.verifyPutAndsOnTop() && rightOperand.verifyPutAndsOnTop() ); 144 } 145 146 174 public ValueNode changeToCNF(boolean underTopAndNode) 175 throws StandardException 176 { 177 leftOperand = leftOperand.changeToCNF(false ); 178 rightOperand = rightOperand.changeToCNF(false ); 179 180 return this; 181 } 182 183 192 public boolean verifyChangeToCNF() 193 { 194 return ( leftOperand.verifyChangeToCNF() && rightOperand.verifyChangeToCNF() ); 195 } 196 197 198 206 207 public void generateExpression(ExpressionClassBuilder acb, 208 MethodBuilder mb) 209 throws StandardException 210 { 211 String evaluatorMethodName; 212 213 218 219 if ( notMe ) { evaluatorMethodName = "isNot"; } 220 else { evaluatorMethodName = "is"; } 221 222 leftOperand.generateExpression(acb, mb); 223 rightOperand.generateExpression(acb, mb); 224 mb.callMethod(VMOpcode.INVOKEINTERFACE, ClassName.BooleanDataValue, evaluatorMethodName, 225 ClassName.BooleanDataValue, 1); 226 } 227 } 228 | Popular Tags |