| java.lang.Object org.jatha.dynatype.StandardLispValue org.jatha.compile.LispPrimitive
All known Subclasses: org.jatha.compile.ImportPrimitive, org.jatha.compile.SquareRootPrimitive, org.jatha.compile.CosecantPrimitive, org.jatha.compile.FuncallPrimitive, org.jatha.compile.PackageUseListPrimitive, org.jatha.compile.EqlPrimitive, org.jatha.compile.EqualNumericPrimitive, org.jatha.compile.StringPrimitive, org.jatha.compile.SetfGethashPrimitive, org.jatha.compile.Macroexpand1Primitive, org.jatha.compile.ListAllPackagesPrimitive, org.jatha.compile.StringLessThanOrEqualPrimitive, org.jatha.compile.GethashPrimitive, org.jatha.compile.ThirdPrimitive, org.jatha.compile.ClrhashPrimitive, org.jatha.compile.StringNeqPrimitive, org.jatha.compile.RassocPrimitive, org.jatha.compile.PrincPrimitive, org.jatha.compile.SecantPrimitive, org.jatha.compile.FifthPrimitive, org.jatha.compile.SetPrimitive, org.jatha.compile.HashtablepPrimitive, org.jatha.compile.HashtableRehashThresholdPrimitive, org.jatha.compile.NumberpPrimitive, org.jatha.compile.FourthPrimitive, org.jatha.compile.StringpPrimitive, org.jatha.compile.StringLeftTrimPrimitive, org.jatha.compile.ApplyPrimitive, org.jatha.compile.ListStarPrimitive, org.jatha.compile.MacroexpandPrimitive, org.jatha.compile.SubtractOnePrimitive, org.jatha.compile.StringCapitalizePrimitive, org.jatha.compile.AtomPrimitive, org.jatha.compile.FloorPrimitive, org.jatha.compile.GreaterThanPrimitive, org.jatha.compile.RadiansToDegreesPrimitive, org.jatha.compile.FreePrimitive, org.jatha.compile.Prin1Primitive, org.jatha.compile.DefconstantPrimitive, org.jatha.compile.StringEqPrimitive, org.jatha.compile.HashtableTestPrimitive, org.jatha.compile.ListpPrimitive, org.jatha.compile.PackageNamePrimitive, org.jatha.compile.CdrPrimitive, org.jatha.compile.SetfDocumentationPrimitive, org.jatha.compile.ArcSinePrimitive, org.jatha.compile.SetfSymbolFunctionPrimitive, org.jatha.compile.KeywordpPrimitive, org.jatha.compile.ArcCosinePrimitive, org.jatha.compile.TangentPrimitive, org.jatha.compile.ShadowingImportPrimitive, org.jatha.compile.StringGreaterpPrimitive, org.jatha.compile.RemovePrimitive, org.jatha.compile.RestPrimitive, org.jatha.compile.LessThanPrimitive, org.jatha.compile.SeventhPrimitive, org.jatha.compile.PushPrimitive, org.jatha.compile.AssocPrimitive, org.jatha.compile.SymbolpPrimitive, org.jatha.compile.NullPrimitive, org.jatha.compile.ReciprocalPrimitive, org.jatha.compile.HashtableRehashSizePrimitive, org.jatha.compile.TimePrimitive, org.jatha.compile.LessThanOrEqualPrimitive, org.jatha.compile.StringLessThanPrimitive, org.jatha.compile.EltPrimitive, org.jatha.compile.BoundpPrimitive, org.jatha.compile.FunctionPrimitive, org.jatha.compile.EighthPrimitive, org.jatha.compile.SubstPrimitive, org.jatha.compile.StringEndsWithPrimitive, org.jatha.compile.PopPrimitive, org.jatha.compile.SetfSymbolPlistPrimitive, org.jatha.compile.RplacaPrimitive, org.jatha.compile.StringDowncasePrimitive, org.jatha.compile.LastPrimitive, org.jatha.compile.MultiplyPrimitive, org.jatha.compile.TenthPrimitive, org.jatha.compile.MakeHashTablePrimitive, org.jatha.compile.QuotePrimitive, org.jatha.compile.StringNotLesspPrimitive, org.jatha.compile.StringGreaterThanPrimitive, org.jatha.compile.MinPrimitive, org.jatha.compile.ArcTangentPrimitive, org.jatha.compile.ListPrimitive, org.jatha.compile.MaxPrimitive, org.jatha.compile.NStringUpcasePrimitive, org.jatha.compile.FactorialPrimitive, org.jatha.compile.ReversePrimitive, org.jatha.compile.ConspPrimitive, org.jatha.compile.PositionPrimitive, org.jatha.compile.ConstantpPrimitive, org.jatha.compile.ExportPrimitive, org.jatha.compile.CotangentPrimitive, org.jatha.compile.GcFullPrimitive, org.jatha.compile.LoadPrimitive, org.jatha.compile.StringUpcasePrimitive, org.jatha.compile.BackquotePrimitive, org.jatha.compile.NreversePrimitive, org.jatha.compile.LoadFromJarPrimitive, org.jatha.compile.SymbolNamePrimitive, org.jatha.compile.GrindefPrimitive, org.jatha.compile.PackageNicknamesPrimitive, org.jatha.compile.StringRightTrimPrimitive, org.jatha.compile.CopyListPrimitive, org.jatha.compile.TracePrimitive, org.jatha.compile.SymbolValuePrimitive, org.jatha.compile.FindPackagePrimitive, org.jatha.compile.GoPrimitive, org.jatha.compile.ConcatenatePrimitive, org.jatha.compile.TagbodyPrimitive, org.jatha.compile.NotPrimitive, org.jatha.compile.NStringCapitalizePrimitive, org.jatha.compile.CarPrimitive, org.jatha.compile.CosinePrimitive, org.jatha.compile.AddPrimitive, org.jatha.compile.RemhashPrimitive, org.jatha.compile.PrintPrimitive, org.jatha.compile.AbsoluteValuePrimitive, org.jatha.compile.ReadFromStringPrimitive, org.jatha.compile.SinePrimitive, org.jatha.compile.StringGreaterThanOrEqualPrimitive, org.jatha.compile.LengthPrimitive, org.jatha.compile.MakepackagePrimitive, org.jatha.compile.DegreesToRadiansPrimitive, org.jatha.compile.AproposPrimitive, org.jatha.compile.CeilingPrimitive, org.jatha.compile.ExitPrimitive, org.jatha.compile.TypeOfPrimitive, org.jatha.compile.EvalPrimitive, org.jatha.compile.InternPrimitive, org.jatha.compile.EqPrimitive, org.jatha.compile.GcPrimitive, org.jatha.compile.AppendPrimitive, org.jatha.compile.NStringDowncasePrimitive, org.jatha.compile.UsePackagePrimitive, org.jatha.compile.ArcTangent2Primitive, org.jatha.compile.SymbolPlistPrimitive, org.jatha.compile.GreaterThanOrEqualPrimitive, org.jatha.compile.StringTrimPrimitive, org.jatha.compile.DefvarPrimitive, org.jatha.compile.MemberPrimitive, org.jatha.compile.FboundpPrimitive, org.jatha.compile.StringEqualPrimitive, org.jatha.compile.ZeropPrimitive, org.jatha.compile.HashtableCountPrimitive, org.jatha.compile.SubtractPrimitive, org.jatha.compile.StringLesspPrimitive, org.jatha.compile.ConsPrimitive, org.jatha.compile.StringStartsWithPrimitive, org.jatha.compile.HashtableSizePrimitive, org.jatha.compile.ReturnFromPrimitive, org.jatha.compile.SymbolPackagePrimitive, org.jatha.machine.SECDop, org.jatha.compile.ButlastPrimitive, org.jatha.compile.ShadowPrimitive, org.jatha.compile.SixthPrimitive, org.jatha.compile.BlockPrimitive, org.jatha.compile.CharacterpPrimitive, org.jatha.compile.SetqPrimitive, org.jatha.compile.RplacdPrimitive, org.jatha.compile.DefparameterPrimitive, org.jatha.compile.SetfSymbolValuePrimitive, org.jatha.compile.StringNotGreaterpPrimitive, org.jatha.compile.NinthPrimitive, org.jatha.compile.SymbolFunctionPrimitive, org.jatha.compile.AddOnePrimitive, org.jatha.compile.DocumentationPrimitive, org.jatha.compile.IntegerpPrimitive, org.jatha.compile.NconcPrimitive, org.jatha.compile.FloatpPrimitive, org.jatha.compile.DividePrimitive, org.jatha.compile.FirstPrimitive, org.jatha.compile.SecondPrimitive,
LispPrimitive | abstract public class LispPrimitive extends StandardLispValue (Code) | | The LispPrimitive class makes the
transition from LISP code to Java code. There
is a LispPrimitive for each builtin LISP function.
1) Create the new LISP primitive as an instance of
this class. It must have several methods as
described below.
2) Register the new primitive with the compiler.
Each primitive must implement one method:
public void Execute(SECDMachine machine)
See Also: org.jatha.compile.LispCompiler author: Micheal S. Hewett hewett@cs.stanford.edu |
Method Summary | |
LispValue | BuiltinFunctionCode(LispValue fn) | public LispValue | CompileArgs(LispCompiler compiler, SECDMachine machine, LispValue args, LispValue valueList, LispValue code) The CompileArgs method turns the arguments of the function call
into SECD abstract machine code. | public LispValue | CompileArgs(LispCompiler compiler, SECDMachine machine, LispValue function, LispValue args, LispValue valueList, LispValue code) | abstract public void | Execute(SECDMachine machine) Execute performs the operation using the abstract machine
registers. | public String | LispFunctionNameString() | public LispValue | LispFunctionNameSymbol() | public boolean | basic_functionp() | public LispValue | grindef(LispValue code, int indentAmount) | public void | indent(int amount) | public void | internal_prin1(PrintStream os) | public void | internal_princ(PrintStream os) | public void | internal_print(PrintStream os) | public String | parameterCountString() This method returns a Java string denoting the length of
the expected argument list in some readable form. | public void | printCode(LispValue code) printCode prints a list of compiled code in a nice manner. | public void | printCode(LispValue code, int indentAmount) | public String | toString() The output of this function is printed when the
instruction needs to be printed. | boolean | validArgumentLength(LispValue numberOfArguments) This method returns true if
the list of arguments satisfies the length restrictions
posed by the function, and false otherwise. | public boolean | validArgumentList(LispValue args) This method returns true if
the list of arguments satisfies the length and format restrictions
posed by the function, and false otherwise.
It calls validArgumentLength , so the programmer
doesn't need to call it.
This method is called by the compiler.
See Also: LispPrimitive See Also: LispCompiler Parameters: args - the list of arguments. |
functionName | protected String functionName(Code) | | the functionName is part of the string that
gets printed when the instruction appears in a printed list.
|
inlineP | public boolean inlineP(Code) | | Set inlineP to true if the function effectively evaluates itself
simply by compiling its argument list. This is true for
functions like LIST, LIST*, and QUOTE. This inhibits putting
the function call on the stack, thus saving a millisecond of time.
See Also: org.jatha.compile.LispPrimitive |
maxNumberOfArgs | protected long maxNumberOfArgs(Code) | | |
minNumberOfArgs | protected long minNumberOfArgs(Code) | | |
LispPrimitive | public LispPrimitive(Jatha lisp, String fnName, long minArgs, long maxArgs)(Code) | | The constructor for the LispPrimitive class.
See Also: org.jatha.compile.LispCompiler Parameters: fnName - The LISP function name being implemented. Parameters: minArgs - The minimum number of Arguments to this function. Parameters: maxArgs - The maximum number of Arguments to this function. |
CompileArgs | public LispValue CompileArgs(LispCompiler compiler, SECDMachine machine, LispValue args, LispValue valueList, LispValue code) throws CompilerException(Code) | | The CompileArgs method turns the arguments of the function call
into SECD abstract machine code. Most functions won't need to
override the default code generation, but ones that do funny
things with argument lists will need to.
See Also: LispCompiler Parameters: compiler - Parameters: args - Parameters: valueList - Parameters: code - LispValue The code generated and cons'ed onto the front of the incoming code. |
Execute | abstract public void Execute(SECDMachine machine) throws CompilerException(Code) | | Execute performs the operation using the abstract machine
registers. Arguments are found on the S register stack,
in reverse order. UNLIMITED argument lists are collected
into a list which is the top element on the stack.
The implementation should pop an appropriate number of arguments
from the stack, perform a computation, then push a result
back on the S stack. The instruction should then be popped from
the C (code) register. A LispValueFactory objects is available
in the static variable LispValueFactory .
Example implementations:
FIRST
class FirstPrimitive extends LispPrimitive
{
public First()
{
super("FIRST", 1); // 1 argument
}
public void Execute(SECDMachine machine)
{
LispValue arg = machine.S.pop();
machine.S.push(my_first(arg));
machine.C.pop();
}
}
A multi-argument function must pop the arguments in reverse order.
public void Execute(SECDMachine machine)
{
LispValue arg2 = machine.S.pop();
LispValue arg1 = machine.S.pop();
machine.S.push(my_new_function(arg1, arg2));
machine.C.pop();
}
}
To register the new primitive, call:
Jatha.COMPILER.Register(new FirstPrimitive());
See Also: org.jatha.compile.LispCompiler Parameters: machine - The abstract machine instance. |
LispFunctionNameString | public String LispFunctionNameString()(Code) | | |
basic_functionp | public boolean basic_functionp()(Code) | | |
indent | public void indent(int amount)(Code) | | |
parameterCountString | public String parameterCountString()(Code) | | This method returns a Java string denoting the length of
the expected argument list in some readable form.
This method is called by the compiler when an argument count
exception is generated.
See Also: LispPrimitive See Also: LispCompiler a Java string denoting the length of the expected argument list. |
printCode | public void printCode(LispValue code)(Code) | | printCode prints a list of compiled code in a nice manner.
Calls the 'grindef' function on each primitive.
Grindef is an historical LISP function not found in Common LISP.
Example:
printCode(compiled-function, 2);
See Also: LispPrimitive Parameters: code - the code to be printed, with indent 2. |
toString | public String toString()(Code) | | The output of this function is printed when the
instruction needs to be printed.
|
validArgumentLength | boolean validArgumentLength(LispValue numberOfArguments)(Code) | | This method returns true if
the list of arguments satisfies the length restrictions
posed by the function, and false otherwise.
See Also: LispPrimitive Parameters: numberOfArguments - usually the result of args.length() boolean |
validArgumentList | public boolean validArgumentList(LispValue args)(Code) | | This method returns true if
the list of arguments satisfies the length and format restrictions
posed by the function, and false otherwise.
It calls validArgumentLength , so the programmer
doesn't need to call it.
This method is called by the compiler.
See Also: LispPrimitive See Also: LispCompiler Parameters: args - the list of arguments. boolean |
|
|