[Mathlib-commitlog] SF.net SVN: mathlib:[722] JMathLib/trunk/src/jmathlib/toolbox/io
Status: Beta
Brought to you by:
st_mueller
|
From: <st_...@us...> - 2009-01-23 12:59:06
|
Revision: 722
http://mathlib.svn.sourceforge.net/mathlib/?rev=722&view=rev
Author: st_mueller
Date: 2009-01-23 12:58:57 +0000 (Fri, 23 Jan 2009)
Log Message:
-----------
changed signature of evaluate(Token[] operands)
to
evaluate(Token[] operands, GlobalValues globals)
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/toolbox/io/cd.java
JMathLib/trunk/src/jmathlib/toolbox/io/createnewfile.java
JMathLib/trunk/src/jmathlib/toolbox/io/csvread.java
JMathLib/trunk/src/jmathlib/toolbox/io/csvwrite.java
JMathLib/trunk/src/jmathlib/toolbox/io/delete.java
JMathLib/trunk/src/jmathlib/toolbox/io/dir.java
JMathLib/trunk/src/jmathlib/toolbox/io/exist.java
JMathLib/trunk/src/jmathlib/toolbox/io/isdirectory.java
JMathLib/trunk/src/jmathlib/toolbox/io/isfile.java
JMathLib/trunk/src/jmathlib/toolbox/io/ishidden.java
JMathLib/trunk/src/jmathlib/toolbox/io/lastmodified.java
JMathLib/trunk/src/jmathlib/toolbox/io/load.java
JMathLib/trunk/src/jmathlib/toolbox/io/loadvariables.java
JMathLib/trunk/src/jmathlib/toolbox/io/mkdir.java
JMathLib/trunk/src/jmathlib/toolbox/io/pwd.java
JMathLib/trunk/src/jmathlib/toolbox/io/rmdir.java
JMathLib/trunk/src/jmathlib/toolbox/io/runfile.java
JMathLib/trunk/src/jmathlib/toolbox/io/savevariables.java
JMathLib/trunk/src/jmathlib/toolbox/io/systemcommand.java
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/cd.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/cd.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/cd.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -3,6 +3,7 @@
import jmathlib.core.tokens.*;
import jmathlib.core.functions.ExternalFunction;
import jmathlib.core.interpreter.*;
+
import java.io.*;
/**An external function for changing to another directory */
@@ -12,7 +13,7 @@
/* @param operands[0] string which specifies the directory *
* to change to (optional). *
* If invoked with now paramenter the current directory is returned. */
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
String path=".";
@@ -34,18 +35,18 @@
try
{
- File dir = new File(getWorkingDirectory(), path);
+ File dir = new File(globals.getWorkingDirectory(), path);
//getInterpreter().displayText("canonical path = "+dir.getCanonicalPath());
if (dir.isDirectory())
{
- setWorkingDirectory(dir);
+ globals.setWorkingDirectory(dir);
if (getNoOfLeftHandArguments()==1)
return new CharToken(dir.getCanonicalPath());
else
- getInterpreter().displayText(dir.getCanonicalPath());
+ globals.getInterpreter().displayText(dir.getCanonicalPath());
}
}
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/createnewfile.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/createnewfile.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/createnewfile.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -2,11 +2,13 @@
import jmathlib.core.tokens.*;
import jmathlib.core.functions.ExternalFunction;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.io.*;
public class createnewfile extends ExternalFunction
{
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
if (getNArgIn(operands) != 1)
@@ -21,7 +23,7 @@
try
{
- file = new File(getWorkingDirectory(),name);
+ file = new File(globals.getWorkingDirectory(),name);
if(!file.createNewFile())
throwMathLibException("create new file: did not work");
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/csvread.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/csvread.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/csvread.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -7,6 +7,8 @@
import jmathlib.core.functions.ExternalFunction;
import jmathlib.core.interpreter.ErrorLogger;
import jmathlib.core.interpreter.Errors;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.io.*;
import java.util.Stack;
@@ -20,7 +22,7 @@
@param operands[2] = the start column (optional)
@param operands[3] = range(optional, not implemented)
@return the matrix as an OperandToken*/
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
DoubleNumberToken result = null;
@@ -32,7 +34,7 @@
{
String fileName = ((CharToken)operands[0]).toString();
- File CSVFile = new File(getWorkingDirectory(), fileName);
+ File CSVFile = new File(globals.getWorkingDirectory(), fileName);
if(!CSVFile.exists()) return null;
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/csvwrite.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/csvwrite.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/csvwrite.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -7,6 +7,8 @@
import jmathlib.core.functions.ExternalFunction;
import jmathlib.core.interpreter.ErrorLogger;
import jmathlib.core.interpreter.Errors;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.io.*;
/**An external function for loading a matrix from a csv file*/
@@ -18,7 +20,7 @@
@param operands[1] = the matrix to save
@param operands[2] = the start row (optional)
@param operands[3] = the start column (optional)*/
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
// at least one operand
if (getNArgIn(operands) != 2)
@@ -31,7 +33,7 @@
double[][] values = ((DoubleNumberToken)operands[1]).getReValues();
String fileName = ((CharToken)operands[0]).toString();
- File CSVFile = new File(getWorkingDirectory(), fileName);
+ File CSVFile = new File(globals.getWorkingDirectory(), fileName);
ErrorLogger.debugLine("Writing CSV>"+fileName+"<");
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/delete.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/delete.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/delete.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -2,11 +2,13 @@
import jmathlib.core.tokens.*;
import jmathlib.core.functions.ExternalFunction;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.io.*;
public class delete extends ExternalFunction
{
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
if (getNArgIn(operands) != 1)
@@ -21,7 +23,7 @@
try
{
- file = new File(getWorkingDirectory(),name);
+ file = new File(globals.getWorkingDirectory(),name);
}
catch (Exception e)
{
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/dir.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/dir.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/dir.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -2,12 +2,14 @@
import jmathlib.core.tokens.*;
import jmathlib.core.functions.ExternalFunction;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.io.*;
/**An external function for getting a directory listing */
public class dir extends ExternalFunction
{
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
if (getNArgIn(operands) != 0)
@@ -15,7 +17,7 @@
String path=".";
- File dir = new File(getWorkingDirectory(), path);
+ File dir = new File(globals.getWorkingDirectory(), path);
String[] files = dir.list();
@@ -25,9 +27,9 @@
String name = files[i];
File f = new File(name);
if (f.isDirectory())
- getInterpreter().displayText(files[i]+"/");
+ globals.getInterpreter().displayText(files[i]+"/");
else
- getInterpreter().displayText(files[i]);
+ globals.getInterpreter().displayText(files[i]);
}
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/exist.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/exist.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/exist.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -4,6 +4,8 @@
import jmathlib.core.tokens.OperandToken;
import jmathlib.core.tokens.numbertokens.DoubleNumberToken;
import jmathlib.core.functions.ExternalFunction;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.io.*;
/**An external function used to check if a file exists*/
@@ -12,7 +14,7 @@
/**Check if file exists
@param 0 = filename
@return 1 if the file exists*/
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
// at least one operand
@@ -26,7 +28,7 @@
testFile = new File(fileName);
else
{
- File path = getWorkingDirectory();
+ File path = globals.getWorkingDirectory();
testFile = new File(path, fileName);
}
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/isdirectory.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/isdirectory.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/isdirectory.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -3,11 +3,13 @@
import jmathlib.core.tokens.*;
import jmathlib.core.tokens.numbertokens.DoubleNumberToken;
import jmathlib.core.functions.ExternalFunction;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.io.*;
public class isdirectory extends ExternalFunction
{
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
if (getNArgIn(operands) != 1)
@@ -20,7 +22,7 @@
try
{
- File dir = new File(getWorkingDirectory(),name);
+ File dir = new File(globals.getWorkingDirectory(),name);
if (dir.isDirectory())
return new DoubleNumberToken(1);
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/isfile.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/isfile.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/isfile.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -3,12 +3,13 @@
import jmathlib.core.tokens.*;
import jmathlib.core.tokens.numbertokens.DoubleNumberToken;
import jmathlib.core.functions.ExternalFunction;
+import jmathlib.core.interpreter.GlobalValues;
import java.io.*;
public class isfile extends ExternalFunction
{
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
if (getNArgIn(operands) != 1)
@@ -21,7 +22,7 @@
try
{
- File file = new File(getWorkingDirectory(), name);
+ File file = new File(globals.getWorkingDirectory(), name);
if (file.isFile())
return new DoubleNumberToken(1);
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/ishidden.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/ishidden.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/ishidden.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -3,11 +3,13 @@
import jmathlib.core.tokens.*;
import jmathlib.core.tokens.numbertokens.DoubleNumberToken;
import jmathlib.core.functions.ExternalFunction;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.io.*;
public class ishidden extends ExternalFunction
{
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
if (getNArgIn(operands) != 1)
@@ -20,7 +22,7 @@
try
{
- File file = new File(getWorkingDirectory(), name);
+ File file = new File(globals.getWorkingDirectory(), name);
if (!file.exists())
throwMathLibException("ishidden: file does not exist");
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/lastmodified.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/lastmodified.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/lastmodified.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -3,11 +3,13 @@
import jmathlib.core.tokens.*;
import jmathlib.core.tokens.numbertokens.DoubleNumberToken;
import jmathlib.core.functions.ExternalFunction;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.io.*;
public class lastmodified extends ExternalFunction
{
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
if (getNArgIn(operands) != 1)
@@ -20,7 +22,7 @@
try
{
- File file = new File(getWorkingDirectory(), name);
+ File file = new File(globals.getWorkingDirectory(), name);
// check if file exists in current workspace
if (!file.exists())
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/load.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/load.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/load.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -5,6 +5,8 @@
import jmathlib.core.tokens.numbertokens.DoubleNumberToken;
import jmathlib.core.functions.ExternalFunction;
import jmathlib.core.interpreter.ErrorLogger;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.io.*;
/**An external function for loading a matrix from a csv file*/
@@ -68,7 +70,7 @@
@param operands[2] = the start column (optional)
@param operands[3] = range(optional, not implemented)
@return the matrix as an OperandToken*/
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
OperandToken result = null;
@@ -80,8 +82,8 @@
// fileName = ((StringToken)operands[0]).toString();
//}
- System.out.println("load dir "+getWorkingDirectory() );
- File fileHandle = new File(getWorkingDirectory(), fileName);
+ System.out.println("load dir "+globals.getWorkingDirectory() );
+ File fileHandle = new File(globals.getWorkingDirectory(), fileName);
if(!fileHandle.exists())
throwMathLibException("load file does not exist");
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/loadvariables.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/loadvariables.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/loadvariables.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -2,11 +2,13 @@
import jmathlib.core.tokens.*;
import jmathlib.core.functions.ExternalFunction;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.io.*;
public class loadvariables extends ExternalFunction
{
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
if (getNArgIn(operands) > 1)
@@ -23,7 +25,7 @@
file = ((CharToken)operands[0]).toString();
}
- getLocalVariables().loadVariables(file);
+ globals.getLocalVariables().loadVariables(file);
return null;
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/mkdir.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/mkdir.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/mkdir.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -2,11 +2,13 @@
import jmathlib.core.tokens.*;
import jmathlib.core.functions.ExternalFunction;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.io.*;
public class mkdir extends ExternalFunction
{
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
if (getNArgIn(operands) != 1)
@@ -20,7 +22,7 @@
File file=null;
try
{
- file = new File(getWorkingDirectory(),name);
+ file = new File(globals.getWorkingDirectory(),name);
}
catch (Exception e)
{
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/pwd.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/pwd.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/pwd.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -3,14 +3,16 @@
import jmathlib.core.tokens.*;
import jmathlib.core.tokens.numbertokens.DoubleNumberToken;
import jmathlib.core.functions.ExternalFunction;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.io.*;
public class pwd extends ExternalFunction
{
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
- File f = getWorkingDirectory();
+ File f = globals.getWorkingDirectory();
return new CharToken(f.getAbsolutePath());
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/rmdir.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/rmdir.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/rmdir.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -2,12 +2,14 @@
import jmathlib.core.tokens.*;
import jmathlib.core.functions.ExternalFunction;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.io.*;
/**An external function for changing to another directory */
public class rmdir extends ExternalFunction
{
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
if (getNArgIn(operands) != 1)
@@ -22,7 +24,7 @@
try
{
- file = new File(getWorkingDirectory(),name);
+ file = new File(globals.getWorkingDirectory(),name);
}
catch (Exception e)
{
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/runfile.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/runfile.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/runfile.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -5,6 +5,8 @@
import jmathlib.core.tokens.CharToken;
import jmathlib.core.functions.ExternalFunction;
import jmathlib.core.interpreter.ErrorLogger;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.io.*;
/**An external function for loading and running m-files (script-files) *
@@ -14,7 +16,7 @@
/** Check that the operand is a string then open the file *
* referenced. *
* @param operands[0] string which specifies the function to load */
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
String answerString="";
@@ -36,7 +38,7 @@
if(fileName.indexOf(".m") == -1) fileName += ".m";
- File scriptFile = new File(getWorkingDirectory(), fileName);
+ File scriptFile = new File(globals.getWorkingDirectory(), fileName);
if(!scriptFile.exists()) return null;
@@ -54,7 +56,7 @@
inReader.close();
//execute the file and store the answer
- answerString = getInterpreter().executeExpression(lineFile);
+ answerString = globals.getInterpreter().executeExpression(lineFile);
}
catch (Exception e)
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/savevariables.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/savevariables.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/savevariables.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -2,11 +2,13 @@
import jmathlib.core.tokens.*;
import jmathlib.core.functions.ExternalFunction;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.io.*;
public class savevariables extends ExternalFunction
{
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
if (getNArgIn(operands) > 1)
@@ -23,7 +25,7 @@
file = ((CharToken)operands[0]).toString();
}
- getLocalVariables().saveVariables(file);
+ globals.getLocalVariables().saveVariables(file);
return null;
Modified: JMathLib/trunk/src/jmathlib/toolbox/io/systemcommand.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/io/systemcommand.java 2009-01-23 12:50:35 UTC (rev 721)
+++ JMathLib/trunk/src/jmathlib/toolbox/io/systemcommand.java 2009-01-23 12:58:57 UTC (rev 722)
@@ -3,6 +3,8 @@
import jmathlib.core.tokens.Token;
import jmathlib.core.tokens.OperandToken;
import jmathlib.core.functions.ExternalFunction;
+import jmathlib.core.interpreter.GlobalValues;
+
import java.io.*;
/**An external function used to execute an external program
@@ -13,7 +15,7 @@
@param operands[0] = filename
@param operands[n] = arguments
@return 1*/
- public OperandToken evaluate(Token[] operands)
+ public OperandToken evaluate(Token[] operands, GlobalValues globals)
{
String[] cmdarray = new String[operands.length];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|