[Mathlib-commitlog] SF.net SVN: mathlib:[765] JMathLib/trunk/src/jmathlib/core/tokens/ UnaryOperato
Status: Beta
Brought to you by:
st_mueller
|
From: <st_...@us...> - 2009-01-24 20:23:00
|
Revision: 765
http://mathlib.svn.sourceforge.net/mathlib/?rev=765&view=rev
Author: st_mueller
Date: 2009-01-24 20:22:57 +0000 (Sat, 24 Jan 2009)
Log Message:
-----------
changed signature of evaluate(Token[] operands)
to
evaluate(Token[] operands, GlobalValues globals)
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/core/tokens/UnaryOperatorToken.java
Modified: JMathLib/trunk/src/jmathlib/core/tokens/UnaryOperatorToken.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/tokens/UnaryOperatorToken.java 2009-01-24 20:21:39 UTC (rev 764)
+++ JMathLib/trunk/src/jmathlib/core/tokens/UnaryOperatorToken.java 2009-01-24 20:22:57 UTC (rev 765)
@@ -8,7 +8,8 @@
public class UnaryOperatorToken extends OperatorToken
{
/**Constructor taking the operator and priority
- @param _operator = the operator being constructed */
+ * @param _operator = the operator being constructed
+ */
public UnaryOperatorToken(char _operator)
{
/**call the super constructor, type defaults to ttoperator and operands to 1*/
@@ -19,7 +20,7 @@
/**evaluate the operator
@param operands = the operator operands
@return the result as an OperandToken*/
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
OperandToken result = null;
@@ -51,7 +52,7 @@
if(operand instanceof VariableToken)
{
// first: evaluate and return original value variable
- result = operand.evaluate(null);
+ result = operand.evaluate(null, globals);
// second: decrease variable
OperandToken op = result.subtract(new DoubleNumberToken(1));
@@ -59,7 +60,7 @@
// save new variable value
String variable = ((VariableToken)operand).getName();
//getVariables().getVariable(variable).assign(op);
- getVariable(variable).assign(op);
+ globals.getVariable(variable).assign(op);
}
else if(operand instanceof NumberToken)
{
@@ -79,7 +80,7 @@
if(operand instanceof VariableToken)
{
// first: evaluate and return original value variable
- result = operand.evaluate(null);
+ result = operand.evaluate(null, globals);
// second: increase variable
OperandToken op = result.add(new DoubleNumberToken(1));
@@ -87,7 +88,7 @@
// save new variable value
String variable = ((VariableToken)operand).getName();
//getVariables().getVariable(variable).assign(op);
- getVariable(variable).assign(op);
+ globals.getVariable(variable).assign(op);
}
else if(operand instanceof NumberToken)
{
@@ -113,7 +114,9 @@
return result;
}
- /**@return the operator as a string*/
+ /**
+ * @return the operator as a string
+ */
public String toString()
{
if (value=='-')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|