Clean up code

This commit is contained in:
Mike Cifelli 2018-11-10 08:30:15 -05:00
parent 35406b9f03
commit 6ff6852c05
6 changed files with 11 additions and 12 deletions

View File

@ -7,7 +7,7 @@ import function.builtin.Eval.Companion.applyFunction
import function.builtin.Eval.Companion.lookupFunctionOrLambda
import sexpression.Cons
import sexpression.SExpression
import table.FunctionTable
import table.FunctionTable.lookupFunction
@FunctionNames("APPLY")
class Apply(name: String) : LispFunction() {
@ -31,7 +31,7 @@ class Apply(name: String) : LispFunction() {
companion object {
fun apply(argumentList: Cons): SExpression {
return FunctionTable.lookupFunction("APPLY")!!.call(argumentList)
return lookupFunction("APPLY")!!.call(argumentList)
}
}
}

View File

@ -16,7 +16,7 @@ import sexpression.SExpression
import sexpression.Symbol
import sexpression.Symbol.Companion.T
import table.ExecutionContext
import table.FunctionTable
import table.FunctionTable.lookupFunction
@FunctionNames("EVAL")
class Eval(name: String) : LispFunction() {
@ -99,7 +99,7 @@ class Eval(name: String) : LispFunction() {
companion object {
private fun lookupEval() = FunctionTable.lookupFunction("EVAL") as Eval
private fun lookupEval() = lookupFunction("EVAL") as Eval
@JvmStatic
fun eval(sExpression: SExpression): SExpression {
@ -128,7 +128,7 @@ class Eval(name: String) : LispFunction() {
@JvmStatic
fun lookupFunctionOrLambda(functionExpression: SExpression): LispFunction {
val function = FunctionTable.lookupFunction(functionExpression.toString())
val function = lookupFunction(functionExpression.toString())
return function ?: createLambdaFunction(functionExpression)
}

View File

@ -7,7 +7,7 @@ import sexpression.Cons
import sexpression.SExpression
import sexpression.Symbol
import table.ExecutionContext
import table.FunctionTable
import table.FunctionTable.lookupFunction
import table.SymbolTable
@FunctionNames("SET")
@ -47,6 +47,6 @@ class Set(name: String) : LispFunction() {
companion object {
@JvmStatic
fun set(argumentList: Cons) = FunctionTable.lookupFunction("SET")!!.call(argumentList)
fun set(argumentList: Cons) = lookupFunction("SET")!!.call(argumentList)
}
}

View File

@ -9,7 +9,7 @@ import function.UserDefinedFunction
import sexpression.Cons
import sexpression.SExpression
import sexpression.Symbol
import table.FunctionTable
import table.FunctionTable.lookupFunction
@FunctionNames("SYMBOL-FUNCTION")
class SymbolFunction(name: String) : LispFunction() {
@ -23,7 +23,7 @@ class SymbolFunction(name: String) : LispFunction() {
argumentValidator.validate(argumentList)
val symbol = argumentList.first
val function = FunctionTable.lookupFunction(symbol.toString())
val function = lookupFunction(symbol.toString())
if (function != null)
return createRepresentation(symbol, function)

View File

@ -5,7 +5,7 @@ import function.FunctionNames
import function.LispFunction
import sexpression.Cons
import sexpression.Nil
import table.FunctionTable
import table.FunctionTable.lookupFunction
@FunctionNames("APPEND")
class Append(name: String) : LispFunction() {
@ -58,6 +58,6 @@ class Append(name: String) : LispFunction() {
return lookupAppend().appendLists(firstList, secondList)
}
private fun lookupAppend() = FunctionTable.lookupFunction("APPEND") as Append
private fun lookupAppend() = lookupFunction("APPEND") as Append
}
}

View File

@ -5,7 +5,6 @@ import function.FunctionNames
import function.LispFunction
import sexpression.Cons
import sexpression.LispNumber
import table.FunctionTable
import table.FunctionTable.lookupFunction
import java.math.BigInteger.ZERO