1 package com.icl.saxon.expr; 2 import com.icl.saxon.*; 3 4 import java.util.*; 5 6 9 10 abstract class BinaryExpression extends Expression { 11 12 protected Expression p1, p2; 13 protected int operator; 15 18 19 public BinaryExpression() {} 20 21 27 28 public BinaryExpression(Expression p1, int op, Expression p2) { 29 this.p1 = p1; 30 this.p2 = p2; 31 this.operator = op; 32 } 33 34 40 41 public void setDetails(Expression p1, int op, Expression p2) { 42 this.p1 = p1; 43 this.p2 = p2; 44 this.operator = op; 45 } 46 47 51 52 public Expression simplify() throws XPathException { 53 p1 = p1.simplify(); 54 p2 = p2.simplify(); 55 56 if ((p1 instanceof Value) && (p2 instanceof Value)) { 58 return evaluate(null); 59 } 60 return this; 61 } 62 63 68 69 public int getDependencies() { 70 return p1.getDependencies() | p2.getDependencies(); 71 } 72 73 76 77 public void display(int level) { 78 System.err.println(indent(level) + Tokenizer.tokens[operator]); 79 p1.display(level+1); 80 p2.display(level+1); 81 } 82 83 } 84 85 | Popular Tags |