1 9 package org.lsmp.djep.matrixJep.function; 10 11 import java.util.*; 12 import org.nfunk.jep.*; 13 import org.nfunk.jep.function.*; 14 import org.lsmp.djep.matrixJep.*; 15 import org.lsmp.djep.matrixJep.nodeTypes.*; 16 import org.lsmp.djep.vectorJep.values.*; 17 18 25 public class MAssign extends Assign implements MatrixSpecialEvaluationI 26 { 27 public MAssign() 28 { 29 numberOfParameters = 2; 30 } 31 32 35 public void run(Stack s) throws ParseException 36 { 37 throw new ParseException("Eval should not be called by Evaluator"); 38 } 39 40 46 public MatrixValueI evaluate(MatrixNodeI node,MatrixEvaluator visitor,MatrixJep j) throws ParseException 47 { 48 if(node.jjtGetNumChildren()!=2) 49 throw new ParseException("Assignment opperator must have 2 operators."); 50 51 53 MatrixValueI rhsVal = (MatrixValueI) node.jjtGetChild(1).jjtAccept(visitor,null); 54 55 Node lhsNode = node.jjtGetChild(0); 57 if(lhsNode instanceof ASTMVarNode) 58 { 59 ASTMVarNode vn = (ASTMVarNode) lhsNode; 60 MatrixVariableI var = (MatrixVariableI) vn.getVar(); 61 var.setMValue(rhsVal); 62 return rhsVal; 63 } 64 throw new ParseException("Assignment should have a variable for the lhs."); 65 } 66 } 67 | Popular Tags |