1 21 22 package org.armedbear.lisp; 23 24 public class CompiledFunction extends Closure 25 { 26 public CompiledFunction(Symbol symbol, LispObject lambdaList, 27 LispObject body, Environment env) 28 throws ConditionThrowable 29 { 30 super(null, lambdaList, body, env); 31 } 32 33 public LispObject typep(LispObject typeSpecifier) throws ConditionThrowable 34 { 35 if (typeSpecifier == Symbol.COMPILED_FUNCTION) 36 return T; 37 return super.typep(typeSpecifier); 38 } 39 40 public LispObject execute() throws ConditionThrowable 41 { 42 LispObject[] args = new LispObject[0]; 43 return execute(args); 44 } 45 46 public LispObject execute(LispObject arg) throws ConditionThrowable 47 { 48 LispObject[] args = new LispObject[1]; 49 args[0] = arg; 50 return execute(args); 51 } 52 53 public LispObject execute(LispObject first, LispObject second) 54 throws ConditionThrowable 55 { 56 LispObject[] args = new LispObject[2]; 57 args[0] = first; 58 args[1] = second; 59 return execute(args); 60 } 61 62 public LispObject execute(LispObject first, LispObject second, 63 LispObject third) 64 throws ConditionThrowable 65 { 66 LispObject[] args = new LispObject[3]; 67 args[0] = first; 68 args[1] = second; 69 args[2] = third; 70 return execute(args); 71 } 72 73 public LispObject execute(LispObject first, LispObject second, 74 LispObject third, LispObject fourth) 75 throws ConditionThrowable 76 { 77 LispObject[] args = new LispObject[4]; 78 args[0] = first; 79 args[1] = second; 80 args[2] = third; 81 args[3] = fourth; 82 return execute(args); 83 } 84 85 public LispObject execute(LispObject[] args) throws ConditionThrowable 86 { 87 return signal(new LispError("CompiledFunction.execute(): not implemented")); 88 } 89 90 private static final Primitive LOAD_COMPILED_FUNCTION = 92 new Primitive("load-compiled-function", PACKAGE_SYS, true, 93 "pathname") 94 { 95 public LispObject execute(LispObject arg) throws ConditionThrowable 96 { 97 String namestring = null; 98 if (arg instanceof Pathname) { 99 namestring = ((Pathname)arg).getNamestring(); 100 } else if (arg instanceof AbstractString) { 101 namestring = arg.getStringValue(); 102 } 103 if (namestring != null) 104 return loadCompiledFunction(namestring); 105 return signal(new LispError("Unable to load " + arg.writeToString())); 106 } 107 }; 108 109 private static final Primitive1 VARLIST = 111 new Primitive1("varlist", PACKAGE_SYS, false) 112 { 113 public LispObject execute(LispObject arg) throws ConditionThrowable { 114 if (arg instanceof Closure) 115 return ((Closure)arg).getVariableList(); 116 return signal(new TypeError(arg, "compiled function")); 117 } 118 }; 119 } 120 | Popular Tags |