Convert some more code to kotlin

This commit is contained in:
Mike Cifelli 2018-07-21 17:31:34 -04:00
parent 1df72e7704
commit 4c6920eaa1
11 changed files with 53 additions and 70 deletions

View File

@ -1,13 +0,0 @@
package function;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface FunctionNames {
String[] value();
}

View File

@ -0,0 +1,10 @@
package function
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy.RUNTIME
import kotlin.annotation.AnnotationTarget.CLASS
import kotlin.annotation.AnnotationTarget.FILE
@Retention(RUNTIME)
@Target(CLASS, FILE)
annotation class FunctionNames(vararg val value: String)

View File

@ -1,17 +0,0 @@
package function;
import sexpression.Cons;
import sexpression.SExpression;
public abstract class LispFunction {
public abstract SExpression call(Cons argumentList);
public boolean isArgumentListEvaluated() {
return true;
}
public boolean isMacro() {
return false;
}
}

View File

@ -0,0 +1,15 @@
package function
import sexpression.Cons
import sexpression.SExpression
abstract class LispFunction {
open val isArgumentListEvaluated: Boolean
get() = true
open val isMacro: Boolean
get() = false
abstract fun call(argumentList: Cons): SExpression
}

View File

@ -1,9 +0,0 @@
package function;
public abstract class LispSpecialFunction extends LispFunction {
@Override
public boolean isArgumentListEvaluated() {
return false;
}
}

View File

@ -0,0 +1,7 @@
package function
abstract class LispSpecialFunction : LispFunction() {
override val isArgumentListEvaluated: Boolean
get() = false
}

View File

@ -1,15 +0,0 @@
package function;
import sexpression.Cons;
public class UserDefinedMacro extends UserDefinedSpecialFunction {
public UserDefinedMacro(String name, Cons lambdaList, Cons body) {
super(name, lambdaList, body);
}
@Override
public boolean isMacro() {
return true;
}
}

View File

@ -0,0 +1,10 @@
package function
import sexpression.Cons
class UserDefinedMacro(name: String, lambdaList: Cons, body: Cons)
: UserDefinedSpecialFunction(name, lambdaList, body) {
override val isMacro: Boolean
get() = true
}

View File

@ -1,15 +0,0 @@
package function;
import sexpression.Cons;
public class UserDefinedSpecialFunction extends UserDefinedFunction {
public UserDefinedSpecialFunction(String name, Cons lambdaList, Cons body) {
super(name, lambdaList, body);
}
@Override
public boolean isArgumentListEvaluated() {
return false;
}
}

View File

@ -0,0 +1,10 @@
package function
import sexpression.Cons
open class UserDefinedSpecialFunction(name: String, lambdaList: Cons, body: Cons)
: UserDefinedFunction(name, lambdaList, body) {
override val isArgumentListEvaluated: Boolean
get() = false
}

View File

@ -124,7 +124,7 @@ object FunctionTable {
addAllFunctionNamesToTable(function, functionNames.value)
}
private fun addAllFunctionNamesToTable(function: Class<out LispFunction>, names: Array<String>) {
private fun addAllFunctionNamesToTable(function: Class<out LispFunction>, names: Array<out String>) {
for (name in names)
table[name] = createInstance(function, name)
}