Convert some more code to kotlin
This commit is contained in:
parent
1df72e7704
commit
4c6920eaa1
|
@ -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();
|
|
||||||
}
|
|
|
@ -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)
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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
|
||||||
|
}
|
|
@ -1,9 +0,0 @@
|
||||||
package function;
|
|
||||||
|
|
||||||
public abstract class LispSpecialFunction extends LispFunction {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isArgumentListEvaluated() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package function
|
||||||
|
|
||||||
|
abstract class LispSpecialFunction : LispFunction() {
|
||||||
|
|
||||||
|
override val isArgumentListEvaluated: Boolean
|
||||||
|
get() = false
|
||||||
|
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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
|
||||||
|
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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
|
||||||
|
}
|
|
@ -124,7 +124,7 @@ object FunctionTable {
|
||||||
addAllFunctionNamesToTable(function, functionNames.value)
|
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)
|
for (name in names)
|
||||||
table[name] = createInstance(function, name)
|
table[name] = createInstance(function, name)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue