gnu.expr
Class Compilation

java.lang.Object
  extended by gnu.expr.Compilation
All Implemented Interfaces:
SourceLocator, org.xml.sax.Locator
Direct Known Subclasses:
Translator

public class Compilation
extends java.lang.Object
implements SourceLocator

State for a single expression or module. For each top-level thing (expression or file) we compile or evaluate we create a new Compilation.


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 argsCallContextField
           
static int BODY_PARSED
          State code indicating the entire module has been parsed.
static int CALL_WITH_CONSUMER
          Function results are written to the current CallContext's Consumer.
static int CALL_WITH_CONTINUATIONS
          Support for full continuations.
static int CALL_WITH_RETURN
          Plain calling convention, using regular Java parameters and returns.
static int CALL_WITH_TAILCALLS
          Like CALL_WITH_CONSUMER, but handle full on-stack-growing tail-calls.
static int CALL_WITH_UNSPECIFIED
           
static int CLASS_WRITTEN
          State code indicating that bytecode has been written to its target.
 java.lang.String classPrefix
          If non-null: a prefix for generateClassName to prepend to names.
static java.lang.String classPrefixDefault
           
static int COMPILE_SETUP
          State code that various compile-only data has been determined.
static int COMPILED
          State code indicating the bytecode has been generated.
 ClassType curClass
           
 LambdaExp curLambda
           
protected  ScopeExp current_scope
           
 Options currentOptions
           
static boolean debugPrintExpr
          If true, print out expressions after parsing and before optimizations.
static boolean debugPrintFinalExpr
          If true, print out final expressions after optimizations etc.
static int defaultCallConvention
          The default calling convention.
static boolean emitSourceDebugExtAttr
           
static int ERROR_SEEN
           
 java.util.Stack exprStack
          A help vector for building expressions.
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
           
 boolean generateServlet
          True if we should generate an Servlet.
static boolean generateServletDefault
           
static Method getCallContextInstanceMethod
           
static Method getCurrentEnvironmentMethod
           
static Method getLocation1EnvironmentMethod
           
static Method getLocation2EnvironmentMethod
           
static Method getLocationMethod
           
static Method getProcedureBindingMethod
           
static Method getSymbolProcedureMethod
           
static Method getSymbolValueMethod
           
 boolean immediate
          True if the compiled result will be immediately loaded.
static boolean inlineOk
           
static Type[] int1Args
           
static ClassType javaIntegerType
           
static ClassType javaStringType
           
protected  Language language
           
 Lexer lexer
           
 NameLookup lexical
          Current lexical scope - map name to Declaration.
 ClassType mainClass
           
 ModuleExp mainLambda
           
protected  SourceMessages messages
           
 Method method
          The current method.
 ModuleInfo minfo
           
 ClassType moduleClass
          Generated class that extends ModuleBody.
static int moduleStatic
          If moduleStatic > 0, (module-static #t) is implied by default.
 boolean mustCompile
          True if the form is too complex to evaluate,and we must compile it.
static Field noArgsField
           
static ArrayType objArrayType
           
static Options options
           
static Field pcCallContextField
           
 java.util.Stack pendingImports
           
static Field procCallContextField
           
static int PROLOG_PARSED
          We have determined the module name and class, but not finished parsing.
static int PROLOG_PARSING
          State code for initial pre-parse looking for module name.
static int RESOLVED
          State code for lexical bindings having been resolved.
static ClassType scmBooleanType
           
static ClassType scmKeywordType
           
static ClassType scmListType
           
static ClassType scmNamedType
           
static ClassType scmPairType
           
static ClassType scmSequenceType
           
static Type[] string1Arg
           
static Type[] sym1Arg
           
 Variable thisDecl
           
static Field trueConstant
           
static ClassType typeApplet
           
static ClassType typeCallContext
           
static ClassType typeClass
           
static ClassType typeClassType
           
static ClassType typeConsumer
           
static ClassType typeEnvironment
           
static ClassType typeLanguage
           
static ClassType typeLocation
           
static ClassType typeMethodProc
           
static ClassType typeModuleBody
           
static ClassType typeModuleMethod
           
static ClassType typeModuleWithContext
           
static ClassType typeObject
           
static ClassType typeObjectType
           
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 typeRunnable
           
static ClassType typeServlet
           
static ClassType typeString
           
static ClassType typeSymbol
           
static ClassType typeType
           
static ClassType typeValues
           
static int WALKED
          State code when various inlining and optimization passes are done.
 
Constructor Summary
Compilation(boolean immediate, SourceMessages messages)
           
Compilation(Language language, SourceMessages messages)
           
Compilation(Language language, SourceMessages messages, NameLookup lexical)
           
Compilation(SourceMessages messages)
           
 
Method Summary
 void addClass(ClassType new_class)
           
 void addMainClass(ModuleExp module)
           
 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)
           
 Field compileConstantToField(java.lang.Object value)
           
 void compileToArchive(ModuleExp mexp, java.lang.String fname)
           
 LambdaExp currentLambda()
           
 ModuleExp currentModule()
          The same as getModule, until we allow nested modules.
 ScopeExp currentScope()
           
static char demangle2(char char1, char char2)
          Demangle a three-character mangling starting with '$'.
static java.lang.String demangleName(java.lang.String name)
           
static java.lang.String demangleName(java.lang.String name, boolean reversible)
           
 void error(char severity, Declaration decl, java.lang.String msg1, java.lang.String msg2)
           
 void error(char severity, java.lang.String message)
           
 void error(char severity, java.lang.String message, SourceLocator location)
           
 void error(char severity, java.lang.String message, java.lang.String code, Declaration decl)
           
static Compilation findForImmediateLiterals(int key)
           
 ClassType findNamedClass(java.lang.String name)
          Search this Compilation for a ClassType with a given name.
 void freeLocalField(Field field)
           
 void generateApplyMethodsWithContext(LambdaExp lexp)
          Generate ModuleBody's apply(CallContext) method Use the applyMethods vector, which contains methods that implement the (public, readable) methods of the current module.
 void generateApplyMethodsWithoutContext(LambdaExp lexp)
          Generate ModuleBody's apply0...applyN methods.
 java.lang.String generateClassName(java.lang.String hint)
          Generate an unused class name.
 void generateConstructor(ClassType clas, LambdaExp lexp)
           
 void generateConstructor(LambdaExp lexp)
           
 void generateMatchMethods(LambdaExp lexp)
           
 boolean getBooleanOption(java.lang.String key)
          Get a named boolean option.
 boolean getBooleanOption(java.lang.String key, boolean defaultValue)
          Get a named boolean option.
 CodeAttr getCode()
           
 int getColumnNumber()
          Return current column number.
static Method getConstructor(ClassType clas, LambdaExp lexp)
           
 Method getConstructor(LambdaExp lexp)
           
static Compilation getCurrent()
           
 java.lang.String getFileName()
          Normally same as getSystemId.
 Method getForNameHelper()
          Generate a method to find a named Class without initializing it.
 Language getLanguage()
           
 int getLineNumber()
          Return current line number.
 SourceMessages getMessages()
           
 ModuleExp getModule()
           
 ClassType getModuleType()
           
 java.lang.String getPublicId()
           
 int getState()
          Returns a code indicating how far along we are in the parsing/compilation process.
 java.lang.String getSystemId()
           
 boolean inlineOk(Expression proc)
           
 boolean inlineOk(Procedure proc)
           
 boolean isPedantic()
           
 boolean isStableSourceLocation()
          True if position is unlikely to change.
 boolean isStatic()
           
static boolean isValidJavaName(java.lang.String name)
           
 LetExp letDone(Expression body)
           
 void letEnter()
           
 void letStart()
           
 Declaration letVariable(java.lang.Object name, Type type, Expression init)
           
 void loadCallContext()
          Generate code to push the current CallContext on the JVM stack.
 void loadClassRef(ClassType clas)
           
 void loadClassRef(java.lang.String className)
          Generate code to load a named Class without initializing it.
 Declaration lookup(java.lang.Object name, int namespace)
           
 void loopBody(Expression body)
           
 void loopCond(Expression cond)
           
 void loopEnter()
          Done handling loop variables, and pushes them into the lexical scope.
 Expression loopRepeat()
           
 Expression loopRepeat(Expression exp)
           
 Expression loopRepeat(Expression[] exps)
           
 void loopStart()
          Start a new loop.
 Declaration loopVariable(java.lang.Object name, Type type, Expression init)
           
static java.lang.String mangleName(java.lang.String name)
           
static java.lang.String mangleName(java.lang.String name, boolean reversible)
          Convert a string to a safe Java identifier.
static java.lang.String mangleName(java.lang.String name, int kind)
          Convert a string to a safe Java identifier.
static java.lang.String mangleNameIfNeeded(java.lang.String name)
           
static java.lang.String mangleURI(java.lang.String name)
          Map a URI to a package/class name.
 void mustCompileHere()
          Note that we have seen a construct that must be compiled, not evaluated.
 void outputClass(java.lang.String directory)
           
 Expression parse(java.lang.Object input)
          This may not make sense, except for Lisp-like languages.
 void pop()
           
 void pop(ScopeExp scope)
           
 void process(int wantedState)
          Parse/walk/compile this module as needed and requested.
 void push(Declaration decl)
           
 void push(ScopeExp scope)
           
 ModuleExp pushNewModule(Lexer lexer)
           
 ModuleExp pushNewModule(java.lang.String filename)
           
 void pushPendingImport(ModuleInfo info, ScopeExp defs)
           
 void pushScope(ScopeExp scope)
           
static int registerForImmediateLiterals(Compilation comp)
           
 java.lang.Object resolve(java.lang.Object name, boolean function)
           
 void setColumn(int column)
           
static void setCurrent(Compilation comp)
           
 void setCurrentScope(ScopeExp scope)
          Set currentScope().
 void setFile(java.lang.String filename)
           
 void setLine(Expression position)
           
 void setLine(int line)
           
 void setLine(java.lang.Object location)
           
 void setLine(java.lang.String filename, int line, int column)
           
 void setLocation(SourceLocator position)
           
 void setMessages(SourceMessages messages)
           
 void setModule(ModuleExp mexp)
           
 void setState(int state)
           
static void setupLiterals(int key)
          Call-back from compiled code to initialize literals in immediate mode.
 Expression syntaxError(java.lang.String message)
          Handle syntax errors (at rewrite time).
 java.lang.String toString()
           
 void usedClass(Type type)
          Called for classes referenced in bytecode.
 boolean usingCPStyle()
           
 boolean usingTailCalls()
           
 void walkModule(ModuleExp mexp)
          Shared processing for both compiling/eval.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mustCompile

public boolean mustCompile
True if the form is too complex to evaluate,and we must compile it. This is because it contains a construct we know how to compile, but not evaluate, and it it outside a function (which we always compile). This can be a let scope, or primitive procedure.


curClass

public ClassType curClass

mainClass

public ClassType mainClass

moduleClass

public ClassType moduleClass
Generated class that extends ModuleBody. Normally same as mainClass.


curLambda

public LambdaExp curLambda

mainLambda

public ModuleExp mainLambda

thisDecl

public Variable thisDecl

PROLOG_PARSING

public static final int PROLOG_PARSING
State code for initial pre-parse looking for module name.

See Also:
Constant Field Values

PROLOG_PARSED

public static final int PROLOG_PARSED
We have determined the module name and class, but not finished parsing.

See Also:
Constant Field Values

BODY_PARSED

public static final int BODY_PARSED
State code indicating the entire module has been parsed.

See Also:
Constant Field Values

RESOLVED

public static final int RESOLVED
State code for lexical bindings having been resolved.

See Also:
Constant Field Values

WALKED

public static final int WALKED
State code when various inlining and optimization passes are done.

See Also:
Constant Field Values

COMPILE_SETUP

public static final int COMPILE_SETUP
State code that various compile-only data has been determined.

See Also:
Constant Field Values

COMPILED

public static final int COMPILED
State code indicating the bytecode has been generated.

See Also:
Constant Field Values

CLASS_WRITTEN

public static final int CLASS_WRITTEN
State code indicating that bytecode has been written to its target.

See Also:
Constant Field Values

ERROR_SEEN

public static final int ERROR_SEEN
See Also:
Constant Field Values

minfo

public ModuleInfo minfo

lexer

public Lexer lexer

pendingImports

public java.util.Stack pendingImports

fewerClasses

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


debugPrintExpr

public static boolean debugPrintExpr
If true, print out expressions after parsing and before optimizations.


debugPrintFinalExpr

public static boolean debugPrintFinalExpr
If true, print out final expressions after optimizations etc.


options

public static Options options

currentOptions

public Options currentOptions

defaultCallConvention

public static int defaultCallConvention
The default calling convention. One of the following CALL_WITHG_xxx values.


CALL_WITH_UNSPECIFIED

public static final int CALL_WITH_UNSPECIFIED
See Also:
Constant Field Values

CALL_WITH_RETURN

public static final int CALL_WITH_RETURN
Plain calling convention, using regular Java parameters and returns.

See Also:
Constant Field Values

CALL_WITH_CONSUMER

public static final int CALL_WITH_CONSUMER
Function results are written to the current CallContext's Consumer.

See Also:
Constant Field Values

CALL_WITH_TAILCALLS

public static final int CALL_WITH_TAILCALLS
Like CALL_WITH_CONSUMER, but handle full on-stack-growing tail-calls.

See Also:
Constant Field Values

CALL_WITH_CONTINUATIONS

public static final int CALL_WITH_CONTINUATIONS
Support for full continuations. Not implemented.

See Also:
Constant Field Values

moduleStatic

public static int moduleStatic
If moduleStatic > 0, (module-static #t) is implied by default. If moduleStatic == 2, calls run. If moduleStatic < 0, (module-static #f) is implied by default.


immediate

public boolean immediate
True if the compiled result will be immediately loaded.


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

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

objArrayType

public static final ArrayType objArrayType

scmNamedType

public static ClassType scmNamedType

typeRunnable

public static ClassType typeRunnable

typeType

public static ClassType typeType

typeObjectType

public static ClassType typeObjectType

typeClass

public static ClassType typeClass

typeClassType

public static ClassType typeClassType

typeProcedure

public static ClassType typeProcedure

typeLanguage

public static ClassType typeLanguage

typeEnvironment

public static ClassType typeEnvironment

typeLocation

public static ClassType typeLocation

typeSymbol

public static ClassType typeSymbol

getSymbolValueMethod

public static final Method getSymbolValueMethod

getSymbolProcedureMethod

public static final Method getSymbolProcedureMethod

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

getLocation1EnvironmentMethod

public static final Method getLocation1EnvironmentMethod

getLocation2EnvironmentMethod

public static final Method getLocation2EnvironmentMethod

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

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

typeModuleWithContext

public static ClassType typeModuleWithContext

typeApplet

public static ClassType typeApplet

typeServlet

public static ClassType typeServlet

typeCallContext

public static ClassType typeCallContext

typeConsumer

public static final ClassType typeConsumer

getCallContextInstanceMethod

public static Method getCallContextInstanceMethod

typeValues

public static ClassType typeValues

noArgsField

public static Field noArgsField

pcCallContextField

public static Field pcCallContextField

typeMethodProc

public static ClassType typeMethodProc

typeModuleMethod

public static ClassType typeModuleMethod

argsCallContextField

public static Field argsCallContextField

procCallContextField

public static Field procCallContextField

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.


generateServletDefault

public static boolean generateServletDefault

generateServlet

public boolean generateServlet
True if we should generate an Servlet.


inlineOk

public static boolean inlineOk

classPrefixDefault

public static java.lang.String classPrefixDefault

classPrefix

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


emitSourceDebugExtAttr

public static boolean emitSourceDebugExtAttr

language

protected Language language

exprStack

public java.util.Stack exprStack
A help vector for building expressions.


lexical

public NameLookup lexical
Current lexical scope - map name to Declaration.


current_scope

protected ScopeExp current_scope

messages

protected SourceMessages messages
Constructor Detail

Compilation

public Compilation(boolean immediate,
                   SourceMessages messages)

Compilation

public Compilation(SourceMessages messages)

Compilation

public Compilation(Language language,
                   SourceMessages messages)

Compilation

public Compilation(Language language,
                   SourceMessages messages,
                   NameLookup lexical)
Method Detail

getState

public int getState()
Returns a code indicating how far along we are in the parsing/compilation process.


setState

public void setState(int state)

isPedantic

public boolean isPedantic()

pushPendingImport

public void pushPendingImport(ModuleInfo info,
                              ScopeExp defs)

getBooleanOption

public final boolean getBooleanOption(java.lang.String key,
                                      boolean defaultValue)
Get a named boolean option.


getBooleanOption

public final boolean getBooleanOption(java.lang.String key)
Get a named boolean option.


usingCPStyle

public boolean usingCPStyle()

usingTailCalls

public boolean usingTailCalls()

getCode

public final CodeAttr getCode()

getModuleType

public final ClassType getModuleType()

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

compileConstantToField

public Field compileConstantToField(java.lang.Object value)

inlineOk

public boolean inlineOk(Expression proc)

inlineOk

public boolean inlineOk(Procedure proc)

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

mangleURI

public static java.lang.String mangleURI(java.lang.String name)
Map a URI to a package/class name. Similar to the JAXB mangling, and that in the Java language spec.


mangleName

public static java.lang.String mangleName(java.lang.String name)

mangleNameIfNeeded

public static java.lang.String mangleNameIfNeeded(java.lang.String name)

isValidJavaName

public static boolean isValidJavaName(java.lang.String name)

mangleName

public static java.lang.String mangleName(java.lang.String name,
                                          boolean reversible)
Convert a string to a safe Java identifier.

Parameters:
reversible - if we should use an invertible mapping.

mangleName

public static java.lang.String mangleName(java.lang.String name,
                                          int kind)
Convert a string to a safe Java identifier.

Parameters:
kind - -1 - non-reversible; 0: reversible, except that '$' is not mapped; 1: reversible

demangle2

public static char demangle2(char char1,
                             char char2)
Demangle a three-character mangling starting with '$'. UNFINISHED!


demangleName

public static java.lang.String demangleName(java.lang.String name)

demangleName

public static java.lang.String demangleName(java.lang.String name,
                                            boolean reversible)

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.

walkModule

public void walkModule(ModuleExp mexp)
Shared processing for both compiling/eval.


outputClass

public void outputClass(java.lang.String directory)
                 throws java.io.IOException
Throws:
java.io.IOException

compileToArchive

public void compileToArchive(ModuleExp mexp,
                             java.lang.String fname)
                      throws java.io.IOException
Throws:
java.io.IOException

addClass

public void addClass(ClassType new_class)

addMainClass

public void addMainClass(ModuleExp module)

getConstructor

public final Method getConstructor(LambdaExp lexp)

getConstructor

public static final Method getConstructor(ClassType clas,
                                          LambdaExp lexp)

generateConstructor

public final void generateConstructor(LambdaExp lexp)

generateConstructor

public final void generateConstructor(ClassType clas,
                                      LambdaExp lexp)

generateMatchMethods

public void generateMatchMethods(LambdaExp lexp)

generateApplyMethodsWithContext

public void generateApplyMethodsWithContext(LambdaExp lexp)
Generate ModuleBody's apply(CallContext) method Use the applyMethods vector, which contains methods that implement the (public, readable) methods of the current module.


generateApplyMethodsWithoutContext

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


process

public void process(int wantedState)
Parse/walk/compile this module as needed and requested. This method does not process any dependent modules (expect indirectly, such as may be done by a require form).

Parameters:
wantedState - the desired value of getState().

allocLocalField

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

loadCallContext

public final void loadCallContext()
Generate code to push the current CallContext on the JVM stack.


freeLocalField

public void freeLocalField(Field field)

parse

public Expression parse(java.lang.Object input)
This may not make sense, except for Lisp-like languages. For those, 'input' an s-expression from the reader.


getLanguage

public Language getLanguage()

currentLambda

public LambdaExp currentLambda()

getModule

public final ModuleExp getModule()

setModule

public void setModule(ModuleExp mexp)

isStatic

public boolean isStatic()

currentModule

public ModuleExp currentModule()
The same as getModule, until we allow nested modules.


mustCompileHere

public void mustCompileHere()
Note that we have seen a construct that must be compiled, not evaluated. If we are not inside a lambda (which is always compiled), but only inside the outer-most ModuleExp, note that it must be compiled.


currentScope

public ScopeExp currentScope()

setCurrentScope

public void setCurrentScope(ScopeExp scope)
Set currentScope(). Also update the nesting object.


pushNewModule

public ModuleExp pushNewModule(Lexer lexer)

pushNewModule

public ModuleExp pushNewModule(java.lang.String filename)

push

public void push(ScopeExp scope)

pushScope

public final void pushScope(ScopeExp scope)

pop

public void pop(ScopeExp scope)

pop

public final void pop()

push

public void push(Declaration decl)

lookup

public Declaration lookup(java.lang.Object name,
                          int namespace)

usedClass

public void usedClass(Type type)
Called for classes referenced in bytecode. Since this only does something when immediate, we only care about classes referenced in the bytecode when immediate. It is used to ensure that we can inherit from classes defines when in immediate mode (in Scheme using define-class or similar).


getMessages

public SourceMessages getMessages()

setMessages

public void setMessages(SourceMessages messages)

error

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

error

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

error

public void error(char severity,
                  Declaration decl,
                  java.lang.String msg1,
                  java.lang.String msg2)

error

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

syntaxError

public Expression syntaxError(java.lang.String message)
Handle syntax errors (at rewrite time).

Parameters:
message - an error message to print out
Returns:
an ErrorExp

getLineNumber

public final int getLineNumber()
Description copied from interface: SourceLocator
Return current line number. The "first" line is line 1; unknown is -1.

Specified by:
getLineNumber in interface SourceLocator
Specified by:
getLineNumber in interface org.xml.sax.Locator

getColumnNumber

public final int getColumnNumber()
Description copied from interface: SourceLocator
Return current column number. The "first" column is column 1; unknown is -1.

Specified by:
getColumnNumber in interface SourceLocator
Specified by:
getColumnNumber in interface org.xml.sax.Locator

getFileName

public final java.lang.String getFileName()
Description copied from interface: SourceLocator
Normally same as getSystemId.

Specified by:
getFileName in interface SourceLocator

getPublicId

public java.lang.String getPublicId()
Specified by:
getPublicId in interface SourceLocator
Specified by:
getPublicId in interface org.xml.sax.Locator

getSystemId

public java.lang.String getSystemId()
Specified by:
getSystemId in interface SourceLocator
Specified by:
getSystemId in interface org.xml.sax.Locator

isStableSourceLocation

public boolean isStableSourceLocation()
Description copied from interface: SourceLocator
True if position is unlikely to change. True for an expression but not an input file.

Specified by:
isStableSourceLocation in interface SourceLocator

setFile

public void setFile(java.lang.String filename)

setLine

public void setLine(int line)

setColumn

public void setColumn(int column)

setLine

public final void setLine(Expression position)

setLine

public void setLine(java.lang.Object location)

setLocation

public final void setLocation(SourceLocator position)

setLine

public void setLine(java.lang.String filename,
                    int line,
                    int column)

letStart

public void letStart()

letVariable

public Declaration letVariable(java.lang.Object name,
                               Type type,
                               Expression init)

letEnter

public void letEnter()

letDone

public LetExp letDone(Expression body)

loopStart

public void loopStart()
Start a new loop. (We could make this implied by the first loopVaribale call ???)


loopVariable

public Declaration loopVariable(java.lang.Object name,
                                Type type,
                                Expression init)

loopEnter

public void loopEnter()
Done handling loop variables, and pushes them into the lexical scope. Ready to parse the loop condition.


loopCond

public void loopCond(Expression cond)

loopBody

public void loopBody(Expression body)

loopRepeat

public Expression loopRepeat(Expression[] exps)

loopRepeat

public Expression loopRepeat()

loopRepeat

public Expression loopRepeat(Expression exp)

loadClassRef

public void loadClassRef(ClassType clas)

loadClassRef

public void loadClassRef(java.lang.String className)
Generate code to load a named Class without initializing it.


getForNameHelper

public Method getForNameHelper()
Generate a method to find a named Class without initializing it. Generate a static helper method "class$" like javac generates for 'CLASS.class', but does not initialize CLASS. Also, we don't bother catching exceptions, since the JVM doesn't require us to. I.e. generates: public static class $(String name) { return Class.forName(name, false, Class.forName(THISCLASSNAME).getClassLoader()); } Note that we want the result to use the same ClassLoader as the caller, which is why we generate a static helper method.


resolve

public java.lang.Object resolve(java.lang.Object name,
                                boolean function)

setupLiterals

public static void setupLiterals(int key)
Call-back from compiled code to initialize literals in immediate mode. In non-immediate mode (i.e. generating class files) the compiler emits code to "re-construct" literal values. However, in immediate mode that would be wasteful, plus we would get values that are similar (equals) to but not necessarily identical (eq) to the compile-time literal. So we need to pass the literal values to the compiled code, by using reflectiion to initialize various static fields. This method does that. It is called from start of the the generated static initializer, which helps makes things more consistent between immediate and non-immediate mode.


registerForImmediateLiterals

public static int registerForImmediateLiterals(Compilation comp)

findForImmediateLiterals

public static Compilation findForImmediateLiterals(int key)

getCurrent

public static Compilation getCurrent()

setCurrent

public static void setCurrent(Compilation comp)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object