[Mathlib-commitlog] SF.net SVN: mathlib:[715] JMathLib/trunk/src/jmathlib/toolbox/jmathlib/ system
Status: Beta
Brought to you by:
st_mueller
|
From: <st_...@us...> - 2009-01-21 19:38:36
|
Revision: 715
http://mathlib.svn.sourceforge.net/mathlib/?rev=715&view=rev
Author: st_mueller
Date: 2009-01-21 19:38:33 +0000 (Wed, 21 Jan 2009)
Log Message:
-----------
changed signature of evaluate(Token[] operands)
to
evaluate(Token[] operands, GlobalValues globals)
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/addpath.java
JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/checkforupdates.java
JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/createFunctionsList.java
JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/debug.java
JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/disp.java
JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/error.java
JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/foreach.java
Modified: JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/addpath.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/addpath.java 2009-01-21 19:37:16 UTC (rev 714)
+++ JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/addpath.java 2009-01-21 19:38:33 UTC (rev 715)
@@ -4,6 +4,7 @@
import jmathlib.core.functions.FileFunctionLoader;
import jmathlib.core.functions.FunctionLoader;
import jmathlib.core.functions.ExternalFunction;
+import jmathlib.core.interpreter.GlobalValues;
import jmathlib.core.tokens.Token;
import jmathlib.core.tokens.CharToken;
import jmathlib.core.tokens.OperandToken;
@@ -15,7 +16,7 @@
{
/**adds an item to the search path
@param operands[0] = item to add*/
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
if (getNArgIn(operands)!=1)
throwMathLibException("addpath: number of arguments != 1");
@@ -44,8 +45,8 @@
{
FunctionLoader loader = new FileFunctionLoader(new File(path), true);
if (!prepend)
- getFunctionManager().addFunctionLoader(loader);
- else getFunctionManager().addFunctionLoaderAt(0, loader);
+ globals.getFunctionManager().addFunctionLoader(loader);
+ else globals.getFunctionManager().addFunctionLoaderAt(0, loader);
}
}
Modified: JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/checkforupdates.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/checkforupdates.java 2009-01-21 19:37:16 UTC (rev 714)
+++ JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/checkforupdates.java 2009-01-21 19:38:33 UTC (rev 715)
@@ -2,6 +2,8 @@
import jmathlib.core.tokens.*;
import jmathlib.core.functions.ExternalFunction;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.net.*;
import java.util.*;
@@ -11,15 +13,19 @@
/**An external function for checking for updates over the network*/
public class checkforupdates extends ExternalFunction
{
- public OperandToken evaluate(Token[] operands)
+ GlobalValues globals = null;
+
+ public OperandToken evaluate(Token[] operands, GlobalValues _globals)
{
+
+ globals = _globals;
String s = "";
String lineFile = "";
String updateSiteS = "http://www.jmathlib.de/checkForUpdates/";
boolean silentB = false;
- s = getInterpreter().prefs.getLocalProperty("update.site.primary");
+ s = globals.getInterpreter().prefs.getLocalProperty("update.site.primary");
if (s != null)
updateSiteS = s;
@@ -37,22 +43,22 @@
else
{
updateSiteS = s;
- getInterpreter().displayText("Update Site "+updateSiteS);
+ globals.getInterpreter().displayText("Update Site "+updateSiteS);
}
}
}
if (!silentB)
- getInterpreter().displayText("Checking for Updates at "+updateSiteS);
+ globals.getInterpreter().displayText("Checking for Updates at "+updateSiteS);
- String[] lastUpdateS = getInterpreter().prefs.getLocalProperty("update.date.last").split("/");
+ String[] lastUpdateS = globals.getInterpreter().prefs.getLocalProperty("update.date.last").split("/");
int year = Integer.parseInt(lastUpdateS[0]);
int month = Integer.parseInt(lastUpdateS[1])-1;
int day = Integer.parseInt(lastUpdateS[2]);
//getInterpreter().displayText("check:"+year+"/"+month+"/"+day);
- int intervall = Integer.parseInt(getInterpreter().prefs.getLocalProperty("update.intervall"));
+ int intervall = Integer.parseInt(globals.getInterpreter().prefs.getLocalProperty("update.intervall"));
GregorianCalendar calFile = new GregorianCalendar(year,month,day);
GregorianCalendar calCur = new GregorianCalendar();
@@ -136,7 +142,7 @@
System.out.println("checkForUpdates: Properties error");
}
- String[] localVersionS = getInterpreter().prefs.getLocalProperty("jmathlib.version").replace("/",".").split("\\.");
+ String[] localVersionS = globals.getInterpreter().prefs.getLocalProperty("jmathlib.version").replace("/",".").split("\\.");
String[] webVersionS = props.getProperty("jmathlib.version").replace("/",".").split("\\.");
// build version number of local version
@@ -166,42 +172,42 @@
{
// set marker for next startup
- getInterpreter().prefs.setLocalProperty("update.newversionavailable","yes");
+ globals.getInterpreter().prefs.setLocalProperty("update.newversionavailable","yes");
s = props.getProperty("update.newversionavailable.message01");
if (s!=null)
{
- getInterpreter().prefs.setLocalProperty("update.newversionavailable.message01", s);
- getInterpreter().displayText(s);
+ globals.getInterpreter().prefs.setLocalProperty("update.newversionavailable.message01", s);
+ globals.getInterpreter().displayText(s);
}
else
- getInterpreter().displayText("There is a new version of JMathLib available");
+ globals.getInterpreter().displayText("There is a new version of JMathLib available");
s = props.getProperty("update.newversionavailable.message02");
if (s!=null)
{
- getInterpreter().prefs.setLocalProperty("update.newversionavailable.message02", s);
- getInterpreter().displayText(s);
+ globals.getInterpreter().prefs.setLocalProperty("update.newversionavailable.message02", s);
+ globals.getInterpreter().displayText(s);
}
}
else if (webVersion < localVersion)
{
- getInterpreter().displayText("Funny! The version of JMathLib on the web is older than your local version");
+ globals.getInterpreter().displayText("Funny! The version of JMathLib on the web is older than your local version");
}
else
{
if (!silentB)
{
- getInterpreter().displayText("The local version of JMathLib is up to date");
+ globals.getInterpreter().displayText("The local version of JMathLib is up to date");
s=props.getProperty("update.uptodate.message01");
if (s!=null)
- getInterpreter().displayText(s);
+ globals.getInterpreter().displayText(s);
s=props.getProperty("update.uptodate.message02");
if (s!=null)
- getInterpreter().displayText(s);
+ globals.getInterpreter().displayText(s);
}
}
@@ -213,23 +219,23 @@
String checkedDate = Integer.toString(cal.get(Calendar.YEAR)) + "/"
+ Integer.toString(cal.get(Calendar.MONTH)+1) + "/"
+ Integer.toString(cal.get(Calendar.DAY_OF_MONTH));
- getInterpreter().prefs.setLocalProperty("update.date.last", checkedDate);
+ globals.getInterpreter().prefs.setLocalProperty("update.date.last", checkedDate);
// update link to primary update-site
s= props.getProperty("update.site.primary");
if (s!=null)
- getInterpreter().prefs.setLocalProperty("update.site.primary",s);
+ globals.getInterpreter().prefs.setLocalProperty("update.site.primary",s);
// update link to backup update-site
s= props.getProperty("update.site.backup");
if (s!=null)
- getInterpreter().prefs.setLocalProperty("update.site.backup",s);
+ globals.getInterpreter().prefs.setLocalProperty("update.site.backup",s);
// update message of the day
s= props.getProperty("message.of.the.day");
if (s!=null)
- getInterpreter().prefs.setLocalProperty("message.of.the.day",s);
+ globals.getInterpreter().prefs.setLocalProperty("message.of.the.day",s);
}
Modified: JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/createFunctionsList.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/createFunctionsList.java 2009-01-21 19:37:16 UTC (rev 714)
+++ JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/createFunctionsList.java 2009-01-21 19:38:33 UTC (rev 715)
@@ -23,16 +23,16 @@
public class createFunctionsList extends ExternalFunction
{
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
Vector pathVector = new Vector();
// get all search paths from all file loaders
- for (int i=0;i<getFunctionManager().getFunctionLoaderCount();i++)
+ for (int i=0;i<globals.getFunctionManager().getFunctionLoaderCount();i++)
{
- FunctionLoader loader = getFunctionManager().getFunctionLoader(i);
+ FunctionLoader loader = globals.getFunctionManager().getFunctionLoader(i);
if (loader instanceof FileFunctionLoader)
{
@@ -52,13 +52,13 @@
String path = "";
String line = "";
- ErrorLogger.debugLine("working directory: "+getWorkingDirectory().getAbsolutePath());
+ ErrorLogger.debugLine("working directory: "+globals.getWorkingDirectory().getAbsolutePath());
try
{
// create file to store all class-, m-files and images
- File funcFile = new File(getWorkingDirectory().getAbsoluteFile() +
+ File funcFile = new File(globals.getWorkingDirectory().getAbsoluteFile() +
File.separator + "bin" +
File.separator + "jmathlib" +
File.separator + "webFunctionsList.dat");
@@ -101,7 +101,7 @@
!line.contains(".svn") )
{
// remove preceding absolute path
- line = line.substring((getWorkingDirectory().getAbsolutePath()+"/bin/").length());
+ line = line.substring((globals.getWorkingDirectory().getAbsolutePath()+"/bin/").length());
ErrorLogger.debugLine("path = "+ line);
Modified: JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/debug.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/debug.java 2009-01-21 19:37:16 UTC (rev 714)
+++ JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/debug.java 2009-01-21 19:38:33 UTC (rev 715)
@@ -12,7 +12,7 @@
/**Executes an expression, displaying the parse tree.
@param operand[0] = the string containing the expression
@return the result of the expression*/
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
String answer = "";
if(operands[0] instanceof CharToken)
@@ -26,7 +26,7 @@
// open a tree to show the expression-tree for a parsed command
jmathlib.tools.treeanalyser.TreeAnalyser treeAnalyser = new jmathlib.tools.treeanalyser.TreeAnalyser(expressionTree);
- OperandToken answerToken = expressionTree.evaluate(null);
+ OperandToken answerToken = expressionTree.evaluate(null, globals);
//while(answerToken != null)
//{
if(answerToken != null)
@@ -36,7 +36,7 @@
//if(answerToken.display)
// answer += answerToken.toString() + "\n";
- answerToken = expressionTree.evaluate(null);
+ answerToken = expressionTree.evaluate(null, globals);
}
//}
Modified: JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/disp.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/disp.java 2009-01-21 19:37:16 UTC (rev 714)
+++ JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/disp.java 2009-01-21 19:38:33 UTC (rev 715)
@@ -3,17 +3,18 @@
import jmathlib.core.tokens.Token;
import jmathlib.core.tokens.OperandToken;
import jmathlib.core.functions.ExternalFunction;
+import jmathlib.core.interpreter.GlobalValues;
/**An external function for writing to the main display*/
public class disp extends ExternalFunction
{
/**write operand to main display
@param operand[n] = items to display*/
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
for(int index = 0; index < operands.length; index++)
{
- getInterpreter().displayText(operands[index].toString());
+ globals.getInterpreter().displayText(operands[index].toString());
}
return null;
Modified: JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/error.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/error.java 2009-01-21 19:37:16 UTC (rev 714)
+++ JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/error.java 2009-01-21 19:38:33 UTC (rev 715)
@@ -5,6 +5,7 @@
import jmathlib.core.tokens.CharToken;
import jmathlib.core.functions.ExternalFunction;
import jmathlib.core.interpreter.Errors;
+import jmathlib.core.interpreter.GlobalValues;
/**An external function for displaying error messages
aborts the current function being processed*/
@@ -12,7 +13,7 @@
{
/**write operand to main display then abort processing
@param operand[n] = error messages to display*/
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
if(operands[0] instanceof CharToken)
{
Modified: JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/foreach.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/foreach.java 2009-01-21 19:37:16 UTC (rev 714)
+++ JMathLib/trunk/src/jmathlib/toolbox/jmathlib/system/foreach.java 2009-01-21 19:38:33 UTC (rev 715)
@@ -13,7 +13,7 @@
@param operand[1] = a string containing the variable name
@param operand[2] = a string containing the expression
@return 0 if there were any errors, otherwise it returns 1*/
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
int result = 0;
//check that the first operand is a matrix
@@ -27,7 +27,7 @@
if((operands[1] instanceof CharToken) && (operands[2] instanceof CharToken))
{
//create a variable with the correct name
- Variable var = createVariable(((CharToken)operands[1]).toString());
+ Variable var = globals.createVariable(((CharToken)operands[1]).toString());
String expression = ((CharToken)operands[2]).toString();
//parse the expression
@@ -44,7 +44,7 @@
OperandToken exp = ((OperandToken)expressionTree.clone());
- exp.evaluate(null);
+ exp.evaluate(null, globals);
}
}
result = 1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|