Static import of 'eval'
This commit is contained in:
parent
0c3d3ae024
commit
013707e11a
|
@ -1,8 +1,9 @@
|
|||
package function;
|
||||
|
||||
import static function.builtin.EVAL.eval;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import function.builtin.EVAL;
|
||||
import sexpression.*;
|
||||
import table.*;
|
||||
|
||||
|
@ -40,7 +41,7 @@ public class UserDefinedFunction extends LispFunction {
|
|||
SExpression lastEvaluation = Nil.getInstance();
|
||||
|
||||
for (Cons expression = body; expression.consp(); expression = (Cons) expression.getCdr())
|
||||
lastEvaluation = EVAL.eval(expression.getCar());
|
||||
lastEvaluation = eval(expression.getCar());
|
||||
|
||||
executionContext.setScope(callingScope);
|
||||
releaseParameterValues();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package function.builtin;
|
||||
|
||||
import static function.builtin.EVAL.eval;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
|
@ -59,7 +61,7 @@ public class LOAD extends LispFunction {
|
|||
private boolean isSuccessfulEvaluation(LispParser parser) {
|
||||
while (!parser.isEof()) {
|
||||
try {
|
||||
EVAL.eval(parser.getNextSExpression());
|
||||
eval(parser.getNextSExpression());
|
||||
} catch (LispException e) {
|
||||
errorManager.handle(e);
|
||||
return false;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package function.builtin.special;
|
||||
|
||||
import static function.builtin.EVAL.eval;
|
||||
|
||||
import function.*;
|
||||
import function.builtin.EVAL;
|
||||
import sexpression.*;
|
||||
|
||||
public class AND extends LispFunction {
|
||||
|
@ -19,7 +20,7 @@ public class AND extends LispFunction {
|
|||
}
|
||||
|
||||
private SExpression callTailRecursive(Cons argumentList, SExpression lastValue) {
|
||||
SExpression currentValue = EVAL.eval(argumentList.getCar());
|
||||
SExpression currentValue = eval(argumentList.getCar());
|
||||
Cons remainingValues = (Cons) argumentList.getCdr();
|
||||
|
||||
if (argumentList.nullp())
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package function.builtin.special;
|
||||
|
||||
import static function.builtin.EVAL.eval;
|
||||
|
||||
import function.*;
|
||||
import function.builtin.EVAL;
|
||||
import sexpression.*;
|
||||
|
||||
public class COND extends LispFunction {
|
||||
|
@ -26,7 +27,7 @@ public class COND extends LispFunction {
|
|||
|
||||
Cons clause = (Cons) argumentList.getCar();
|
||||
Cons remainingClauses = (Cons) argumentList.getCdr();
|
||||
SExpression test = EVAL.eval(clause.getCar());
|
||||
SExpression test = eval(clause.getCar());
|
||||
|
||||
if (isTestSuccessful(test))
|
||||
return evaluateResult(clause, test);
|
||||
|
@ -42,7 +43,7 @@ public class COND extends LispFunction {
|
|||
SExpression lastResultValue = test;
|
||||
|
||||
for (SExpression result = clause.getCdr(); result.consp(); result = advanceCons(result))
|
||||
lastResultValue = EVAL.eval(getCar(result));
|
||||
lastResultValue = eval(getCar(result));
|
||||
|
||||
return lastResultValue;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package function.builtin.special;
|
||||
|
||||
import static function.builtin.EVAL.eval;
|
||||
|
||||
import function.*;
|
||||
import function.builtin.EVAL;
|
||||
import sexpression.*;
|
||||
import table.*;
|
||||
|
||||
|
@ -65,14 +66,14 @@ public class LET extends LispFunction {
|
|||
SExpression symbol = symbolValuePair.getCar();
|
||||
SExpression value = restOfPair.getCar();
|
||||
|
||||
scope.put(symbol.toString(), EVAL.eval(value));
|
||||
scope.put(symbol.toString(), eval(value));
|
||||
}
|
||||
|
||||
private SExpression evaluateBody(Cons body) {
|
||||
SExpression lastEvaluation = Nil.getInstance();
|
||||
|
||||
for (; body.consp(); body = (Cons) body.getCdr())
|
||||
lastEvaluation = EVAL.eval(body.getCar());
|
||||
lastEvaluation = eval(body.getCar());
|
||||
|
||||
return lastEvaluation;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package function.builtin.special;
|
||||
|
||||
import static function.builtin.EVAL.eval;
|
||||
|
||||
import function.*;
|
||||
import function.builtin.EVAL;
|
||||
import sexpression.*;
|
||||
|
||||
public class OR extends LispFunction {
|
||||
|
@ -19,7 +20,7 @@ public class OR extends LispFunction {
|
|||
}
|
||||
|
||||
private SExpression callTailRecursive(Cons argumentList) {
|
||||
SExpression currentValue = EVAL.eval(argumentList.getCar());
|
||||
SExpression currentValue = eval(argumentList.getCar());
|
||||
Cons remainingValues = (Cons) argumentList.getCdr();
|
||||
|
||||
if (remainingValues.nullp() || !currentValue.nullp())
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package function.builtin.special;
|
||||
|
||||
import static function.builtin.EVAL.eval;
|
||||
|
||||
import function.*;
|
||||
import function.builtin.EVAL;
|
||||
import sexpression.*;
|
||||
import table.*;
|
||||
|
||||
|
@ -22,7 +23,7 @@ public class SETF extends LispFunction {
|
|||
|
||||
Cons cdr = (Cons) argumentList.getCdr();
|
||||
SExpression symbol = argumentList.getCar();
|
||||
SExpression value = EVAL.eval(cdr.getCar());
|
||||
SExpression value = eval(cdr.getCar());
|
||||
|
||||
SymbolTable table = findScopeOfSymbol(symbol);
|
||||
table.put(symbol.toString(), value);
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package interpreter;
|
||||
|
||||
import static function.builtin.EVAL.eval;
|
||||
|
||||
import environment.RuntimeEnvironment;
|
||||
import error.*;
|
||||
import function.builtin.EVAL;
|
||||
import parser.LispParser;
|
||||
import sexpression.SExpression;
|
||||
|
||||
|
@ -42,7 +43,7 @@ public class LispInterpreter {
|
|||
|
||||
private void printValueOfNextSExpressionWithException() {
|
||||
SExpression sExpression = parser.getNextSExpression();
|
||||
String result = environment.decorateValueOutput(String.valueOf(EVAL.eval(sExpression)));
|
||||
String result = environment.decorateValueOutput(String.valueOf(eval(sExpression)));
|
||||
|
||||
erasePrompt();
|
||||
environment.getOutput().println(result);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package testutil;
|
||||
|
||||
import static function.builtin.EVAL.eval;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import function.builtin.EVAL;
|
||||
import parser.LispParser;
|
||||
import sexpression.SExpression;
|
||||
|
||||
|
@ -24,7 +24,7 @@ public final class TestUtilities {
|
|||
}
|
||||
|
||||
public static SExpression evaluateString(String input) {
|
||||
return EVAL.eval(parseString(input));
|
||||
return eval(parseString(input));
|
||||
}
|
||||
|
||||
public static SExpression parseString(String input) {
|
||||
|
|
Loading…
Reference in New Issue