gnu.expr
Class Compilation

java.lang.Object
  |
  +--gnu.expr.Compilation

public class Compilation
extends java.lang.Object


Field Summary
static Type[] apply0args
           
static Method apply0method
           
static Type[] apply1args
           
static Method apply1method
           
static Type[] apply2args
           
static Method apply2method
           
static Method apply3method
           
static Method apply4method
           
static Method applyCpsMethod
           
static Method[] applymethods
           
static Type[] applyNargs
           
static Method applyNmethod
           
static Field argsCallStackField
           
static Field callerCallFrameField
           
 java.lang.String classPrefix
          If non-null: a prefix for generateClassName to prepend to names.
 ClassType curClass
           
 LambdaExp curLambda
           
static Field falseConstant
           
static boolean fewerClasses
          If true, minimize the number of classes generated.
 boolean generateApplet
          True if we should generate an Applet.
static boolean generateAppletDefault
           
 boolean generateMain
          True if we should generate a main(String[]) method.
static boolean generateMainDefault
           
static Method getBinding2Method
           
static Method getBindingEnvironmentMethod
           
static Method getCurrentEnvironmentMethod
           
static Method getLocationMethod
           
static Method getProcedureBindingMethod
           
static Type[] int1Args
           
static ClassType javaIntegerType
           
static ClassType javaStringType
           
 ClassType mainClass
           
static Method makeNullPairMethod
           
static Method makePairMethod
           
 Method method
          The current method.
static Field noArgsField
           
static Field numArgsCallFrameField
           
static ArrayType objArrayType
           
static Field pcCallStackField
           
static Method popCallStackMethod
           
static Field procCallStackField
           
static Field saved_pcCallFrameField
           
static ClassType scmBooleanType
           
static ClassType scmKeywordType
           
static ClassType scmListType
           
static ClassType scmNamedType
           
static ClassType scmPairType
           
static ClassType scmSequenceType
           
static ClassType scmSymbolType
           
static ClassType scmUndefinedType
           
static Type[] string1Arg
           
static Type[] sym1Arg
           
static ArrayType symbolArrayType
           
 Variable thisDecl
           
static Field trueConstant
           
static ClassType typeApplet
           
static ClassType typeApplyMethodContainer
           
static ClassType typeApplyMethodProc
           
static ClassType typeBinding
           
static ClassType typeBinding2
           
static ClassType typeCallFrame
           
static ClassType typeCallStack
           
static ClassType typeCpsProcedure
           
static ClassType typeEnvironment
           
static ClassType typeInterpreter
           
static ClassType typeLocation
           
static ClassType typeMacro
           
static ClassType typeModuleBody
           
static ClassType typeModuleMethod
           
static ClassType typeObject
           
static ClassType typePair
           
static ClassType typeProcedure
           
static ClassType typeProcedure0
           
static ClassType typeProcedure1
           
static ClassType typeProcedure2
           
static ClassType typeProcedure3
           
static ClassType typeProcedure4
           
static ClassType[] typeProcedureArray
           
static ClassType typeProcedureN
           
static ClassType typeString
           
static ClassType typeValues
           
static boolean usingCPStyle
           
static boolean usingTailCalls
           
static Field valueCallStackField
           
 
Constructor Summary
Compilation(LambdaExp lexp, java.lang.String classname, java.lang.String prefix, boolean immediate)
           
 
Method Summary
 void addClass(ClassType new_class)
           
 ClassType addClass(LambdaExp lexp)
          Compiles a function to a class.
 Field allocLocalField(Type type, java.lang.String name)
           
 void compileConstant(java.lang.Object value)
          Emit code to "evaluate" a compile-time constant.
 void compileConstant(java.lang.Object value, Target target)
           
 void emitLiteral(java.lang.Object value)
          Emit code to push a value.
 void error(char severity, java.lang.String message)
           
 void error(char severity, java.lang.String filename, int line, int column, java.lang.String message)
           
 void error(SourceError err)
           
 Literal findLiteral(java.lang.Object value)
           
 ClassType findNamedClass(java.lang.String name)
          Search this Compilation for a ClassType with a given name.
 void freeLocalField(Field field)
           
 void generateApplyMethods()
          Generate ModuleBody's apply0 ..
 java.lang.String generateClassName(java.lang.String hint)
          Generate an unused class name.
 Method generateConstructor(ClassType clas, LambdaExp lexp)
           
 Field getBindingField(java.lang.String name)
          Allocate a static Binding field used to access globals bindings.
 CodeAttr getCode()
           
 Interpreter getInterpreter()
           
 ClassType getMethodProcType()
           
 ClassType getModuleSuperType()
           
static java.lang.String mangleName(java.lang.String name)
          Convert a string to a safe Java identifier.
static boolean usingCPStyle()
           
static boolean usingTailCalls()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

curClass

public ClassType curClass

mainClass

public ClassType mainClass

curLambda

public LambdaExp curLambda

thisDecl

public Variable thisDecl

fewerClasses

public static boolean fewerClasses
If true, minimize the number of classes generated. Do this even if it makes things a little slower.

usingCPStyle

public static boolean usingCPStyle

usingTailCalls

public static boolean usingTailCalls

method

public Method method
The current method.

typeObject

public static ClassType typeObject

scmBooleanType

public static ClassType scmBooleanType

typeString

public static ClassType typeString

javaStringType

public static ClassType javaStringType

scmSymbolType

public static ClassType scmSymbolType

scmKeywordType

public static ClassType scmKeywordType

scmSequenceType

public static ClassType scmSequenceType

javaIntegerType

public static ClassType javaIntegerType

scmListType

public static ClassType scmListType

typePair

public static ClassType typePair

scmPairType

public static ClassType scmPairType

scmUndefinedType

public static ClassType scmUndefinedType

objArrayType

public static final ArrayType objArrayType

symbolArrayType

public static final ArrayType symbolArrayType

scmNamedType

public static ClassType scmNamedType

typeProcedure

public static ClassType typeProcedure

typeInterpreter

public static ClassType typeInterpreter

typeMacro

public static ClassType typeMacro

typeEnvironment

public static ClassType typeEnvironment

typeLocation

public static ClassType typeLocation

typeBinding

public static ClassType typeBinding

typeBinding2

public static ClassType typeBinding2

getLocationMethod

public static final Method getLocationMethod

getProcedureBindingMethod

public static final Method getProcedureBindingMethod

trueConstant

public static final Field trueConstant

falseConstant

public static final Field falseConstant

int1Args

public static final Type[] int1Args

string1Arg

public static final Type[] string1Arg

sym1Arg

public static final Type[] sym1Arg

getBindingEnvironmentMethod

public static final Method getBindingEnvironmentMethod

getBinding2Method

public static final Method getBinding2Method

getCurrentEnvironmentMethod

public static Method getCurrentEnvironmentMethod

apply0args

public static Type[] apply0args

apply1args

public static Type[] apply1args

apply2args

public static Type[] apply2args

applyNargs

public static Type[] applyNargs

makeNullPairMethod

public static final Method makeNullPairMethod

makePairMethod

public static Method makePairMethod

apply0method

public static Method apply0method

apply1method

public static Method apply1method

apply2method

public static Method apply2method

apply3method

public static Method apply3method

apply4method

public static Method apply4method

applyNmethod

public static Method applyNmethod

applymethods

public static Method[] applymethods

typeProcedure0

public static ClassType typeProcedure0

typeProcedure1

public static ClassType typeProcedure1

typeProcedure2

public static ClassType typeProcedure2

typeProcedure3

public static ClassType typeProcedure3

typeProcedure4

public static ClassType typeProcedure4

typeProcedureN

public static ClassType typeProcedureN

typeModuleBody

public static ClassType typeModuleBody

typeApplet

public static ClassType typeApplet

typeModuleMethod

public static ClassType typeModuleMethod

typeApplyMethodProc

public static ClassType typeApplyMethodProc

typeApplyMethodContainer

public static ClassType typeApplyMethodContainer

typeCallStack

public static ClassType typeCallStack

popCallStackMethod

public static Method popCallStackMethod

typeValues

public static ClassType typeValues

noArgsField

public static Field noArgsField

valueCallStackField

public static Field valueCallStackField

pcCallStackField

public static Field pcCallStackField

typeCpsProcedure

public static ClassType typeCpsProcedure

typeCallFrame

public static ClassType typeCallFrame

numArgsCallFrameField

public static Field numArgsCallFrameField

argsCallStackField

public static Field argsCallStackField

procCallStackField

public static Field procCallStackField

callerCallFrameField

public static Field callerCallFrameField

saved_pcCallFrameField

public static Field saved_pcCallFrameField

applyCpsMethod

public static Method applyCpsMethod

typeProcedureArray

public static ClassType[] typeProcedureArray

generateMainDefault

public static boolean generateMainDefault

generateMain

public boolean generateMain
True if we should generate a main(String[]) method.

generateAppletDefault

public static boolean generateAppletDefault

generateApplet

public boolean generateApplet
True if we should generate an Applet.

classPrefix

public java.lang.String classPrefix
If non-null: a prefix for generateClassName to prepend to names.
Constructor Detail

Compilation

public Compilation(LambdaExp lexp,
                   java.lang.String classname,
                   java.lang.String prefix,
                   boolean immediate)
Method Detail

getCode

public final CodeAttr getCode()

getMethodProcType

public final ClassType getMethodProcType()

getModuleSuperType

public final ClassType getModuleSuperType()

getInterpreter

public Interpreter getInterpreter()

findLiteral

public Literal findLiteral(java.lang.Object value)

emitLiteral

public void emitLiteral(java.lang.Object value)
Emit code to push a value. Only used when compiling to a file, and for internal use. Must previously have called findLiteral (to detect cycles).

compileConstant

public void compileConstant(java.lang.Object value)
Emit code to "evaluate" a compile-time constant. This is the normal external interface.
Parameters:
value - the value to be compiled

compileConstant

public void compileConstant(java.lang.Object value,
                            Target target)

findNamedClass

public ClassType findNamedClass(java.lang.String name)
Search this Compilation for a ClassType with a given name.
Parameters:
name - the name of the class desired
Returns:
the matching ClassType, or null if none is found

mangleName

public static java.lang.String mangleName(java.lang.String name)
Convert a string to a safe Java identifier. This is not invertible (since '_' is passed unchanged). This should be fixed.

generateClassName

public java.lang.String generateClassName(java.lang.String hint)
Generate an unused class name.
Parameters:
hint - the requested name (or prefix)
Returns:
a unique class name.

addClass

public void addClass(ClassType new_class)

generateConstructor

public final Method generateConstructor(ClassType clas,
                                        LambdaExp lexp)

generateApplyMethods

public void generateApplyMethods()
Generate ModuleBody's apply0 .. applyN methods. Use the applyMethods vector, which contains methods that implement the (public, readable) methods of the current module.

addClass

public final ClassType addClass(LambdaExp lexp)
Compiles a function to a class.

usingCPStyle

public static boolean usingCPStyle()

usingTailCalls

public static boolean usingTailCalls()

allocLocalField

public Field allocLocalField(Type type,
                             java.lang.String name)

freeLocalField

public void freeLocalField(Field field)

getBindingField

public Field getBindingField(java.lang.String name)
Allocate a static Binding field used to access globals bindings.

error

public void error(char severity,
                  java.lang.String message)

error

public void error(char severity,
                  java.lang.String filename,
                  int line,
                  int column,
                  java.lang.String message)

error

public void error(SourceError err)