Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

silk
Class Procedure  view Procedure download Procedure.java

java.lang.Object
  extended bysilk.Procedure
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
Closure, Continuation, Generic, JavaConstructor, JavaField, JavaMethod, Primitive, RawConstructor, RawMethod

public abstract class Procedure
extends java.lang.Object
implements java.lang.Runnable

Abstract superclass of Procedures. Procedures of no arguments, called "thunks", implement the Runnable interface. To invoke a Procedure from Java, use apply(Pair).


Field Summary
(package private)  int maxArgs
           
(package private)  int minArgs
           
(package private)  java.lang.String name
           
 
Constructor Summary
Procedure()
           
Procedure(int minArgs, int maxArgs)
           
 
Method Summary
abstract  java.lang.Object apply(java.lang.Object[] args)
          Apply the procedure to an argument list, which is represented as a parameter-oriented array.
 java.lang.Object apply(Pair args)
          Convert an argument list into an argument array, and call apply on that.
 java.lang.Object[] makeArgArray(java.lang.Object[] code, Environment env)
          Take the code that represents a call, evaluate arguments in the calling environment and put results into an argument array.
 java.lang.Object[] makeArgArray(Pair args)
          Convert a list of arguments into an array expected by the procedure.
 int nParms()
          How many parameters does this procedure have.
 void run()
          This method will be called by whoever wishes to run your class implementing Runnable.
 java.lang.Object setName(java.lang.Object name)
          If the procedure has not yet been named, name it.
static java.lang.Object throwObject(java.lang.Object E)
           
static java.lang.Object throwRuntimeException(java.lang.RuntimeException E)
          provide scheme access to the exception throwing
 java.lang.String toString()
          Convert this Object to a human-readable String.
protected  java.lang.String toStringArgs()
           
static java.lang.Object tryCatch(java.lang.Object E, java.lang.Object F)
          provide scheme access to the "try/catch" expression of Java
static java.lang.Object tryFinally(java.lang.Object e, java.lang.Object f)
          Provide scheme access to finally - unwind-protect.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

java.lang.String name

minArgs

int minArgs

maxArgs

int maxArgs
Constructor Detail

Procedure

public Procedure()

Procedure

public Procedure(int minArgs,
                 int maxArgs)
Method Detail

setName

public java.lang.Object setName(java.lang.Object name)
If the procedure has not yet been named, name it. The idea is if I do (define (id x) x) and then (define default-proc id), then the procedure is called "id".


nParms

public int nParms()
How many parameters does this procedure have. This is different than the number of arguments it expects. For example, list expects any number of arguments, but it has only one parameter.


toStringArgs

protected java.lang.String toStringArgs()

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


run

public void run()
Description copied from interface: java.lang.Runnable
This method will be called by whoever wishes to run your class implementing Runnable. Note that there are no restrictions on what you are allowed to do in the run method, except that you cannot throw a checked exception.

Specified by:
run in interface java.lang.Runnable

apply

public abstract java.lang.Object apply(java.lang.Object[] args)
Apply the procedure to an argument list, which is represented as a parameter-oriented array. That is, if the procedure p has the parameter list (x y . z) and the call is (p 1 2 3 4) then args will be the array {1, 2, (3 4)}.


apply

public java.lang.Object apply(Pair args)
Convert an argument list into an argument array, and call apply on that.


makeArgArray

public final java.lang.Object[] makeArgArray(Pair args)
Convert a list of arguments into an array expected by the procedure. (See apply for an explanation of what is expected.)


makeArgArray

public java.lang.Object[] makeArgArray(java.lang.Object[] code,
                                       Environment env)
Take the code that represents a call, evaluate arguments in the calling environment and put results into an argument array. Note that code[0] is the procedure, not an argument. For example, (p 1 2 3 (+ 2 2)) turns into the code {p, 1, 2, 3, {+, 2, 2}}, and if p has the parameter list (x y . z) then p.makeArgArray(code, env) would return {1, 2, (3 4)}.


tryCatch

public static java.lang.Object tryCatch(java.lang.Object E,
                                        java.lang.Object F)
provide scheme access to the "try/catch" expression of Java


tryFinally

public static java.lang.Object tryFinally(java.lang.Object e,
                                          java.lang.Object f)
Provide scheme access to finally - unwind-protect.


throwRuntimeException

public static java.lang.Object throwRuntimeException(java.lang.RuntimeException E)
                                              throws java.lang.RuntimeException
provide scheme access to the exception throwing


throwObject

public static java.lang.Object throwObject(java.lang.Object E)
                                    throws java.lang.Throwable