Clean up code
This commit is contained in:
parent
35406b9f03
commit
6ff6852c05
|
@ -7,7 +7,7 @@ import function.builtin.Eval.Companion.applyFunction
|
||||||
import function.builtin.Eval.Companion.lookupFunctionOrLambda
|
import function.builtin.Eval.Companion.lookupFunctionOrLambda
|
||||||
import sexpression.Cons
|
import sexpression.Cons
|
||||||
import sexpression.SExpression
|
import sexpression.SExpression
|
||||||
import table.FunctionTable
|
import table.FunctionTable.lookupFunction
|
||||||
|
|
||||||
@FunctionNames("APPLY")
|
@FunctionNames("APPLY")
|
||||||
class Apply(name: String) : LispFunction() {
|
class Apply(name: String) : LispFunction() {
|
||||||
|
@ -31,7 +31,7 @@ class Apply(name: String) : LispFunction() {
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun apply(argumentList: Cons): SExpression {
|
fun apply(argumentList: Cons): SExpression {
|
||||||
return FunctionTable.lookupFunction("APPLY")!!.call(argumentList)
|
return lookupFunction("APPLY")!!.call(argumentList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import sexpression.SExpression
|
||||||
import sexpression.Symbol
|
import sexpression.Symbol
|
||||||
import sexpression.Symbol.Companion.T
|
import sexpression.Symbol.Companion.T
|
||||||
import table.ExecutionContext
|
import table.ExecutionContext
|
||||||
import table.FunctionTable
|
import table.FunctionTable.lookupFunction
|
||||||
|
|
||||||
@FunctionNames("EVAL")
|
@FunctionNames("EVAL")
|
||||||
class Eval(name: String) : LispFunction() {
|
class Eval(name: String) : LispFunction() {
|
||||||
|
@ -99,7 +99,7 @@ class Eval(name: String) : LispFunction() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private fun lookupEval() = FunctionTable.lookupFunction("EVAL") as Eval
|
private fun lookupEval() = lookupFunction("EVAL") as Eval
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun eval(sExpression: SExpression): SExpression {
|
fun eval(sExpression: SExpression): SExpression {
|
||||||
|
@ -128,7 +128,7 @@ class Eval(name: String) : LispFunction() {
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun lookupFunctionOrLambda(functionExpression: SExpression): LispFunction {
|
fun lookupFunctionOrLambda(functionExpression: SExpression): LispFunction {
|
||||||
val function = FunctionTable.lookupFunction(functionExpression.toString())
|
val function = lookupFunction(functionExpression.toString())
|
||||||
|
|
||||||
return function ?: createLambdaFunction(functionExpression)
|
return function ?: createLambdaFunction(functionExpression)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import sexpression.Cons
|
||||||
import sexpression.SExpression
|
import sexpression.SExpression
|
||||||
import sexpression.Symbol
|
import sexpression.Symbol
|
||||||
import table.ExecutionContext
|
import table.ExecutionContext
|
||||||
import table.FunctionTable
|
import table.FunctionTable.lookupFunction
|
||||||
import table.SymbolTable
|
import table.SymbolTable
|
||||||
|
|
||||||
@FunctionNames("SET")
|
@FunctionNames("SET")
|
||||||
|
@ -47,6 +47,6 @@ class Set(name: String) : LispFunction() {
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun set(argumentList: Cons) = FunctionTable.lookupFunction("SET")!!.call(argumentList)
|
fun set(argumentList: Cons) = lookupFunction("SET")!!.call(argumentList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import function.UserDefinedFunction
|
||||||
import sexpression.Cons
|
import sexpression.Cons
|
||||||
import sexpression.SExpression
|
import sexpression.SExpression
|
||||||
import sexpression.Symbol
|
import sexpression.Symbol
|
||||||
import table.FunctionTable
|
import table.FunctionTable.lookupFunction
|
||||||
|
|
||||||
@FunctionNames("SYMBOL-FUNCTION")
|
@FunctionNames("SYMBOL-FUNCTION")
|
||||||
class SymbolFunction(name: String) : LispFunction() {
|
class SymbolFunction(name: String) : LispFunction() {
|
||||||
|
@ -23,7 +23,7 @@ class SymbolFunction(name: String) : LispFunction() {
|
||||||
argumentValidator.validate(argumentList)
|
argumentValidator.validate(argumentList)
|
||||||
|
|
||||||
val symbol = argumentList.first
|
val symbol = argumentList.first
|
||||||
val function = FunctionTable.lookupFunction(symbol.toString())
|
val function = lookupFunction(symbol.toString())
|
||||||
|
|
||||||
if (function != null)
|
if (function != null)
|
||||||
return createRepresentation(symbol, function)
|
return createRepresentation(symbol, function)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import function.FunctionNames
|
||||||
import function.LispFunction
|
import function.LispFunction
|
||||||
import sexpression.Cons
|
import sexpression.Cons
|
||||||
import sexpression.Nil
|
import sexpression.Nil
|
||||||
import table.FunctionTable
|
import table.FunctionTable.lookupFunction
|
||||||
|
|
||||||
@FunctionNames("APPEND")
|
@FunctionNames("APPEND")
|
||||||
class Append(name: String) : LispFunction() {
|
class Append(name: String) : LispFunction() {
|
||||||
|
@ -58,6 +58,6 @@ class Append(name: String) : LispFunction() {
|
||||||
return lookupAppend().appendLists(firstList, secondList)
|
return lookupAppend().appendLists(firstList, secondList)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun lookupAppend() = FunctionTable.lookupFunction("APPEND") as Append
|
private fun lookupAppend() = lookupFunction("APPEND") as Append
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import function.FunctionNames
|
||||||
import function.LispFunction
|
import function.LispFunction
|
||||||
import sexpression.Cons
|
import sexpression.Cons
|
||||||
import sexpression.LispNumber
|
import sexpression.LispNumber
|
||||||
import table.FunctionTable
|
|
||||||
import table.FunctionTable.lookupFunction
|
import table.FunctionTable.lookupFunction
|
||||||
import java.math.BigInteger.ZERO
|
import java.math.BigInteger.ZERO
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue