diff --git a/src/function/builtin/APPLY.java b/src/function/builtin/APPLY.java index 44fb6fe..fb61a41 100644 --- a/src/function/builtin/APPLY.java +++ b/src/function/builtin/APPLY.java @@ -15,8 +15,8 @@ public class APPLY extends LispFunction { return lookupFunction("APPLY").call(argumentList); } - public APPLY() { - this.argumentValidator = new ArgumentValidator("APPLY"); + public APPLY(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setExactNumberOfArguments(2); this.argumentValidator.setTrailingArgumentExpectedType(Cons.class); } diff --git a/src/function/builtin/EVAL.java b/src/function/builtin/EVAL.java index 5847f88..b2fbc79 100644 --- a/src/function/builtin/EVAL.java +++ b/src/function/builtin/EVAL.java @@ -53,8 +53,8 @@ public class EVAL extends LispFunction { private ArgumentValidator argumentValidator; - public EVAL() { - this.argumentValidator = new ArgumentValidator("EVAL"); + public EVAL(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setExactNumberOfArguments(1); } diff --git a/src/function/builtin/EXIT.java b/src/function/builtin/EXIT.java index 70f076e..322a459 100644 --- a/src/function/builtin/EXIT.java +++ b/src/function/builtin/EXIT.java @@ -12,8 +12,8 @@ public class EXIT extends LispFunction { private ArgumentValidator argumentValidator; private RuntimeEnvironment environment; - public EXIT() { - this.argumentValidator = new ArgumentValidator("EXIT"); + public EXIT(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setMaximumNumberOfArguments(0); this.environment = RuntimeEnvironment.getInstance(); } diff --git a/src/function/builtin/FUNCALL.java b/src/function/builtin/FUNCALL.java index 77cf373..50f9da9 100644 --- a/src/function/builtin/FUNCALL.java +++ b/src/function/builtin/FUNCALL.java @@ -11,8 +11,8 @@ public class FUNCALL extends LispFunction { private ArgumentValidator argumentValidator; - public FUNCALL() { - this.argumentValidator = new ArgumentValidator("FUNCALL"); + public FUNCALL(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setMinimumNumberOfArguments(1); } diff --git a/src/function/builtin/LOAD.java b/src/function/builtin/LOAD.java index 7a6a2d8..df5d71f 100644 --- a/src/function/builtin/LOAD.java +++ b/src/function/builtin/LOAD.java @@ -18,16 +18,15 @@ import sexpression.*; @FunctionNames({ "LOAD" }) public class LOAD extends LispFunction { + private static Stack pathPrefixes = new Stack<>(); private ArgumentValidator argumentValidator; private RuntimeEnvironment environment; - private Stack pathPrefixes; - public LOAD() { - this.argumentValidator = new ArgumentValidator("LOAD"); + public LOAD(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setExactNumberOfArguments(1); this.argumentValidator.setEveryArgumentExpectedType(LispString.class); this.environment = RuntimeEnvironment.getInstance(); - this.pathPrefixes = new Stack<>(); } public SExpression call(Cons argumentList) { diff --git a/src/function/builtin/PRINT.java b/src/function/builtin/PRINT.java index 63dd5a3..54e5c2d 100644 --- a/src/function/builtin/PRINT.java +++ b/src/function/builtin/PRINT.java @@ -10,8 +10,8 @@ public class PRINT extends LispFunction { private ArgumentValidator argumentValidator; private RuntimeEnvironment environment; - public PRINT() { - this.argumentValidator = new ArgumentValidator("PRINT"); + public PRINT(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setExactNumberOfArguments(1); this.environment = RuntimeEnvironment.getInstance(); } diff --git a/src/function/builtin/SET.java b/src/function/builtin/SET.java index 020faaf..7bbec2c 100644 --- a/src/function/builtin/SET.java +++ b/src/function/builtin/SET.java @@ -16,8 +16,8 @@ public class SET extends LispFunction { private ArgumentValidator argumentValidator; private ExecutionContext executionContext; - public SET() { - this.argumentValidator = new ArgumentValidator("SET"); + public SET(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setExactNumberOfArguments(2); this.argumentValidator.setFirstArgumentExpectedType(Symbol.class); this.executionContext = ExecutionContext.getInstance(); diff --git a/src/function/builtin/SYMBOL_FUNCTION.java b/src/function/builtin/SYMBOL_FUNCTION.java index 1c68f31..a4b4f4d 100644 --- a/src/function/builtin/SYMBOL_FUNCTION.java +++ b/src/function/builtin/SYMBOL_FUNCTION.java @@ -13,8 +13,8 @@ public class SYMBOL_FUNCTION extends LispFunction { private ArgumentValidator argumentValidator; - public SYMBOL_FUNCTION() { - this.argumentValidator = new ArgumentValidator("SYMBOL-FUNCTION"); + public SYMBOL_FUNCTION(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setExactNumberOfArguments(1); this.argumentValidator.setEveryArgumentExpectedType(Symbol.class); } diff --git a/src/function/builtin/cons/CONS.java b/src/function/builtin/cons/CONS.java index fdfc7f9..4d2582b 100644 --- a/src/function/builtin/cons/CONS.java +++ b/src/function/builtin/cons/CONS.java @@ -8,8 +8,8 @@ public class CONS extends LispFunction { private ArgumentValidator argumentValidator; - public CONS() { - this.argumentValidator = new ArgumentValidator("CONS"); + public CONS(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setExactNumberOfArguments(2); } diff --git a/src/function/builtin/cons/FIRST.java b/src/function/builtin/cons/FIRST.java index f956022..975293b 100644 --- a/src/function/builtin/cons/FIRST.java +++ b/src/function/builtin/cons/FIRST.java @@ -8,8 +8,8 @@ public class FIRST extends LispFunction { private ArgumentValidator argumentValidator; - public FIRST() { - this.argumentValidator = new ArgumentValidator("FIRST"); + public FIRST(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setExactNumberOfArguments(1); this.argumentValidator.setEveryArgumentExpectedType(Cons.class); } diff --git a/src/function/builtin/cons/LENGTH.java b/src/function/builtin/cons/LENGTH.java index 85172e7..25e91d3 100644 --- a/src/function/builtin/cons/LENGTH.java +++ b/src/function/builtin/cons/LENGTH.java @@ -11,7 +11,7 @@ import sexpression.*; public class LENGTH extends LispFunction { public static BigInteger getLength(Cons list) { - LENGTH lengthFunction = new LENGTH(); + LENGTH lengthFunction = new LENGTH("LENGTH"); LispNumber length = lengthFunction.callWithoutArgumentValidation(makeList(list)); return length.getValue(); @@ -19,8 +19,8 @@ public class LENGTH extends LispFunction { private ArgumentValidator argumentValidator; - public LENGTH() { - this.argumentValidator = new ArgumentValidator("LENGTH"); + public LENGTH(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setExactNumberOfArguments(1); this.argumentValidator.setEveryArgumentExpectedType(Cons.class); } diff --git a/src/function/builtin/cons/LIST.java b/src/function/builtin/cons/LIST.java index ec006e3..7e85fdf 100644 --- a/src/function/builtin/cons/LIST.java +++ b/src/function/builtin/cons/LIST.java @@ -14,8 +14,8 @@ public class LIST extends LispFunction { private ArgumentValidator argumentValidator; - public LIST() { - this.argumentValidator = new ArgumentValidator("LIST"); + public LIST(String name) { + this.argumentValidator = new ArgumentValidator(name); } public Cons call(Cons argumentList) { diff --git a/src/function/builtin/cons/REST.java b/src/function/builtin/cons/REST.java index f7e8265..2a8f7b8 100644 --- a/src/function/builtin/cons/REST.java +++ b/src/function/builtin/cons/REST.java @@ -8,8 +8,8 @@ public class REST extends LispFunction { private ArgumentValidator argumentValidator; - public REST() { - this.argumentValidator = new ArgumentValidator("REST"); + public REST(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setExactNumberOfArguments(1); this.argumentValidator.setEveryArgumentExpectedType(Cons.class); } diff --git a/src/function/builtin/math/DIVIDE.java b/src/function/builtin/math/DIVIDE.java index bf1020b..e9d707d 100644 --- a/src/function/builtin/math/DIVIDE.java +++ b/src/function/builtin/math/DIVIDE.java @@ -11,8 +11,8 @@ public class DIVIDE extends LispFunction { private ArgumentValidator argumentValidator; private MathFunction mathFunction; - public DIVIDE() { - this.argumentValidator = new ArgumentValidator("/"); + public DIVIDE(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setMinimumNumberOfArguments(1); this.argumentValidator.setEveryArgumentExpectedType(LispNumber.class); this.mathFunction = new MathFunction(this::getReciprocal, this::divide); diff --git a/src/function/builtin/math/MINUS.java b/src/function/builtin/math/MINUS.java index 7a2c39e..a87b1b4 100644 --- a/src/function/builtin/math/MINUS.java +++ b/src/function/builtin/math/MINUS.java @@ -11,8 +11,8 @@ public class MINUS extends LispFunction { private ArgumentValidator argumentValidator; private MathFunction mathFunction; - public MINUS() { - this.argumentValidator = new ArgumentValidator("-"); + public MINUS(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setMinimumNumberOfArguments(1); this.argumentValidator.setEveryArgumentExpectedType(LispNumber.class); this.mathFunction = new MathFunction(this::additiveInverse, this::subtract); diff --git a/src/function/builtin/math/MULTIPLY.java b/src/function/builtin/math/MULTIPLY.java index 23e6818..609da75 100644 --- a/src/function/builtin/math/MULTIPLY.java +++ b/src/function/builtin/math/MULTIPLY.java @@ -11,8 +11,8 @@ public class MULTIPLY extends LispFunction { private ArgumentValidator argumentValidator; private MathFunction mathFunction; - public MULTIPLY() { - this.argumentValidator = new ArgumentValidator("*"); + public MULTIPLY(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setEveryArgumentExpectedType(LispNumber.class); this.mathFunction = new MathFunction(number -> number, this::multiply); } diff --git a/src/function/builtin/math/PLUS.java b/src/function/builtin/math/PLUS.java index eb49441..3fc0d9d 100644 --- a/src/function/builtin/math/PLUS.java +++ b/src/function/builtin/math/PLUS.java @@ -11,8 +11,8 @@ public class PLUS extends LispFunction { private ArgumentValidator argumentValidator; private MathFunction mathFunction; - public PLUS() { - this.argumentValidator = new ArgumentValidator("+"); + public PLUS(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setEveryArgumentExpectedType(LispNumber.class); this.mathFunction = new MathFunction(number -> number, this::add); } diff --git a/src/function/builtin/predicate/ATOM.java b/src/function/builtin/predicate/ATOM.java index 79aec95..25e473b 100644 --- a/src/function/builtin/predicate/ATOM.java +++ b/src/function/builtin/predicate/ATOM.java @@ -11,8 +11,8 @@ public class ATOM extends LispFunction { private ArgumentValidator argumentValidator; - public ATOM() { - this.argumentValidator = new ArgumentValidator("ATOM"); + public ATOM(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setExactNumberOfArguments(1); } diff --git a/src/function/builtin/predicate/EQ.java b/src/function/builtin/predicate/EQ.java index add9adb..0a6edab 100644 --- a/src/function/builtin/predicate/EQ.java +++ b/src/function/builtin/predicate/EQ.java @@ -11,8 +11,8 @@ public class EQ extends LispFunction { private ArgumentValidator argumentValidator; - public EQ() { - this.argumentValidator = new ArgumentValidator("EQ"); + public EQ(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setExactNumberOfArguments(2); } diff --git a/src/function/builtin/predicate/EQUAL.java b/src/function/builtin/predicate/EQUAL.java index 537f011..8813ba3 100644 --- a/src/function/builtin/predicate/EQUAL.java +++ b/src/function/builtin/predicate/EQUAL.java @@ -15,8 +15,8 @@ public class EQUAL extends LispFunction { private ArgumentValidator argumentValidator; - public EQUAL() { - this.argumentValidator = new ArgumentValidator("EQUAL"); + public EQUAL(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setExactNumberOfArguments(2); } diff --git a/src/function/builtin/predicate/LISTP.java b/src/function/builtin/predicate/LISTP.java index 446102d..9aa9590 100644 --- a/src/function/builtin/predicate/LISTP.java +++ b/src/function/builtin/predicate/LISTP.java @@ -11,8 +11,8 @@ public class LISTP extends LispFunction { private ArgumentValidator argumentValidator; - public LISTP() { - this.argumentValidator = new ArgumentValidator("LISTP"); + public LISTP(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setExactNumberOfArguments(1); } diff --git a/src/function/builtin/predicate/NULL.java b/src/function/builtin/predicate/NULL.java index a013ae3..936e266 100644 --- a/src/function/builtin/predicate/NULL.java +++ b/src/function/builtin/predicate/NULL.java @@ -11,8 +11,8 @@ public class NULL extends LispFunction { private ArgumentValidator argumentValidator; - public NULL() { - this.argumentValidator = new ArgumentValidator("NULL"); + public NULL(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setExactNumberOfArguments(1); } diff --git a/src/function/builtin/predicate/NUMERIC_EQUAL.java b/src/function/builtin/predicate/NUMERIC_EQUAL.java index 578e800..aa6dc08 100644 --- a/src/function/builtin/predicate/NUMERIC_EQUAL.java +++ b/src/function/builtin/predicate/NUMERIC_EQUAL.java @@ -11,8 +11,8 @@ public class NUMERIC_EQUAL extends LispFunction { private ArgumentValidator argumentValidator; - public NUMERIC_EQUAL() { - this.argumentValidator = new ArgumentValidator("="); + public NUMERIC_EQUAL(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setMinimumNumberOfArguments(1); this.argumentValidator.setEveryArgumentExpectedType(LispNumber.class); } diff --git a/src/function/builtin/predicate/NUMERIC_GREATER.java b/src/function/builtin/predicate/NUMERIC_GREATER.java index 42f0b2b..d3920b0 100644 --- a/src/function/builtin/predicate/NUMERIC_GREATER.java +++ b/src/function/builtin/predicate/NUMERIC_GREATER.java @@ -11,8 +11,8 @@ public class NUMERIC_GREATER extends LispFunction { private ArgumentValidator argumentValidator; - public NUMERIC_GREATER() { - this.argumentValidator = new ArgumentValidator(">"); + public NUMERIC_GREATER(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setMinimumNumberOfArguments(1); this.argumentValidator.setEveryArgumentExpectedType(LispNumber.class); } diff --git a/src/function/builtin/predicate/NUMERIC_LESS.java b/src/function/builtin/predicate/NUMERIC_LESS.java index 976e6d6..3187e1a 100644 --- a/src/function/builtin/predicate/NUMERIC_LESS.java +++ b/src/function/builtin/predicate/NUMERIC_LESS.java @@ -11,8 +11,8 @@ public class NUMERIC_LESS extends LispFunction { private ArgumentValidator argumentValidator; - public NUMERIC_LESS() { - this.argumentValidator = new ArgumentValidator("<"); + public NUMERIC_LESS(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setMinimumNumberOfArguments(1); this.argumentValidator.setEveryArgumentExpectedType(LispNumber.class); } diff --git a/src/function/builtin/special/AND.java b/src/function/builtin/special/AND.java index 263d368..2ca1eb2 100644 --- a/src/function/builtin/special/AND.java +++ b/src/function/builtin/special/AND.java @@ -11,8 +11,8 @@ public class AND extends LispSpecialFunction { private ArgumentValidator argumentValidator; - public AND() { - this.argumentValidator = new ArgumentValidator("AND"); + public AND(String name) { + this.argumentValidator = new ArgumentValidator(name); } public SExpression call(Cons argumentList) { diff --git a/src/function/builtin/special/CASE.java b/src/function/builtin/special/CASE.java index 8750131..8961bde 100644 --- a/src/function/builtin/special/CASE.java +++ b/src/function/builtin/special/CASE.java @@ -13,8 +13,8 @@ public class CASE extends LispSpecialFunction { private ArgumentValidator argumentValidator; - public CASE() { - this.argumentValidator = new ArgumentValidator("CASE"); + public CASE(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setMinimumNumberOfArguments(1); this.argumentValidator.setTrailingArgumentExpectedType(Cons.class); this.argumentValidator.setTrailingArgumentExcludedType(Nil.class); diff --git a/src/function/builtin/special/COND.java b/src/function/builtin/special/COND.java index 5ec47c7..bceabfa 100644 --- a/src/function/builtin/special/COND.java +++ b/src/function/builtin/special/COND.java @@ -11,8 +11,8 @@ public class COND extends LispSpecialFunction { private ArgumentValidator argumentValidator; - public COND() { - this.argumentValidator = new ArgumentValidator("COND"); + public COND(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setEveryArgumentExpectedType(Cons.class); this.argumentValidator.setEveryArgumentExcludedType(Nil.class); } diff --git a/src/function/builtin/special/DEFINE_MACRO.java b/src/function/builtin/special/DEFINE_MACRO.java index 42665e0..e0580d4 100644 --- a/src/function/builtin/special/DEFINE_MACRO.java +++ b/src/function/builtin/special/DEFINE_MACRO.java @@ -6,8 +6,8 @@ import sexpression.*; @FunctionNames({ "DEFINE-MACRO" }) public class DEFINE_MACRO extends Define { - public DEFINE_MACRO() { - super("DEFINE-MACRO"); + public DEFINE_MACRO(String name) { + super(name); } @Override diff --git a/src/function/builtin/special/DEFUN.java b/src/function/builtin/special/DEFUN.java index 403469b..96f3225 100644 --- a/src/function/builtin/special/DEFUN.java +++ b/src/function/builtin/special/DEFUN.java @@ -6,8 +6,8 @@ import sexpression.*; @FunctionNames({ "DEFUN" }) public class DEFUN extends Define { - public DEFUN() { - super("DEFUN"); + public DEFUN(String name) { + super(name); } @Override diff --git a/src/function/builtin/special/IF.java b/src/function/builtin/special/IF.java index c3fdc9f..8730efa 100644 --- a/src/function/builtin/special/IF.java +++ b/src/function/builtin/special/IF.java @@ -10,8 +10,8 @@ public class IF extends LispSpecialFunction { private ArgumentValidator argumentValidator; - public IF() { - this.argumentValidator = new ArgumentValidator("IF"); + public IF(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setMinimumNumberOfArguments(2); this.argumentValidator.setMaximumNumberOfArguments(3); } diff --git a/src/function/builtin/special/LAMBDA.java b/src/function/builtin/special/LAMBDA.java index e1c974f..57a088d 100644 --- a/src/function/builtin/special/LAMBDA.java +++ b/src/function/builtin/special/LAMBDA.java @@ -25,7 +25,7 @@ public class LAMBDA extends LispSpecialFunction { lambdaValidator.setEveryArgumentExpectedType(Cons.class); lambdaValidator.validate(makeList(rest)); - LambdaExpression lambda = new LAMBDA().call((Cons) rest); + LambdaExpression lambda = new LAMBDA("LAMBDA").call((Cons) rest); return lambda.getFunction(); } @@ -33,12 +33,12 @@ public class LAMBDA extends LispSpecialFunction { private ArgumentValidator argumentValidator; private ArgumentValidator lambdaListValidator; - public LAMBDA() { - this.argumentValidator = new ArgumentValidator("LAMBDA"); + public LAMBDA(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setFirstArgumentExpectedType(Cons.class); this.argumentValidator.setMinimumNumberOfArguments(1); - this.lambdaListValidator = new ArgumentValidator("LAMBDA|lambda-list|"); + this.lambdaListValidator = new ArgumentValidator(name + "|lambda-list|"); this.lambdaListValidator.setEveryArgumentExpectedType(Symbol.class); } diff --git a/src/function/builtin/special/LET.java b/src/function/builtin/special/LET.java index 0af0920..f477c0a 100644 --- a/src/function/builtin/special/LET.java +++ b/src/function/builtin/special/LET.java @@ -15,15 +15,15 @@ public class LET extends LispSpecialFunction { private ArgumentValidator pairValidator; private ExecutionContext executionContext; - public LET() { - this.argumentValidator = new ArgumentValidator("LET"); + public LET(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setMinimumNumberOfArguments(1); this.argumentValidator.setFirstArgumentExpectedType(Cons.class); - this.variableDefinitionListValidator = new ArgumentValidator("LET|pair-list|"); + this.variableDefinitionListValidator = new ArgumentValidator(name + "|pair-list|"); this.variableDefinitionListValidator.setEveryArgumentExpectedType(Cons.class); - this.pairValidator = new ArgumentValidator("LET|pair|"); + this.pairValidator = new ArgumentValidator(name + "|pair|"); this.pairValidator.setMinimumNumberOfArguments(1); this.pairValidator.setMaximumNumberOfArguments(2); this.pairValidator.setFirstArgumentExpectedType(Symbol.class); diff --git a/src/function/builtin/special/OR.java b/src/function/builtin/special/OR.java index 695331f..b310b92 100644 --- a/src/function/builtin/special/OR.java +++ b/src/function/builtin/special/OR.java @@ -10,8 +10,8 @@ public class OR extends LispSpecialFunction { private ArgumentValidator argumentValidator; - public OR() { - this.argumentValidator = new ArgumentValidator("OR"); + public OR(String name) { + this.argumentValidator = new ArgumentValidator(name); } public SExpression call(Cons argumentList) { diff --git a/src/function/builtin/special/PROGN.java b/src/function/builtin/special/PROGN.java index c11a5f1..1c8974c 100644 --- a/src/function/builtin/special/PROGN.java +++ b/src/function/builtin/special/PROGN.java @@ -11,8 +11,8 @@ public class PROGN extends LispSpecialFunction { private ArgumentValidator argumentValidator; - public PROGN() { - this.argumentValidator = new ArgumentValidator("PROGN"); + public PROGN(String name) { + this.argumentValidator = new ArgumentValidator(name); } public SExpression call(Cons argumentList) { diff --git a/src/function/builtin/special/QUOTE.java b/src/function/builtin/special/QUOTE.java index ba6f9fa..3827b59 100644 --- a/src/function/builtin/special/QUOTE.java +++ b/src/function/builtin/special/QUOTE.java @@ -8,8 +8,8 @@ public class QUOTE extends LispSpecialFunction { private ArgumentValidator argumentValidator; - public QUOTE() { - this.argumentValidator = new ArgumentValidator("QUOTE"); + public QUOTE(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setExactNumberOfArguments(1); } diff --git a/src/function/builtin/special/SETF.java b/src/function/builtin/special/SETF.java index 2f78bca..ed16e95 100644 --- a/src/function/builtin/special/SETF.java +++ b/src/function/builtin/special/SETF.java @@ -12,8 +12,8 @@ public class SETF extends LispSpecialFunction { private ArgumentValidator argumentValidator; - public SETF() { - this.argumentValidator = new ArgumentValidator("SETF"); + public SETF(String name) { + this.argumentValidator = new ArgumentValidator(name); this.argumentValidator.setExactNumberOfArguments(2); this.argumentValidator.setFirstArgumentExpectedType(Symbol.class); } diff --git a/src/table/FunctionTable.java b/src/table/FunctionTable.java index 0ad7a42..88cb99f 100644 --- a/src/table/FunctionTable.java +++ b/src/table/FunctionTable.java @@ -110,17 +110,15 @@ public class FunctionTable { } private void addAllFunctionNamesToTable(Class function, String[] names) { - LispFunction instance = createInstance(function); - for (String name : names) - table.put(name, instance); + table.put(name, createInstance(function, name)); } - private LispFunction createInstance(Class function) { + private LispFunction createInstance(Class function, String name) { LispFunction instance = null; try { - instance = function.getConstructor().newInstance(); + instance = function.getConstructor(String.class).newInstance(name); } catch (Exception e) { throw new LispFunctionInstantiationException(function.getName()); } diff --git a/test/table/FunctionTableTester.java b/test/table/FunctionTableTester.java index bb0d615..996ba10 100644 --- a/test/table/FunctionTableTester.java +++ b/test/table/FunctionTableTester.java @@ -19,6 +19,8 @@ public class FunctionTableTester { @FunctionNames({ "GOOD" }) public static class GoodFunction extends LispFunction { + public GoodFunction(String name) {} + @Override public SExpression call(Cons argList) { return NIL; @@ -28,10 +30,6 @@ public class FunctionTableTester { @FunctionNames({ "BAD" }) public static class BadFunction extends LispFunction { - public BadFunction() { - throw new IllegalArgumentException("bad function"); - } - @Override public SExpression call(Cons argList) { return NIL;