State for a single expression or module.
For each top-level thing (expression or file) we compile or evaluate
we create a new Compilation.
CALL_WITH_CONSUMER
public static final int CALL_WITH_CONSUMER
Function results are written to the current CallContext's Consumer.
CALL_WITH_CONTINUATIONS
public static final int CALL_WITH_CONTINUATIONS
Support for full continuations. Not implemented.
CALL_WITH_RETURN
public static final int CALL_WITH_RETURN
Plain calling convention, using regular Java parameters and returns.
CALL_WITH_TAILCALLS
public static final int CALL_WITH_TAILCALLS
Like CALL_WITH_CONSUMER, but handle full on-stack-growing tail-calls.
CALL_WITH_UNSPECIFIED
public static final int CALL_WITH_UNSPECIFIED
apply0args
public static Type[] apply0args
apply0method
public static Method apply0method
apply1args
public static Type[] apply1args
apply1method
public static Method apply1method
apply2args
public static Type[] apply2args
apply2method
public static Method apply2method
apply3method
public static Method apply3method
apply4method
public static Method apply4method
applyCpsMethod
public static Method applyCpsMethod
applyNargs
public static Type[] applyNargs
applyNmethod
public static Method applyNmethod
applymethods
public static Method[] applymethods
argsCallContextField
public static Field argsCallContextField
classPrefix
public String classPrefix
If non-null: a prefix for generateClassName to prepend to names.
currentOptions
public Options currentOptions
current_scope
protected ScopeExp current_scope
debugPrintFinalExpr
public static boolean debugPrintFinalExpr
If true, print out final expressions after optimizations etc.
defaultCallConvention
public static int defaultCallConvention
The default calling convention.
One of the following CALL_WITHG_xxx values.
emitSourceDebugExtAttr
public static boolean emitSourceDebugExtAttr
exprStack
public Stack exprStack
A help vector for building expressions.
falseConstant
public static final Field falseConstant
fewerClasses
public static boolean fewerClasses
If true, minimize the number of classes generated.
Do this even if it makes things a little slower.
generateApplet
public boolean generateApplet
True if we should generate an Applet.
generateAppletDefault
public static boolean generateAppletDefault
generateMain
public boolean generateMain
True if we should generate a main(String[]) method.
generateMainDefault
public static boolean generateMainDefault
generateServlet
public boolean generateServlet
True if we should generate an Servlet.
generateServletDefault
public static boolean generateServletDefault
getCallContextInstanceMethod
public static Method getCallContextInstanceMethod
getCurrentEnvironmentMethod
public static Method getCurrentEnvironmentMethod
getLocation1EnvironmentMethod
public static final Method getLocation1EnvironmentMethod
getLocation2EnvironmentMethod
public static final Method getLocation2EnvironmentMethod
getLocationMethod
public static final Method getLocationMethod
getProcedureBindingMethod
public static final Method getProcedureBindingMethod
getSymbolProcedureMethod
public static final Method getSymbolProcedureMethod
getSymbolValueMethod
public static final Method getSymbolValueMethod
immediate
public boolean immediate
True if the compiled result will be immediately loaded.
inlineOk
public static boolean inlineOk
int1Args
public static final Type[] int1Args
javaIntegerType
public static ClassType javaIntegerType
javaStringType
public static ClassType javaStringType
lexical
public NameLookup lexical
Current lexical scope - map name to Declaration.
method
public Method method
The current method.
moduleClass
public ClassType moduleClass
Generated class that extends ModuleBody. Normally same as mainClass.
moduleStatic
public static int moduleStatic
If moduleStatic > 0, (module-static #t) is implied by default.
If moduleStatic == 2, calls run.
If moduleStatic <320, (module-static #f) is implied by default.
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.
noArgsField
public static Field noArgsField
objArrayType
public static final ArrayType objArrayType
options
public static Options options
pcCallContextField
public static Field pcCallContextField
procCallContextField
public static Field procCallContextField
scmBooleanType
public static ClassType scmBooleanType
scmKeywordType
public static ClassType scmKeywordType
scmListType
public static ClassType scmListType
scmNamedType
public static ClassType scmNamedType
scmPairType
public static ClassType scmPairType
scmSequenceType
public static ClassType scmSequenceType
scmUndefinedType
public static ClassType scmUndefinedType
string1Arg
public static final Type[] string1Arg
sym1Arg
public static final Type[] sym1Arg
trueConstant
public static final Field trueConstant
typeCallContext
public static ClassType typeCallContext
typeClassType
public static ClassType typeClassType
typeConsumer
public static final ClassType typeConsumer
typeEnvironment
public static ClassType typeEnvironment
typeLanguage
public static ClassType typeLanguage
typeLocation
public static ClassType typeLocation
typeMethodProc
public static ClassType typeMethodProc
typeModuleBody
public static ClassType typeModuleBody
typeModuleMethod
public static ClassType typeModuleMethod
typeModuleWithContext
public static ClassType typeModuleWithContext
typeObjectType
public static ClassType typeObjectType
typeProcedure
public static ClassType typeProcedure
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
typeProcedureArray
public static ClassType[] typeProcedureArray
typeProcedureN
public static ClassType typeProcedureN
typeRunnable
public static ClassType typeRunnable
typeServlet
public static ClassType typeServlet
addClass
public void addClass(ClassType new_class)
allocLocalField
public Field allocLocalField(Type type,
String name)
compile
public void compile(ModuleExp lexp,
String classname,
String prefix)
Create a new Compilation environment.
lexp
- top-level functionclassname
- name of top-level class to generateprefix
- prefix to pre-pend to the names of other (non-top) classes
compileConstant
public void compileConstant(Object value)
Emit code to "evaluate" a compile-time constant.
This is the normal external interface.
value
- the value to be compiled
compileConstant
public void compileConstant(Object value,
Target target)
compileConstantToField
public Field compileConstantToField(Object value)
compileToArchive
public void compileToArchive(ModuleExp mexp,
String fname)
throws java.io.IOException
compileToFiles
public void compileToFiles(ModuleExp mexp,
String topname,
String directory,
String prefix)
throws java.io.IOException
currentLambda
public LambdaExp currentLambda()
currentModule
public ModuleExp currentModule()
The same as getModule, until we allow nested modules.
currentScope
public ScopeExp currentScope()
demangle2
public static char demangle2(char char1,
char char2)
Demangle a three-character mangling starting with '$'.
UNFINISHED!
demangleName
public static String demangleName(String name)
demangleName
public static String demangleName(String name,
boolean reversible)
error
public void error(char severity,
String message)
error
public void error(char severity,
Declaration decl,
String msg1,
String msg2)
findNamedClass
public ClassType findNamedClass(String name)
Search this Compilation for a ClassType with a given name.
name
- the name of the class desired
- the matching ClassType, or null if none is found
freeLocalField
public void freeLocalField(Field field)
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.
generateClassName
public String generateClassName(String hint)
Generate an unused class name.
hint
- the requested name (or prefix)
generateConstructor
public final void generateConstructor(LambdaExp lexp)
generateMatchMethods
public void generateMatchMethods(LambdaExp lexp)
getBooleanOption
public final boolean getBooleanOption(String key)
Get a named boolean option.
getBooleanOption
public final boolean getBooleanOption(String key,
boolean defaultValue)
Get a named boolean option.
getColumn
public final int getColumn()
getFile
public final String getFile()
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.
getLanguage
public Language getLanguage()
getLine
public final int getLine()
getModuleType
public final ClassType getModuleType()
inlineOk
public boolean inlineOk(Procedure prcc)
isStatic
public boolean isStatic()
isValidJavaName
public static boolean isValidJavaName(String name)
letEnter
public void letEnter()
letStart
public void letStart()
loadCallContext
public final void loadCallContext()
Generate code to push the current CallContext on the JVM stack.
loadClassRef
public void loadClassRef(String className)
Generate code to load a named Class without initializing it.
lookup
public Declaration lookup(Object name,
int namespace)
loopEnter
public void loopEnter()
Done handling loop variables, and pushes them into the lexical scope.
Ready to parse the loop condition.
loopStart
public void loopStart()
Start a new loop.
(We could make this implied by the first loopVaribale call ???)
mangleName
public static String mangleName(String name)
mangleName
public static String mangleName(String name,
boolean reversible)
Convert a string to a safe Java identifier.
reversible
- if we should use an invertible mapping.
mangleNameIfNeeded
public static String mangleNameIfNeeded(String name)
mangleURI
public static String mangleURI(String name)
Map a URI to a package/class name.
Similar to the JAXB mangling, and that in the Java language spec.
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.
outputClass
public void outputClass(String directory)
throws IOException
parse
public Expression parse(Object input)
This may not make sense, except for Lisp-like languages.
For those, 'input' an s-expression from the reader.
pop
public final void pop()
pushScope
public final void pushScope(ScopeExp scope)
resolve
public Object resolve(Object name,
boolean function)
setColumn
public void setColumn(int column)
setCurrent
public static void setCurrent(Compilation comp)
setCurrentScope
public void setCurrentScope(ScopeExp scope)
Set currentScope()
.
Also update the nesting
object.
setFile
public void setFile(String filename)
setLine
public void setLine(String filename,
int line,
int column)
setLine
public final void setLine(Expression position)
setLine
public void setLine(int line)
setModule
public void setModule(ModuleExp mexp)
syntaxError
public Expression syntaxError(String message)
Handle syntax errors (at rewrite time).
message
- an error message to print out
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).
usingCPStyle
public boolean usingCPStyle()
usingTailCalls
public boolean usingTailCalls()