1 2 5 14 package org.jacorb.trading.constraint; 15 16 import java.io.*; 17 18 19 20 public class AddNode extends ExprNode 21 { 22 private ExprNode m_left; 23 private ExprNode m_right; 24 25 26 private AddNode() 27 { 28 } 29 30 31 public AddNode(ExprNode left, ExprNode right) 32 { 33 m_left = left; 34 m_right = right; 35 36 int id = ValueType.promote(left.getType().getId(), right.getType().getId()); 39 setType(new ValueType(id)); 40 } 41 42 43 public void print(PrintStream ps) 44 { 45 ps.println("AddNode: type = " + getType()); 46 ps.println("Left node:"); 47 m_left.print(ps); 48 ps.println("Right node:"); 49 m_right.print(ps); 50 } 51 52 53 public Value evaluate(PropertySource source) 54 throws MissingPropertyException 55 { 56 Value result = null; 57 58 int id = getType().getId(); 59 60 Value v, left, right; 61 v = m_left.evaluate(source); 62 left = v.convert(id); 63 v = m_right.evaluate(source); 64 right = v.convert(id); 65 66 result = left.plus(right); 67 68 return result; 69 } 70 } 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | Popular Tags |