|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgnu.expr.Compilation
public class Compilation
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 int |
defaultClassFileVersion
|
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 |
cleanupAfterCompilation()
|
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(ObjectType clas)
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 |
---|
public boolean mustCompile
public ClassType curClass
public ClassType mainClass
public ClassType moduleClass
public LambdaExp curLambda
public ModuleExp mainLambda
public Variable thisDecl
public static final int PROLOG_PARSING
public static final int PROLOG_PARSED
public static final int BODY_PARSED
public static final int RESOLVED
public static final int WALKED
public static final int COMPILE_SETUP
public static final int COMPILED
public static final int CLASS_WRITTEN
public static final int ERROR_SEEN
public ModuleInfo minfo
public Lexer lexer
public java.util.Stack pendingImports
public static boolean fewerClasses
public static boolean debugPrintExpr
public static boolean debugPrintFinalExpr
public static Options options
public Options currentOptions
public static int defaultClassFileVersion
public static int defaultCallConvention
public static final int CALL_WITH_UNSPECIFIED
public static final int CALL_WITH_RETURN
public static final int CALL_WITH_CONSUMER
public static final int CALL_WITH_TAILCALLS
public static final int CALL_WITH_CONTINUATIONS
public static int moduleStatic
public boolean immediate
public Method method
public static ClassType typeObject
public static ClassType scmBooleanType
public static ClassType typeString
public static ClassType javaStringType
public static ClassType scmKeywordType
public static ClassType scmSequenceType
public static ClassType javaIntegerType
public static ClassType scmListType
public static ClassType typePair
public static ClassType scmPairType
public static final ArrayType objArrayType
public static ClassType scmNamedType
public static ClassType typeRunnable
public static ClassType typeType
public static ClassType typeObjectType
public static ClassType typeClass
public static ClassType typeClassType
public static ClassType typeProcedure
public static ClassType typeLanguage
public static ClassType typeEnvironment
public static ClassType typeLocation
public static ClassType typeSymbol
public static final Method getSymbolValueMethod
public static final Method getSymbolProcedureMethod
public static final Method getLocationMethod
public static final Method getProcedureBindingMethod
public static final Field trueConstant
public static final Field falseConstant
public static final Type[] int1Args
public static final Type[] string1Arg
public static final Type[] sym1Arg
public static final Method getLocation1EnvironmentMethod
public static final Method getLocation2EnvironmentMethod
public static Method getCurrentEnvironmentMethod
public static Type[] apply0args
public static Type[] apply1args
public static Type[] apply2args
public static Type[] applyNargs
public static Method apply0method
public static Method apply1method
public static Method apply2method
public static Method apply3method
public static Method apply4method
public static Method applyNmethod
public static Method[] applymethods
public static ClassType typeProcedure0
public static ClassType typeProcedure1
public static ClassType typeProcedure2
public static ClassType typeProcedure3
public static ClassType typeProcedure4
public static ClassType typeProcedureN
public static ClassType typeModuleBody
public static ClassType typeModuleWithContext
public static ClassType typeApplet
public static ClassType typeServlet
public static ClassType typeCallContext
public static final ClassType typeConsumer
public static Method getCallContextInstanceMethod
public static ClassType typeValues
public static Field noArgsField
public static Field pcCallContextField
public static ClassType typeMethodProc
public static ClassType typeModuleMethod
public static Field argsCallContextField
public static Field procCallContextField
public static Method applyCpsMethod
public static ClassType[] typeProcedureArray
public static boolean generateMainDefault
public boolean generateMain
public static boolean generateAppletDefault
public boolean generateApplet
public static boolean generateServletDefault
public boolean generateServlet
public static boolean inlineOk
public static java.lang.String classPrefixDefault
public java.lang.String classPrefix
public static boolean emitSourceDebugExtAttr
protected Language language
public java.util.Stack exprStack
public NameLookup lexical
protected ScopeExp current_scope
protected SourceMessages messages
Constructor Detail |
---|
public Compilation(boolean immediate, SourceMessages messages)
public Compilation(SourceMessages messages)
public Compilation(Language language, SourceMessages messages)
public Compilation(Language language, SourceMessages messages, NameLookup lexical)
Method Detail |
---|
public int getState()
public void setState(int state)
public boolean isPedantic()
public void pushPendingImport(ModuleInfo info, ScopeExp defs)
public final boolean getBooleanOption(java.lang.String key, boolean defaultValue)
public final boolean getBooleanOption(java.lang.String key)
public boolean usingCPStyle()
public boolean usingTailCalls()
public final CodeAttr getCode()
public final ClassType getModuleType()
public void compileConstant(java.lang.Object value)
value
- the value to be compiledpublic Field compileConstantToField(java.lang.Object value)
public boolean inlineOk(Expression proc)
public boolean inlineOk(Procedure proc)
public void compileConstant(java.lang.Object value, Target target)
public ClassType findNamedClass(java.lang.String name)
name
- the name of the class desired
public static java.lang.String mangleURI(java.lang.String name)
public static java.lang.String mangleName(java.lang.String name)
public static java.lang.String mangleNameIfNeeded(java.lang.String name)
public static boolean isValidJavaName(java.lang.String name)
public static java.lang.String mangleName(java.lang.String name, boolean reversible)
reversible
- if we should use an invertible mapping.public static java.lang.String mangleName(java.lang.String name, int kind)
kind
- -1 - non-reversible;
0: reversible, except that '$' is not mapped;
1: reversiblepublic static char demangle2(char char1, char char2)
public static java.lang.String demangleName(java.lang.String name)
public static java.lang.String demangleName(java.lang.String name, boolean reversible)
public java.lang.String generateClassName(java.lang.String hint)
hint
- the requested name (or prefix)
public void walkModule(ModuleExp mexp)
public void outputClass(java.lang.String directory) throws java.io.IOException
java.io.IOException
public void cleanupAfterCompilation()
public void compileToArchive(ModuleExp mexp, java.lang.String fname) throws java.io.IOException
java.io.IOException
public void addClass(ClassType new_class)
public void addMainClass(ModuleExp module)
public final Method getConstructor(LambdaExp lexp)
public static final Method getConstructor(ClassType clas, LambdaExp lexp)
public final void generateConstructor(LambdaExp lexp)
public final void generateConstructor(ClassType clas, LambdaExp lexp)
public void generateMatchMethods(LambdaExp lexp)
public void generateApplyMethodsWithContext(LambdaExp lexp)
public void generateApplyMethodsWithoutContext(LambdaExp lexp)
public void process(int wantedState)
wantedState
- the desired value of getState().public Field allocLocalField(Type type, java.lang.String name)
public final void loadCallContext()
public void freeLocalField(Field field)
public Expression parse(java.lang.Object input)
public Language getLanguage()
public LambdaExp currentLambda()
public final ModuleExp getModule()
public void setModule(ModuleExp mexp)
public boolean isStatic()
public ModuleExp currentModule()
public void mustCompileHere()
public ScopeExp currentScope()
public void setCurrentScope(ScopeExp scope)
currentScope()
.
Also update the nesting
object.
public ModuleExp pushNewModule(Lexer lexer)
public ModuleExp pushNewModule(java.lang.String filename)
public void push(ScopeExp scope)
public final void pushScope(ScopeExp scope)
public void pop(ScopeExp scope)
public final void pop()
public void push(Declaration decl)
public Declaration lookup(java.lang.Object name, int namespace)
public void usedClass(Type type)
public SourceMessages getMessages()
public void setMessages(SourceMessages messages)
public void error(char severity, java.lang.String message, SourceLocator location)
public void error(char severity, java.lang.String message)
public void error(char severity, Declaration decl, java.lang.String msg1, java.lang.String msg2)
public void error(char severity, java.lang.String message, java.lang.String code, Declaration decl)
public Expression syntaxError(java.lang.String message)
message
- an error message to print out
public final int getLineNumber()
SourceLocator
getLineNumber
in interface javax.xml.transform.SourceLocator
getLineNumber
in interface org.xml.sax.Locator
public final int getColumnNumber()
SourceLocator
getColumnNumber
in interface javax.xml.transform.SourceLocator
getColumnNumber
in interface org.xml.sax.Locator
public final java.lang.String getFileName()
SourceLocator
public java.lang.String getPublicId()
getPublicId
in interface javax.xml.transform.SourceLocator
getPublicId
in interface org.xml.sax.Locator
public java.lang.String getSystemId()
getSystemId
in interface javax.xml.transform.SourceLocator
getSystemId
in interface org.xml.sax.Locator
public boolean isStableSourceLocation()
SourceLocator
public void setFile(java.lang.String filename)
public void setLine(int line)
public void setColumn(int column)
public final void setLine(Expression position)
public void setLine(java.lang.Object location)
public final void setLocation(SourceLocator position)
public void setLine(java.lang.String filename, int line, int column)
public void letStart()
public Declaration letVariable(java.lang.Object name, Type type, Expression init)
public void letEnter()
public LetExp letDone(Expression body)
public void loopStart()
public Declaration loopVariable(java.lang.Object name, Type type, Expression init)
public void loopEnter()
public void loopCond(Expression cond)
public void loopBody(Expression body)
public Expression loopRepeat(Expression[] exps)
public Expression loopRepeat()
public Expression loopRepeat(Expression exp)
public void loadClassRef(ObjectType clas)
public Method getForNameHelper()
public java.lang.Object resolve(java.lang.Object name, boolean function)
public static void setupLiterals(int key)
public static int registerForImmediateLiterals(Compilation comp)
public static Compilation findForImmediateLiterals(int key)
public static Compilation getCurrent()
public static void setCurrent(Compilation comp)
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |