public class UnitCompiler
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
(package private) static interface |
UnitCompiler.Compilable
Helper interface for string conversion.
|
static class |
UnitCompiler.SimpleIField
Short-hand implementation of
IClass.IField that implements a non-constant, non-static,
package-accessible field. |
| Modifier and Type | Field and Description |
|---|---|
private CodeContext |
codeContext |
private Java.CompilationUnit |
compilationUnit |
private int |
compileErrorCount |
private static boolean |
DEBUG |
private boolean |
debugLines |
private boolean |
debugSource |
private boolean |
debugVars |
private java.util.List<ClassFile> |
generatedClassFiles |
private IClassLoader |
iClassLoader |
static boolean |
JUMP_IF_FALSE
Special value for the
orientation parameter of the compileBoolean(Java.Rvalue,
CodeContext.Offset, boolean) methods, indicating that the code should be generated such that execution branches
if the value on top of the operand stack is FALSE. |
static boolean |
JUMP_IF_TRUE
Special value for the
orientation parameter of the compileBoolean(Java.Rvalue,
CodeContext.Offset, boolean) methods, indicating that the code should be generated such that execution branches
if the value on top of the operand stack is TRUE. |
static java.lang.Object |
NOT_CONSTANT
Special return value for the
getConstantValue(Java.Rvalue) method family indicating that the given
Java.Rvalue does not evaluate to a constant value. |
private java.util.Map<java.lang.String,IClass> |
onDemandImportableTypes
To be used only by
importTypeOnDemand(String, Location); cache for on-demand-imported types. |
private ErrorHandler |
optionalCompileErrorHandler |
private WarningHandler |
optionalWarningHandler |
private static java.util.Map<java.lang.String,byte[]> |
PRIMITIVE_NARROWING_CONVERSIONS |
private static java.util.Map<java.lang.String,byte[]> |
PRIMITIVE_WIDENING_CONVERSIONS |
private java.util.Map<java.lang.String,java.util.List<java.lang.Object>> |
singleStaticImports |
private java.util.Map<java.lang.String,java.lang.String[]> |
singleTypeImports
To be used only by
getSingleTypeImport(String, Location); null means "not yet initialized" |
private java.util.Collection<IClass> |
staticImportsOnDemand |
private static int |
STRING_CONCAT_LIMIT
This constant determines the number of operands up to which the
|
private java.util.Collection<java.lang.String[]> |
typeImportsOnDemand
To be used only by
importTypeOnDemand(String, Location); null means "not yet initialized. |
| Constructor and Description |
|---|
UnitCompiler(Java.CompilationUnit compilationUnit,
IClassLoader iClassLoader) |
| Modifier and Type | Method and Description |
|---|---|
private short |
addConstantFloatInfo(float value) |
private short |
addConstantIntegerInfo(int value) |
private short |
addConstantStringInfo(java.lang.String value) |
private void |
addFields(Java.FieldDeclaration fd,
ClassFile cf)
Creates
ClassFile.FieldInfos for all fields declared by the given Java.FieldDeclaration. |
private static java.lang.String[] |
allButLast(java.lang.String[] sa) |
private void |
assignmentConversion(Java.Locatable locatable,
IClass sourceType,
IClass targetType,
java.lang.Object optionalConstantValue)
Implements "assignment conversion" (JLS7 5.2).
|
private java.lang.Object |
assignmentConversion(Java.Locatable locatable,
java.lang.Object value,
IClass targetType)
Implements "assignment conversion" (JLS7 5.2) on a constant value.
|
(package private) void |
assignSyntheticParametersToSyntheticFields(Java.ConstructorDeclarator cd)
Copies the values of the synthetic parameters of this constructor ("this$..." and "val$...") to the synthetic
fields of the object ("this$..." and "val$...").
|
private IClass |
binaryNumericPromotion(Java.Locatable locatable,
IClass type1,
CodeContext.Inserter convertInserter1,
IClass type2)
Implements "binary numeric promotion" (5.6.2)
|
private IClass |
binaryNumericPromotion(Java.Locatable locatable,
IClass type1,
CodeContext.Inserter convertInserter1,
IClass type2,
CodeContext.Inserter convertInserter2)
Implements "binary numeric promotion" (5.6.2), which may perform unboxing conversion.
|
private IClass |
binaryNumericPromotionType(Java.Locatable locatable,
IClass type1,
IClass type2) |
private void |
boxingConversion(Java.Locatable locatable,
IClass sourceType,
IClass targetType) |
private void |
buildLocalVariableMap(Java.Block block,
java.util.Map<java.lang.String,Java.LocalVariable> localVars) |
private java.util.Map<java.lang.String,Java.LocalVariable> |
buildLocalVariableMap(Java.BlockStatement blockStatement,
java.util.Map<java.lang.String,Java.LocalVariable> localVars)
Computes and fills in the 'local variable map' for the given
blockStatement. |
protected void |
buildLocalVariableMap(Java.CatchClause catchClause,
java.util.Map<java.lang.String,Java.LocalVariable> localVars)
Adds the given
localVars to the 'local variable map' of the given catchClause. |
private static java.util.Map<java.lang.String,Java.LocalVariable> |
buildLocalVariableMap(Java.ConstructorInvocation ci,
java.util.Map<java.lang.String,Java.LocalVariable> localVars) |
private void |
buildLocalVariableMap(Java.DoStatement ds,
java.util.Map<java.lang.String,Java.LocalVariable> localVars) |
private void |
buildLocalVariableMap(Java.ForEachStatement fes,
java.util.Map<java.lang.String,Java.LocalVariable> localVars) |
private void |
buildLocalVariableMap(Java.ForStatement fs,
java.util.Map<java.lang.String,Java.LocalVariable> localVars) |
private void |
buildLocalVariableMap(Java.FunctionDeclarator fd) |
private void |
buildLocalVariableMap(Java.IfStatement is,
java.util.Map<java.lang.String,Java.LocalVariable> localVars) |
private void |
buildLocalVariableMap(Java.Initializer i,
java.util.Map<java.lang.String,Java.LocalVariable> localVars) |
private java.util.Map<java.lang.String,Java.LocalVariable> |
buildLocalVariableMap(Java.LabeledStatement ls,
java.util.Map<java.lang.String,Java.LocalVariable> localVars) |
private java.util.Map<java.lang.String,Java.LocalVariable> |
buildLocalVariableMap(Java.LocalVariableDeclarationStatement lvds,
java.util.Map<java.lang.String,Java.LocalVariable> localVars) |
private static java.util.Map<java.lang.String,Java.LocalVariable> |
buildLocalVariableMap(Java.Statement s,
java.util.Map<java.lang.String,Java.LocalVariable> localVars) |
private void |
buildLocalVariableMap(Java.SwitchStatement ss,
java.util.Map<java.lang.String,Java.LocalVariable> localVars) |
private void |
buildLocalVariableMap(Java.SynchronizedStatement ss,
java.util.Map<java.lang.String,Java.LocalVariable> localVars) |
private void |
buildLocalVariableMap(Java.TryStatement ts,
java.util.Map<java.lang.String,Java.LocalVariable> localVars) |
private void |
buildLocalVariableMap(Java.WhileStatement ws,
java.util.Map<java.lang.String,Java.LocalVariable> localVars) |
private void |
checkAccessible(IClass.IMember member,
Java.BlockStatement contextBlockStatement)
Checks whether the given
IClass.IMember is accessible in the given context, according to JLS7
6.6.1.BL1.B4. |
private void |
checkAccessible(IClass iClassDeclaringMember,
Access memberAccess,
Java.BlockStatement contextBlockStatement)
Verifies that a member (class, interface, field or method) declared in a given class is accessible from a given
block statement context, according to JLS7 6.6.1.4.
|
private void |
checkAccessible(IClass type,
Java.BlockStatement contextBlockStatement)
Checks whether the given
IClass is accessible in the given context, according to JLS7 6.6.1.2 and
6.6.1.4. |
private void |
checkThrownException(Java.Locatable locatable,
IClass type,
Java.Scope scope) |
private void |
checkThrownExceptions(Java.Invocation in,
IClass.IMethod iMethod) |
private boolean |
compile(Java.BlockStatement bs) |
private void |
compile(Java.FunctionDeclarator fd,
ClassFile classFile) |
private void |
compile(Java.Rvalue rv)
Some
Java.Rvalues compile more efficiently when their value is not needed, e.g. |
private void |
compile(Java.TypeDeclaration td) |
private boolean |
compile2(Java.AlternateConstructorInvocation aci) |
private void |
compile2(Java.AnonymousClassDeclaration acd) |
private boolean |
compile2(Java.AssertStatement as) |
private void |
compile2(Java.Assignment a) |
private boolean |
compile2(Java.Block b) |
private boolean |
compile2(Java.BreakStatement bs) |
private void |
compile2(Java.ClassDeclaration cd) |
private boolean |
compile2(Java.ContinueStatement cs) |
private void |
compile2(Java.Crement c) |
private boolean |
compile2(Java.DoStatement ds) |
private boolean |
compile2(Java.EmptyStatement es) |
private boolean |
compile2(Java.ExpressionStatement ee) |
private boolean |
compile2(Java.FieldDeclaration fd) |
private boolean |
compile2(Java.ForEachStatement fes) |
private boolean |
compile2(Java.ForStatement fs) |
private boolean |
compile2(Java.IfStatement is) |
private boolean |
compile2(Java.Initializer i) |
private void |
compile2(Java.InnerClassDeclaration icd) |
private void |
compile2(Java.InterfaceDeclaration id) |
private boolean |
compile2(Java.LabeledStatement ls) |
private void |
compile2(Java.LocalClassDeclaration lcd) |
private boolean |
compile2(Java.LocalClassDeclarationStatement lcds) |
private boolean |
compile2(Java.LocalVariableDeclarationStatement lvds) |
private void |
compile2(Java.MemberClassDeclaration mcd) |
private void |
compile2(Java.PackageMemberTypeDeclaration pmtd) |
private void |
compile2(Java.ParenthesizedExpression pe) |
private boolean |
compile2(Java.ReturnStatement rs) |
private void |
compile2(Java.Rvalue rv) |
private boolean |
compile2(Java.SuperConstructorInvocation sci) |
private boolean |
compile2(Java.SwitchStatement ss) |
private boolean |
compile2(Java.SynchronizedStatement ss) |
private boolean |
compile2(Java.ThrowStatement ts) |
private boolean |
compile2(Java.TryStatement ts) |
private boolean |
compile2(Java.WhileStatement ws) |
private IClass |
compileArithmeticBinaryOperation(Java.Locatable locatable,
IClass lhsType,
java.lang.String operator,
Java.Rvalue rhs)
The LHS operand of type
lhsType is expected on the stack. |
private IClass |
compileArithmeticOperation(Java.Locatable locatable,
IClass type,
java.util.Iterator<Java.Rvalue> operands,
java.lang.String operator)
Execute an arithmetic operation on a sequence of
operands. |
private void |
compileBoolean(Java.Rvalue rv,
CodeContext.Offset dst,
boolean orientation)
Some
Java.Rvalues compile more efficiently when their value is the condition for a branch. |
private void |
compileBoolean2(Java.BinaryOperation bo,
CodeContext.Offset dst,
boolean orientation) |
private void |
compileBoolean2(Java.ParenthesizedExpression pe,
CodeContext.Offset dst,
boolean orientation) |
private void |
compileBoolean2(Java.Rvalue rv,
CodeContext.Offset dst,
boolean orientation) |
private void |
compileBoolean2(Java.UnaryOperation ue,
CodeContext.Offset dst,
boolean orientation) |
private void |
compileBridgeMethod(ClassFile cf,
IClass.IMethod base,
IClass.IMethod override)
Compiles a bridge method which will add a method of the signature of base that delegates to override.
|
private int |
compileContext(Java.Rvalue rv)
Generates code that determines the context of the
Java.Rvalue and puts it on the operand stack. |
private int |
compileContext2(Java.AmbiguousName an) |
private int |
compileContext2(Java.ArrayAccessExpression aae) |
private int |
compileContext2(Java.ArrayLength al) |
private int |
compileContext2(Java.FieldAccess fa) |
private int |
compileContext2(Java.FieldAccessExpression fae) |
private int |
compileContext2(Java.ParenthesizedExpression pe) |
private int |
compileContext2(Java.Rvalue rv) |
private int |
compileContext2(Java.SuperclassFieldAccessExpression scfae) |
private void |
compileDeclaredMemberTypes(Java.TypeDeclaration decl,
ClassFile cf)
Compile all of the types for this declaration
|
private void |
compileDeclaredMethods(Java.AbstractTypeDeclaration typeDeclaration,
ClassFile cf)
Compile all of the methods for this declaration
|
private void |
compileDeclaredMethods(Java.TypeDeclaration typeDeclaration,
ClassFile cf,
int startPos)
Compile methods for this declaration starting at
startPos. |
private void |
compileError(java.lang.String message)
Equivalent with
compileError(String, Location) with a null location argument. |
private void |
compileError(java.lang.String message,
Location optionalLocation)
Issue a compile error with the given message.
|
private static CompileException |
compileException(Java.Locatable locatable,
java.lang.String message) |
private IClass |
compileGet(Java.Rvalue rv)
Generates code that determines the value of the
Java.Rvalue and puts it on the operand stack. |
private IClass |
compileGet2(Java.AmbiguousName an) |
private IClass |
compileGet2(Java.ArrayAccessExpression aae) |
private IClass |
compileGet2(Java.ArrayLength al) |
private IClass |
compileGet2(Java.Assignment a) |
private IClass |
compileGet2(Java.BinaryOperation bo) |
private IClass |
compileGet2(Java.BooleanRvalue brv) |
private IClass |
compileGet2(Java.Cast c) |
private IClass |
compileGet2(Java.ClassLiteral cl) |
private IClass |
compileGet2(Java.ConditionalExpression ce) |
private IClass |
compileGet2(Java.Crement c) |
private IClass |
compileGet2(Java.FieldAccess fa) |
private IClass |
compileGet2(Java.FieldAccessExpression fae) |
private IClass |
compileGet2(Java.Instanceof io) |
private IClass |
compileGet2(Java.Literal l) |
private IClass |
compileGet2(Java.LocalVariableAccess lva) |
private IClass |
compileGet2(Java.MethodInvocation mi) |
private IClass |
compileGet2(Java.NewAnonymousClassInstance naci) |
private IClass |
compileGet2(Java.NewArray na) |
private IClass |
compileGet2(Java.NewClassInstance nci) |
private IClass |
compileGet2(Java.NewInitializedArray nia) |
private IClass |
compileGet2(Java.ParameterAccess pa) |
private IClass |
compileGet2(Java.ParenthesizedExpression pe) |
private IClass |
compileGet2(Java.QualifiedThisReference qtr) |
private IClass |
compileGet2(Java.SimpleConstant sl) |
private IClass |
compileGet2(Java.SuperclassFieldAccessExpression scfae) |
private IClass |
compileGet2(Java.SuperclassMethodInvocation scmi) |
private IClass |
compileGet2(Java.ThisReference tr) |
private IClass |
compileGet2(Java.UnaryOperation uo) |
private void |
compileGetValue(Java.ArrayInitializer ai,
IClass arrayType) |
private IClass |
compileGetValue(Java.Rvalue rv)
Convenience function that calls
#compileContext(Rvalue) and #compileGet(Rvalue). |
private void |
compileLocalVariableCrement(Java.Crement c,
Java.LocalVariable lv) |
private void |
compileSet(Java.Lvalue lv)
Generates code that stores a value in the
Java.Lvalue. |
private void |
compileSet2(Java.AmbiguousName an) |
private void |
compileSet2(Java.ArrayAccessExpression aae) |
private void |
compileSet2(Java.FieldAccess fa) |
private void |
compileSet2(Java.FieldAccessExpression fae) |
private void |
compileSet2(Java.LocalVariableAccess lva) |
private void |
compileSet2(Java.ParenthesizedExpression pe) |
private void |
compileSet2(Java.SuperclassFieldAccessExpression scfae) |
private boolean |
compileStatements(java.util.List<? extends Java.BlockStatement> statements) |
private IClass |
compileStringConcatenation(Java.Locatable locatable,
IClass type,
Java.Rvalue operand,
java.util.Iterator<Java.Rvalue> operands) |
private boolean |
compileUnconditionalLoop(Java.ContinuableStatement cs,
Java.BlockStatement body,
Java.Rvalue[] optionalUpdate) |
private boolean |
compileUnconditionalLoopWithUpdate(Java.ContinuableStatement cs,
Java.BlockStatement body,
Java.Rvalue[] update) |
ClassFile[] |
compileUnit(boolean debugSource,
boolean debugLines,
boolean debugVars)
Generates an array of
ClassFile objects which represent the classes and interfaces declared in the
compilation unit. |
private static java.lang.String[] |
concat(java.lang.String[] sa,
java.lang.String s) |
private IClass |
convertToPrimitiveNumericType(Java.Locatable locatable,
IClass type)
If the given type is a primitive type, return that type.
|
private void |
crement(Java.Locatable locatable,
Java.LocalVariable lv,
java.lang.String operator) |
private void |
declareClassDollarMethod(Java.ClassLiteral cl) |
private void |
determineValue(Java.FieldAccessExpression fae) |
private void |
determineValue(Java.SuperclassFieldAccessExpression scfae)
"super.fld", "Type.super.fld"
|
private void |
dup(Java.Locatable locatable,
int n) |
private void |
dupx(Java.Locatable locatable,
IClass type,
int x) |
private boolean |
fakeCompile(Java.BlockStatement bs)
Called to check whether the given
Java.Rvalue compiles or not. |
private void |
fakeCompile(Java.Rvalue rv)
Called to check whether the given
Java.Rvalue compiles or not. |
private IClass.IMethod |
fakeIMethod(IClass targetType,
java.lang.String name,
Java.Rvalue[] arguments) |
private static void |
fillConversionMap(java.lang.Object[] array,
java.util.Map<java.lang.String,byte[]> map) |
IClass |
findClass(java.lang.String className)
Find one class or interface declared in this compilation unit by name.
|
private IClass.IField |
findIField(IClass iClass,
java.lang.String name,
Location location)
Finds a named field in the given
IClass. |
private IClass.IMethod |
findIMethod(IClass targetType,
Java.Invocation invocation)
Find a
IClass.IMethod in the given targetType, its superclasses or superinterfaces with the
given name and for the given arguments. |
IClass.IMethod |
findIMethod(Java.MethodInvocation mi)
Find named methods of "targetType", examine the argument types and choose the most specific method.
|
IClass.IMethod |
findIMethod(Java.SuperclassMethodInvocation superclassMethodInvocation) |
private static Java.LocalClassDeclaration |
findLocalClassDeclaration(Java.Scope s,
java.lang.String name)
Finds a local class declared in any block enclosing the given block statement.
|
private IClass |
findMemberType(IClass iClass,
java.lang.String name,
Location location)
Finds a named type in the given
IClass. |
IClass.IInvocable |
findMostSpecificIInvocable(Java.Locatable locatable,
IClass.IInvocable[] iInvocables,
IClass[] argumentTypes,
boolean boxingPermitted,
Java.Scope contextScope)
Determine the applicable invocables and choose the most specific invocable.
|
private IClass.IInvocable |
findMostSpecificIInvocable(Java.Locatable locatable,
IClass.IInvocable[] iInvocables,
Java.Rvalue[] arguments,
Java.Scope contextScope)
Determine the arguments' types, determine the applicable invocables and choose the most specific invocable
and adjust arguments as needed (for varargs case).
|
private IClass |
findTypeByFullyQualifiedName(Location location,
java.lang.String[] identifiers)
Attempts to load an
IClass by fully-qualified name through iClassLoader. |
private IClass |
findTypeByName(Location location,
java.lang.String className)
Find the named
IClass in this compilation unit, or through the iClassLoader. |
private boolean |
generatesCode(Java.BlockStatement bs)
Checks whether invocation of
#compile(BlockStatement) would generate more than zero code bytes. |
private boolean |
generatesCode2(Java.AssertStatement as) |
private boolean |
generatesCode2(Java.Block b) |
private boolean |
generatesCode2(Java.BlockStatement bs) |
private boolean |
generatesCode2(Java.EmptyStatement es) |
private boolean |
generatesCode2(Java.FieldDeclaration fd) |
private boolean |
generatesCode2(Java.Initializer i) |
private boolean |
generatesCode2(Java.LocalClassDeclarationStatement lcds) |
private boolean |
generatesCode2(java.util.List<Java.BlockStatement> l) |
Java.CompilationUnit |
getCompilationUnit() |
java.lang.Object |
getConstantValue(Java.Rvalue rv)
Attempts to evaluate as a constant expression.
|
private java.lang.Object |
getConstantValue2(Java.AmbiguousName an) |
private java.lang.Object |
getConstantValue2(Java.BinaryOperation bo) |
private java.lang.Object |
getConstantValue2(Java.BooleanLiteral bl) |
private java.lang.Object |
getConstantValue2(Java.Cast c) |
private java.lang.Object |
getConstantValue2(Java.CharacterLiteral cl) |
private java.lang.Object |
getConstantValue2(Java.ConditionalExpression ce) |
private java.lang.Object |
getConstantValue2(Java.FieldAccess fa) |
private java.lang.Object |
getConstantValue2(Java.FloatingPointLiteral fpl) |
private java.lang.Object |
getConstantValue2(Java.IntegerLiteral il) |
private java.lang.Object |
getConstantValue2(Java.NullLiteral nl) |
private java.lang.Object |
getConstantValue2(Java.ParenthesizedExpression pe) |
private java.lang.Object |
getConstantValue2(Java.Rvalue rv) |
private java.lang.Object |
getConstantValue2(Java.SimpleConstant sl) |
private java.lang.Object |
getConstantValue2(Java.StringLiteral sl) |
private java.lang.Object |
getConstantValue2(Java.UnaryOperation uo) |
private Java.ClassDeclaration |
getDeclaringClass(Java.QualifiedThisReference qtr) |
private Java.TypeBodyDeclaration |
getDeclaringTypeBodyDeclaration(Java.QualifiedThisReference qtr) |
private void |
getfield(Java.Locatable locatable,
IClass.IField iField) |
private IClass |
getIClass(Java.ThisReference tr) |
private IClass.IField[] |
getIFields(Java.FieldDeclaration fieldDeclaration) |
void |
getIMethods(IClass type,
java.lang.String methodName,
java.util.List<IClass.IMethod> v)
Add all methods with the given
methodName that are declared by the type, its superclasses and
all their superinterfaces to the result list v. |
Java.LocalVariable |
getLocalVariable(Java.FunctionDeclarator.FormalParameter parameter) |
Java.LocalVariable |
getLocalVariable(Java.FunctionDeclarator.FormalParameter parameter,
boolean isVariableArityParameter) |
Java.LocalVariable |
getLocalVariable(Java.LocalVariableDeclarationStatement lvds,
Java.VariableDeclarator vd) |
private java.lang.Object |
getNegatedConstantValue(Java.Rvalue rv)
Attempts to evaluate the negated value of a constant
Java.Rvalue. |
private java.lang.Object |
getNegatedConstantValue2(Java.IntegerLiteral il) |
private java.lang.Object |
getNegatedConstantValue2(Java.ParenthesizedExpression pe) |
private java.lang.Object |
getNegatedConstantValue2(Java.Rvalue rv) |
private java.lang.Object |
getNegatedConstantValue2(Java.UnaryOperation uo) |
(package private) Java.ArrayInitializerOrRvalue |
getNonConstantFinalInitializer(Java.FieldDeclaration fd,
Java.VariableDeclarator vd)
Determine the non-constant-final initializer of the given
Java.VariableDeclarator. |
(package private) static Java.TypeDeclaration |
getOuterClass(Java.TypeDeclaration typeDeclaration) |
private static java.util.List<Java.TypeDeclaration> |
getOuterClasses(Java.TypeDeclaration inner)
Return a list consisting of the given
inner class and all its outer classes. |
private IClass |
getReferenceType(Location location,
Java.Scope scope,
java.lang.String[] identifiers,
int n) |
private IClass |
getReferenceType(Location location,
java.lang.String simpleTypeName,
Java.Scope scope)
JLS7 6.5.5.1 Simple type name (single identifier)
|
private IClass |
getReturnType(Java.FunctionDeclarator fd) |
java.lang.String[] |
getSingleTypeImport(java.lang.String name,
Location location)
Check if the given simple name was imported through a single type import.
|
private IClass |
getTargetIClass(Java.QualifiedThisReference qtr) |
private IClass |
getType(Java.Atom a) |
private IClass |
getType2(Java.AmbiguousName an) |
private IClass |
getType2(Java.ArrayAccessExpression aae) |
private IClass |
getType2(Java.ArrayLength al) |
private IClass |
getType2(Java.ArrayType at) |
private IClass |
getType2(Java.Assignment a) |
private IClass |
getType2(Java.BasicType bt) |
private IClass |
getType2(Java.BinaryOperation bo) |
private IClass |
getType2(Java.BooleanLiteral bl) |
private IClass |
getType2(Java.Cast c) |
private IClass |
getType2(Java.CharacterLiteral cl) |
private IClass |
getType2(Java.ClassLiteral cl) |
private IClass |
getType2(Java.ConditionalExpression ce) |
private IClass |
getType2(Java.Crement c) |
private IClass |
getType2(Java.FieldAccess fa) |
private IClass |
getType2(Java.FieldAccessExpression fae) |
private IClass |
getType2(Java.FloatingPointLiteral fpl) |
private IClass |
getType2(Java.Instanceof io) |
private IClass |
getType2(Java.IntegerLiteral il) |
private IClass |
getType2(Java.LocalVariableAccess lva) |
private IClass |
getType2(Java.MethodInvocation mi) |
private IClass |
getType2(Java.NewAnonymousClassInstance naci) |
private IClass |
getType2(Java.NewArray na) |
private IClass |
getType2(Java.NewClassInstance nci) |
private IClass |
getType2(Java.NewInitializedArray nia) |
private IClass |
getType2(Java.NullLiteral nl) |
private IClass |
getType2(Java.Package p) |
private IClass |
getType2(Java.ParameterAccess pa) |
private IClass |
getType2(Java.ParenthesizedExpression pe) |
private IClass |
getType2(Java.QualifiedThisReference qtr) |
private IClass |
getType2(Java.ReferenceType rt) |
private IClass |
getType2(Java.RvalueMemberType rvmt) |
private IClass |
getType2(Java.SimpleConstant sl) |
private IClass |
getType2(Java.SimpleType st) |
private IClass |
getType2(Java.StringLiteral sl) |
private IClass |
getType2(Java.SuperclassFieldAccessExpression scfae) |
private IClass |
getType2(Java.SuperclassMethodInvocation scmi) |
private IClass |
getType2(Java.ThisReference tr) |
private IClass |
getType2(Java.UnaryOperation uo) |
private IClass |
getUnboxedType(IClass type) |
private CodeContext.Offset |
getWhereToBreak(Java.BreakableStatement bs) |
private boolean |
hasAnnotation(Java.FunctionDeclarator fd,
IClass methodAnnotation) |
private static int |
hex2Int(Java.Locatable locatable,
java.lang.String value) |
private static long |
hex2Long(Java.Locatable locatable,
java.lang.String value) |
private static int |
ilfd(IClass t) |
private static int |
ilfd(IClass t,
int opcodeInt,
int opcodeLong,
int opcodeFloat,
int opcodeDouble) |
private static int |
ilfda(IClass t) |
private static int |
ilfdabcs(IClass t) |
private void |
import2(Java.CompilationUnit.SingleStaticImportDeclaration ssid) |
private void |
import2(Java.CompilationUnit.StaticImportOnDemandDeclaration siodd) |
private IClass |
importSingleType(java.lang.String simpleTypeName,
Location location)
If the given name was declared in a simple type import, load that class.
|
IClass |
importTypeOnDemand(java.lang.String simpleTypeName,
Location location)
6.5.2.BL1.B1.B5, 6.5.2.BL1.B1.B6 Type-import-on-demand.
6.5.5.1.6 Type-import-on-demand declaration. |
(package private) void |
initializeInstanceVariablesAndInvokeInstanceInitializers(Java.ConstructorDeclarator cd)
Compiles the instance variable initializers and the instance initializers in their lexical order.
|
private java.lang.String |
internalCheckAccessible(IClass iClassDeclaringMember,
Access memberAccess,
Java.Scope contextScope) |
private java.lang.String |
internalCheckAccessible(IClass type,
Java.Scope contextScope) |
private void |
invoke(Java.Locatable locatable,
IClass.IConstructor iConstructor) |
private void |
invoke(Java.Locatable locatable,
IClass.IMethod iMethod) |
private void |
invokeConstructor(Java.Locatable locatable,
Java.Scope scope,
Java.Rvalue optionalEnclosingInstance,
IClass targetClass,
Java.Rvalue[] arguments)
Expects the object to initialize on the stack.
|
private boolean |
isAccessible(IClass.IMember member,
Java.Scope contextScope)
Determines whether the given
IClass.IMember is accessible in the given context, according to
JLS7 6.6.1.BL1.B4. |
private boolean |
isAccessible(IClass iClassDeclaringMember,
Access memberAccess,
Java.Scope contextScope)
Determines whether a member (class, interface, field or method) declared in a given class is accessible from a
given block statement context, according to JLS7 6.6.1.4.
|
private boolean |
isAccessible(IClass type,
Java.Scope contextScope)
Determines whether the given
IClass is accessible in the given context, according to JLS7 6.6.1.2 and
6.6.1.4. |
private IClass |
isBoxingConvertible(IClass sourceType) |
private boolean |
isCastReferenceConvertible(IClass sourceType,
IClass targetType)
JLS7 5.5
|
private boolean |
isConvertibleToPrimitiveNumeric(IClass sourceType) |
private boolean |
isIdentityConvertible(IClass sourceType,
IClass targetType)
Checks whether "identity conversion" (5.1.1) is possible.
|
(package private) Java.LocalVariable |
isIntLv(Java.Crement c)
Checks whether the operand is an integer-like local variable.
|
private boolean |
isMethodInvocationConvertible(IClass sourceType,
IClass targetType,
boolean boxingPermitted)
Checks if "method invocation conversion" (5.3) is possible.
|
private boolean |
isNarrowingPrimitiveConvertible(IClass sourceType,
IClass targetType)
Checks whether "narrowing primitive conversion" (JLS7 5.1.3) is possible.
|
private boolean |
isNarrowingReferenceConvertible(IClass sourceType,
IClass targetType)
Check whether "narrowing reference conversion" (JLS7 5.1.5) is possible.
|
private boolean |
isType(Java.Atom a) |
private boolean |
isType2(Java.AmbiguousName an) |
private boolean |
isType2(Java.Atom a) |
private IClass |
isUnboxingConvertible(IClass sourceType) |
private boolean |
isWideningPrimitiveConvertible(IClass sourceType,
IClass targetType) |
private boolean |
isWideningReferenceConvertible(IClass sourceType,
IClass targetType)
Checks if "widening reference conversion" (5.1.4) is possible.
|
private static java.lang.String |
last(java.lang.String[] sa) |
private void |
leave(Java.BlockStatement bs,
IClass optionalStackValueType)
Clean up the statement context.
|
private void |
leave2(Java.BlockStatement bs,
IClass optionalStackValueType) |
private void |
leave2(Java.SynchronizedStatement ss,
IClass optionalStackValueType) |
private void |
leave2(Java.TryStatement ts,
IClass optionalStackValueType) |
private void |
leaveStatements(Java.Scope from,
Java.Scope to,
IClass optionalStackValueType)
Statements that jump out of blocks ("return", "break", "continue") must call this method to make sure that the
"finally" clauses of all "try...catch" statements are executed.
|
private void |
load(Java.Locatable locatable,
IClass type,
int index) |
private IClass |
load(Java.Locatable locatable,
Java.LocalVariable localVariable) |
private static void |
makeLocalVariableNames(CodeContext cc,
ClassFile.MethodInfo mi)
Makes the variable name and class name Constant Pool names used by local variables.
|
private static java.lang.String[] |
makeUtf8Able(java.lang.String s)
Only strings that can be UTF8-encoded into 65535 bytes can be stored as a constant string info.
|
private void |
maybeCreateInitMethod(Java.AbstractTypeDeclaration decl,
ClassFile cf,
java.util.List<Java.BlockStatement> statements)
Create class initialization method iff there is any initialization code.
|
private static Access |
modifiers2Access(short modifiers) |
private IClass |
newArray(Java.Locatable locatable,
int dimExprCount,
int dims,
IClass componentType)
Expects
dimExprCount values of type int on the operand stack. |
private void |
numericPromotion(Java.Locatable locatable,
IClass sourceType,
IClass targetType) |
private static int |
oct2Int(Java.Locatable locatable,
java.lang.String value) |
private static long |
oct2Long(Java.Locatable locatable,
java.lang.String value) |
private boolean |
overridesMethod(IClass.IMethod method,
IClass type) |
private boolean |
overridesMethodFromSupertype(IClass.IMethod m,
IClass type) |
private void |
pop(Java.Locatable locatable,
IClass type) |
private IClass |
pushConstant(Java.Locatable locatable,
java.lang.Object value) |
private void |
putfield(Java.Locatable locatable,
IClass.IField iField) |
private Java.Atom |
reclassify(Java.AmbiguousName an) |
private Java.Atom |
reclassifyName(Location location,
Java.Scope scope,
java.lang.String identifier)
JLS7 6.5.2.1
|
private Java.Atom |
reclassifyName(Location location,
Java.Scope scope,
java.lang.String[] identifiers,
int n)
Reclassifies the ambiguous name consisting of the first
n of the identifiers (JLS7 6.5.2.2). |
private void |
referenceThis(Java.Locatable locatable) |
private void |
referenceThis(Java.Locatable locatable,
Java.ClassDeclaration declaringClass,
Java.TypeBodyDeclaration declaringTypeBodyDeclaration,
IClass targetIClass) |
private CodeContext |
replaceCodeContext(CodeContext newCodeContext) |
private IClass |
resolve(Java.TypeDeclaration td) |
private void |
reverseUnaryNumericPromotion(Java.Locatable locatable,
IClass sourceType,
IClass targetType) |
void |
setCompileErrorHandler(ErrorHandler optionalCompileErrorHandler)
By default,
CompileExceptions are thrown on compile errors, but an application my install its own
(thread-local) ErrorHandler. |
void |
setWarningHandler(WarningHandler optionalWarningHandler)
By default, warnings are discarded, but an application my install a custom
WarningHandler. |
private void |
store(Java.Locatable locatable,
IClass lvType,
short lvIndex) |
private void |
store(Java.Locatable locatable,
Java.LocalVariable localVariable)
Assign top stack top value to the given local variable.
|
private void |
stringConversion(Java.Locatable locatable,
IClass sourceType)
Converts object of type "sourceType" to type "String" (JLS7 15.18.1.1).
|
(package private) IClass.IConstructor |
toIConstructor(Java.ConstructorDeclarator constructorDeclarator) |
private IClass.IInvocable |
toIInvocable(Java.FunctionDeclarator fd) |
IClass.IMethod |
toIMethod(Java.MethodDeclarator methodDeclarator) |
private Java.Lvalue |
toLvalueOrCompileException(Java.Atom a) |
private Java.Rvalue |
toRvalueOrCompileException(Java.Atom a) |
private Java.Type |
toTypeOrCompileException(Java.Atom a) |
private boolean |
tryAssignmentConversion(Java.Locatable locatable,
IClass sourceType,
IClass targetType,
java.lang.Object optionalConstantValue) |
private boolean |
tryBoxingConversion(Java.Locatable locatable,
IClass sourceType,
IClass targetType) |
private boolean |
tryConstantAssignmentConversion(Java.Locatable locatable,
java.lang.Object constantValue,
IClass targetType)
Check if "constant assignment conversion" (JLS7 5.2, paragraph 1) is possible.
|
private boolean |
tryIdentityConversion(IClass sourceType,
IClass targetType)
Implements "identity conversion" (5.1.1).
|
private boolean |
tryNarrowingPrimitiveConversion(Java.Locatable locatable,
IClass sourceType,
IClass targetType)
Implements "narrowing primitive conversion" (JLS7 5.1.3).
|
private boolean |
tryNarrowingReferenceConversion(Java.Locatable locatable,
IClass sourceType,
IClass targetType)
Implements "narrowing reference conversion" (5.1.5).
|
private boolean |
tryUnboxingConversion(Java.Locatable locatable,
IClass sourceType,
IClass targetType,
CodeContext.Inserter optionalInserter) |
private boolean |
tryWideningPrimitiveConversion(Java.Locatable locatable,
IClass sourceType,
IClass targetType)
Implements "widening primitive conversion" (5.1.2).
|
private boolean |
tryWideningReferenceConversion(IClass sourceType,
IClass targetType)
Performs "widening reference conversion" (5.1.4) if possible.
|
private IClass |
unaryNumericPromotion(Java.Locatable locatable,
IClass type)
Implements "unary numeric promotion" (JLS7 5.6.1).
|
private IClass |
unaryNumericPromotionType(Java.Locatable locatable,
IClass type) |
private void |
unboxingConversion(Java.Locatable locatable,
IClass sourceType,
IClass targetType) |
private void |
unboxingConversion(Java.Locatable locatable,
IClass sourceType,
IClass targetType,
CodeContext.Inserter optionalInserter) |
private static java.lang.String |
unescape(java.lang.String s) |
private void |
warning(java.lang.String handle,
java.lang.String message,
Location optionalLocation)
Issues a warning with the given message an location an returns.
|
private void |
writeBranch(Java.Locatable locatable,
int opcode,
CodeContext.Offset dst) |
private void |
writeByte(int v) |
private void |
writeConstantClassInfo(java.lang.String descriptor) |
private void |
writeConstantDoubleInfo(double value) |
private void |
writeConstantFieldrefInfo(java.lang.String classFd,
java.lang.String fieldName,
java.lang.String fieldFd) |
private void |
writeConstantInterfaceMethodrefInfo(java.lang.String classFd,
java.lang.String methodName,
java.lang.String methodMd) |
private void |
writeConstantLongInfo(long value) |
private void |
writeConstantMethodrefInfo(java.lang.String classFd,
java.lang.String methodName,
java.lang.String methodMd) |
private void |
writeInt(int v) |
private void |
writeLdc(Java.Locatable locatable,
short index) |
private void |
writeOffset(CodeContext.Offset src,
CodeContext.Offset dst) |
private void |
writeOpcode(Java.Locatable locatable,
int opcode) |
private void |
writeOpcodes(Java.Locatable locatable,
byte[] opcodes) |
private void |
writeShort(int v) |
private static final boolean DEBUG
private static final int STRING_CONCAT_LIMIT
a.concat(b).concat(c)
strategy is used to implement string concatenation. For more operands, the
new StringBuilder(a).append(b).append(c).append(d).toString()
strategy is chosen.
A very good article from Tom Gibara analyzes the impact of this decision and recommends a value of three.
public static final boolean JUMP_IF_TRUE
orientation parameter of the compileBoolean(Java.Rvalue,
CodeContext.Offset, boolean) methods, indicating that the code should be generated such that execution branches
if the value on top of the operand stack is TRUE.public static final boolean JUMP_IF_FALSE
orientation parameter of the compileBoolean(Java.Rvalue,
CodeContext.Offset, boolean) methods, indicating that the code should be generated such that execution branches
if the value on top of the operand stack is FALSE.public static final java.lang.Object NOT_CONSTANT
getConstantValue(Java.Rvalue) method family indicating that the given
Java.Rvalue does not evaluate to a constant value.private java.util.Map<java.lang.String,java.lang.String[]> singleTypeImports
getSingleTypeImport(String, Location); null means "not yet initialized"private java.util.Collection<java.lang.String[]> typeImportsOnDemand
importTypeOnDemand(String, Location); null means "not yet initialized.private final java.util.Map<java.lang.String,IClass> onDemandImportableTypes
importTypeOnDemand(String, Location); cache for on-demand-imported types.private static final java.util.Map<java.lang.String,byte[]> PRIMITIVE_WIDENING_CONVERSIONS
private static final java.util.Map<java.lang.String,byte[]> PRIMITIVE_NARROWING_CONVERSIONS
private CodeContext codeContext
private ErrorHandler optionalCompileErrorHandler
private int compileErrorCount
private WarningHandler optionalWarningHandler
private final Java.CompilationUnit compilationUnit
private final IClassLoader iClassLoader
private java.util.List<ClassFile> generatedClassFiles
private boolean debugSource
private boolean debugLines
private boolean debugVars
private final java.util.Map<java.lang.String,java.util.List<java.lang.Object>> singleStaticImports
private final java.util.Collection<IClass> staticImportsOnDemand
public UnitCompiler(Java.CompilationUnit compilationUnit, IClassLoader iClassLoader)
public Java.CompilationUnit getCompilationUnit()
Java.CompilationUnit that this UnitCompiler compilesprivate void import2(Java.CompilationUnit.SingleStaticImportDeclaration ssid) throws CompileException
CompileExceptionprivate void import2(Java.CompilationUnit.StaticImportOnDemandDeclaration siodd) throws CompileException
CompileExceptionpublic ClassFile[] compileUnit(boolean debugSource, boolean debugLines, boolean debugVars) throws CompileException
ClassFile objects which represent the classes and interfaces declared in the
compilation unit.CompileExceptionprivate void compile(Java.TypeDeclaration td) throws CompileException
CompileExceptionprivate void compile2(Java.PackageMemberTypeDeclaration pmtd) throws CompileException
CompileExceptionprivate void compile2(Java.ClassDeclaration cd) throws CompileException
CompileExceptionprivate void addFields(Java.FieldDeclaration fd, ClassFile cf) throws CompileException
ClassFile.FieldInfos for all fields declared by the given Java.FieldDeclaration.CompileExceptionprivate void compile2(Java.AnonymousClassDeclaration acd) throws CompileException
CompileExceptionprivate void compile2(Java.LocalClassDeclaration lcd) throws CompileException
CompileExceptionprivate void compile2(Java.InnerClassDeclaration icd) throws CompileException
CompileExceptionprivate void compile2(Java.MemberClassDeclaration mcd) throws CompileException
CompileExceptionprivate void compile2(Java.InterfaceDeclaration id) throws CompileException
CompileExceptionprivate void maybeCreateInitMethod(Java.AbstractTypeDeclaration decl, ClassFile cf, java.util.List<Java.BlockStatement> statements) throws CompileException
decl - The type declarationcf - The class file into which to put the methodb - The block for the method (possibly empty)CompileExceptionprivate void compileDeclaredMemberTypes(Java.TypeDeclaration decl, ClassFile cf) throws CompileException
NB: as a side effect this will fill in the synthetic field map
CompileExceptionprivate void compileDeclaredMethods(Java.AbstractTypeDeclaration typeDeclaration, ClassFile cf) throws CompileException
NB: as a side effect this will fill in the synthetic field map
CompileExceptionprivate void compileDeclaredMethods(Java.TypeDeclaration typeDeclaration, ClassFile cf, int startPos) throws CompileException
startPos.startPos - Starting parameter to fill inCompileExceptionprivate boolean hasAnnotation(Java.FunctionDeclarator fd, IClass methodAnnotation) throws CompileException
CompileExceptionprivate boolean overridesMethodFromSupertype(IClass.IMethod m, IClass type) throws CompileException
CompileExceptionprivate boolean overridesMethod(IClass.IMethod method, IClass type) throws CompileException
method overrides a method of type or any of its supertypesCompileExceptionprivate void compileBridgeMethod(ClassFile cf, IClass.IMethod base, IClass.IMethod override) throws CompileException
CompileExceptionprivate boolean compile(Java.BlockStatement bs) throws CompileException
CompileExceptionprivate boolean fakeCompile(Java.BlockStatement bs) throws CompileException
Java.Rvalue compiles or not.CompileExceptionprivate boolean compile2(Java.Initializer i) throws CompileException
CompileExceptionprivate boolean compile2(Java.Block b) throws CompileException
CompileExceptionprivate boolean compileStatements(java.util.List<? extends Java.BlockStatement> statements) throws CompileException
CompileExceptionprivate boolean compile2(Java.DoStatement ds) throws CompileException
CompileExceptionprivate boolean compile2(Java.ForStatement fs) throws CompileException
CompileExceptionprivate boolean compile2(Java.ForEachStatement fes) throws CompileException
CompileExceptionprivate boolean compile2(Java.WhileStatement ws) throws CompileException
CompileExceptionprivate boolean compileUnconditionalLoop(Java.ContinuableStatement cs, Java.BlockStatement body, Java.Rvalue[] optionalUpdate) throws CompileException
CompileExceptionprivate boolean compileUnconditionalLoopWithUpdate(Java.ContinuableStatement cs, Java.BlockStatement body, Java.Rvalue[] update) throws CompileException
CompileExceptionprivate boolean compile2(Java.LabeledStatement ls) throws CompileException
CompileExceptionprivate boolean compile2(Java.SwitchStatement ss) throws CompileException
CompileExceptionprivate boolean compile2(Java.BreakStatement bs) throws CompileException
CompileExceptionprivate boolean compile2(Java.ContinueStatement cs) throws CompileException
CompileExceptionprivate boolean compile2(Java.AssertStatement as) throws CompileException
CompileExceptionprivate boolean compile2(Java.EmptyStatement es)
private boolean compile2(Java.ExpressionStatement ee) throws CompileException
CompileExceptionprivate boolean compile2(Java.FieldDeclaration fd) throws CompileException
CompileExceptionprivate boolean compile2(Java.IfStatement is) throws CompileException
CompileExceptionprivate boolean compile2(Java.LocalClassDeclarationStatement lcds) throws CompileException
CompileExceptionprivate static Java.LocalClassDeclaration findLocalClassDeclaration(Java.Scope s, java.lang.String name)
private boolean compile2(Java.LocalVariableDeclarationStatement lvds) throws CompileException
CompileExceptionpublic Java.LocalVariable getLocalVariable(Java.LocalVariableDeclarationStatement lvds, Java.VariableDeclarator vd) throws CompileException
Java.LocalVariable corresponding with the local variable declaration/declaratorCompileExceptionprivate boolean compile2(Java.ReturnStatement rs) throws CompileException
CompileExceptionprivate boolean compile2(Java.SynchronizedStatement ss) throws CompileException
CompileExceptionprivate boolean compile2(Java.ThrowStatement ts) throws CompileException
CompileExceptionprivate boolean compile2(Java.TryStatement ts) throws CompileException
CompileExceptionprivate void compile(Java.FunctionDeclarator fd, ClassFile classFile) throws CompileException
CompileExceptionprivate static void makeLocalVariableNames(CodeContext cc, ClassFile.MethodInfo mi)
private void buildLocalVariableMap(Java.FunctionDeclarator fd) throws CompileException
CompileExceptionprivate java.util.Map<java.lang.String,Java.LocalVariable> buildLocalVariableMap(Java.BlockStatement blockStatement, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
blockStatement.CompileExceptionprivate static java.util.Map<java.lang.String,Java.LocalVariable> buildLocalVariableMap(Java.Statement s, java.util.Map<java.lang.String,Java.LocalVariable> localVars)
private static java.util.Map<java.lang.String,Java.LocalVariable> buildLocalVariableMap(Java.ConstructorInvocation ci, java.util.Map<java.lang.String,Java.LocalVariable> localVars)
private void buildLocalVariableMap(Java.Block block, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
CompileExceptionprivate void buildLocalVariableMap(Java.DoStatement ds, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
CompileExceptionprivate void buildLocalVariableMap(Java.ForStatement fs, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
CompileExceptionprivate void buildLocalVariableMap(Java.ForEachStatement fes, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
CompileExceptionprivate void buildLocalVariableMap(Java.IfStatement is, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
CompileExceptionprivate void buildLocalVariableMap(Java.Initializer i, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
CompileExceptionprivate void buildLocalVariableMap(Java.SwitchStatement ss, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
CompileExceptionprivate void buildLocalVariableMap(Java.SynchronizedStatement ss, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
CompileExceptionprivate void buildLocalVariableMap(Java.TryStatement ts, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
CompileExceptionprivate void buildLocalVariableMap(Java.WhileStatement ws, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
CompileExceptionprivate java.util.Map<java.lang.String,Java.LocalVariable> buildLocalVariableMap(Java.LabeledStatement ls, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
CompileExceptionprivate java.util.Map<java.lang.String,Java.LocalVariable> buildLocalVariableMap(Java.LocalVariableDeclarationStatement lvds, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
CompileExceptionprotected void buildLocalVariableMap(Java.CatchClause catchClause, java.util.Map<java.lang.String,Java.LocalVariable> localVars) throws CompileException
localVars to the 'local variable map' of the given catchClause.CompileExceptionpublic Java.LocalVariable getLocalVariable(Java.FunctionDeclarator.FormalParameter parameter) throws CompileException
Java.LocalVariable corresponding with the parameterCompileExceptionpublic Java.LocalVariable getLocalVariable(Java.FunctionDeclarator.FormalParameter parameter, boolean isVariableArityParameter) throws CompileException
isVariableArityParameter - Whether the parameter is the last parameter of a 'variable arity'
(a.k.a. 'varargs') method declarationJava.LocalVariable corresponding with the parameterCompileExceptionprivate void fakeCompile(Java.Rvalue rv) throws CompileException
Java.Rvalue compiles or not.CompileExceptionprivate void compile(Java.Rvalue rv) throws CompileException
Java.Rvalues compile more efficiently when their value is not needed, e.g. "i++".CompileExceptionprivate void compile2(Java.Rvalue rv) throws CompileException
CompileExceptionprivate void compile2(Java.Assignment a) throws CompileException
CompileExceptionprivate void compile2(Java.Crement c) throws CompileException
CompileExceptionprivate void compile2(Java.ParenthesizedExpression pe) throws CompileException
CompileExceptionprivate boolean compile2(Java.AlternateConstructorInvocation aci) throws CompileException
CompileExceptionprivate boolean compile2(Java.SuperConstructorInvocation sci) throws CompileException
CompileExceptionprivate void compileBoolean(Java.Rvalue rv, CodeContext.Offset dst, boolean orientation) throws CompileException
Java.Rvalues compile more efficiently when their value is the condition for a branch.
Notice that if "this" is a constant, then either dst is never branched to, or it is unconditionally
branched to. "Unexamined code" errors may result during bytecode validation.
dst - Where to jumporientation - JUMP_IF_TRUE or JUMP_IF_FALSECompileExceptionprivate void compileBoolean2(Java.Rvalue rv, CodeContext.Offset dst, boolean orientation) throws CompileException
dst - Where to jumporientation - JUMP_IF_TRUE or JUMP_IF_FALSECompileExceptionprivate void compileBoolean2(Java.UnaryOperation ue, CodeContext.Offset dst, boolean orientation) throws CompileException
dst - Where to jumporientation - JUMP_IF_TRUE or JUMP_IF_FALSECompileExceptionprivate void compileBoolean2(Java.BinaryOperation bo, CodeContext.Offset dst, boolean orientation) throws CompileException
dst - Where to jumporientation - JUMP_IF_TRUE or JUMP_IF_FALSECompileExceptionprivate void compileBoolean2(Java.ParenthesizedExpression pe, CodeContext.Offset dst, boolean orientation) throws CompileException
dst - Where to jumporientation - JUMP_IF_TRUE or JUMP_IF_FALSECompileExceptionprivate int compileContext(Java.Rvalue rv) throws CompileException
Java.Rvalue and puts it on the operand stack. Most
expressions do not have a "context", but some do. E.g. for "x[y]", the context is "x, y". The bottom line is
that for statements like "x[y] += 3" the context is only evaluated once.CompileExceptionprivate int compileContext2(Java.Rvalue rv)
private int compileContext2(Java.AmbiguousName an) throws CompileException
CompileExceptionprivate int compileContext2(Java.FieldAccess fa) throws CompileException
CompileExceptionprivate int compileContext2(Java.ArrayLength al) throws CompileException
CompileExceptionprivate int compileContext2(Java.ArrayAccessExpression aae) throws CompileException
CompileExceptionprivate int compileContext2(Java.FieldAccessExpression fae) throws CompileException
CompileExceptionprivate int compileContext2(Java.SuperclassFieldAccessExpression scfae) throws CompileException
CompileExceptionprivate int compileContext2(Java.ParenthesizedExpression pe) throws CompileException
CompileExceptionprivate IClass compileGet(Java.Rvalue rv) throws CompileException
Java.Rvalue and puts it on the operand stack. This method
relies on that the "context" of the Java.Rvalue is on top of the operand stack (see #compileContext(Rvalue)).Java.RvalueCompileExceptionprivate IClass compileGet2(Java.BooleanRvalue brv) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.AmbiguousName an) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.LocalVariableAccess lva)
private IClass compileGet2(Java.FieldAccess fa) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.ArrayLength al)
private IClass compileGet2(Java.ThisReference tr) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.QualifiedThisReference qtr) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.ClassLiteral cl) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.Assignment a) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.ConditionalExpression ce) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.Crement c) throws CompileException
CompileExceptionprivate void compileLocalVariableCrement(Java.Crement c, Java.LocalVariable lv)
private void crement(Java.Locatable locatable, Java.LocalVariable lv, java.lang.String operator)
private IClass compileGet2(Java.ArrayAccessExpression aae) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.FieldAccessExpression fae) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.SuperclassFieldAccessExpression scfae) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.UnaryOperation uo) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.Instanceof io) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.BinaryOperation bo) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.Cast c) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.ParenthesizedExpression pe) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.MethodInvocation mi) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.SuperclassMethodInvocation scmi) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.NewClassInstance nci) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.NewAnonymousClassInstance naci) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.ParameterAccess pa) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.NewArray na) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.NewInitializedArray nia) throws CompileException
CompileExceptionprivate void compileGetValue(Java.ArrayInitializer ai, IClass arrayType) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.Literal l) throws CompileException
CompileExceptionprivate IClass compileGet2(Java.SimpleConstant sl) throws CompileException
CompileExceptionprivate IClass compileGetValue(Java.Rvalue rv) throws CompileException
#compileContext(Rvalue) and #compileGet(Rvalue).CompileExceptionpublic final java.lang.Object getConstantValue(Java.Rvalue rv) throws CompileException
NOT_CONSTANT iff the rvalue is not a constant valueCompileExceptionprivate java.lang.Object getConstantValue2(Java.Rvalue rv)
private java.lang.Object getConstantValue2(Java.AmbiguousName an) throws CompileException
CompileExceptionprivate java.lang.Object getConstantValue2(Java.FieldAccess fa) throws CompileException
CompileExceptionprivate java.lang.Object getConstantValue2(Java.UnaryOperation uo) throws CompileException
CompileExceptionprivate java.lang.Object getConstantValue2(Java.ConditionalExpression ce) throws CompileException
CompileExceptionprivate java.lang.Object getConstantValue2(Java.BinaryOperation bo) throws CompileException
CompileExceptionprivate java.lang.Object getConstantValue2(Java.Cast c) throws CompileException
CompileExceptionprivate java.lang.Object getConstantValue2(Java.ParenthesizedExpression pe) throws CompileException
CompileExceptionprivate java.lang.Object getConstantValue2(Java.IntegerLiteral il) throws CompileException
CompileExceptionprivate java.lang.Object getConstantValue2(Java.FloatingPointLiteral fpl) throws CompileException
CompileExceptionprivate java.lang.Object getConstantValue2(Java.BooleanLiteral bl)
private java.lang.Object getConstantValue2(Java.CharacterLiteral cl)
private java.lang.Object getConstantValue2(Java.StringLiteral sl)
private java.lang.Object getConstantValue2(Java.NullLiteral nl)
private java.lang.Object getConstantValue2(Java.SimpleConstant sl)
private java.lang.Object getNegatedConstantValue(Java.Rvalue rv) throws CompileException
Java.Rvalue. This is particularly relevant for the
smallest value of an integer or long literal.NOT_CONSTANT iff value is not constant; otherwise a String, Byte, Short, Integer, Boolean, Character, Float, Long, Double
or nullCompileExceptionprivate java.lang.Object getNegatedConstantValue2(Java.Rvalue rv) throws CompileException
CompileExceptionprivate java.lang.Object getNegatedConstantValue2(Java.UnaryOperation uo) throws CompileException
CompileExceptionprivate java.lang.Object getNegatedConstantValue2(Java.ParenthesizedExpression pe) throws CompileException
CompileExceptionprivate java.lang.Object getNegatedConstantValue2(Java.IntegerLiteral il) throws CompileException
CompileExceptionprivate boolean generatesCode(Java.BlockStatement bs) throws CompileException
#compile(BlockStatement) would generate more than zero code bytes.CompileExceptionprivate boolean generatesCode2(Java.BlockStatement bs)
private boolean generatesCode2(Java.AssertStatement as)
private boolean generatesCode2(Java.EmptyStatement es)
private boolean generatesCode2(Java.LocalClassDeclarationStatement lcds)
private boolean generatesCode2(Java.Initializer i) throws CompileException
CompileExceptionprivate boolean generatesCode2(java.util.List<Java.BlockStatement> l) throws CompileException
CompileExceptionprivate boolean generatesCode2(Java.Block b) throws CompileException
CompileExceptionprivate boolean generatesCode2(Java.FieldDeclaration fd) throws CompileException
CompileExceptionprivate void leave(Java.BlockStatement bs, IClass optionalStackValueType)
Statements like "return", "break", "continue" must call this method for all the statements they terminate.
Notice: If optionalStackValueType is null, then the operand stack is empty; otherwise
exactly one operand with that type is on the stack. This information is vital to implementations of #leave(BlockStatement, IClass) that require a specific operand stack state (e.g. an empty operand stack for
JSR).
private void leave2(Java.BlockStatement bs, IClass optionalStackValueType)
private void leave2(Java.SynchronizedStatement ss, IClass optionalStackValueType)
private void leave2(Java.TryStatement ts, IClass optionalStackValueType)
private void compileSet(Java.Lvalue lv) throws CompileException
Java.Lvalue. Expects the Java.Lvalue's context (see compileContext(org.codehaus.janino.Java.Rvalue)) and a value of the Java.Lvalue's type on the operand stack.CompileExceptionprivate void compileSet2(Java.AmbiguousName an) throws CompileException
CompileExceptionprivate void compileSet2(Java.LocalVariableAccess lva)
private void compileSet2(Java.FieldAccess fa) throws CompileException
CompileExceptionprivate void compileSet2(Java.ArrayAccessExpression aae) throws CompileException
CompileExceptionprivate void compileSet2(Java.FieldAccessExpression fae) throws CompileException
CompileExceptionprivate void compileSet2(Java.SuperclassFieldAccessExpression scfae) throws CompileException
CompileExceptionprivate void compileSet2(Java.ParenthesizedExpression pe) throws CompileException
CompileExceptionprivate IClass getType(Java.Atom a) throws CompileException
CompileExceptionprivate IClass getType2(Java.SimpleType st)
private IClass getType2(Java.BasicType bt)
private IClass getType2(Java.ReferenceType rt) throws CompileException
CompileExceptionprivate IClass getReferenceType(Location location, Java.Scope scope, java.lang.String[] identifiers, int n) throws CompileException
IClass, or nullCompileExceptionprivate IClass getReferenceType(Location location, java.lang.String simpleTypeName, Java.Scope scope) throws CompileException
IClass, or nullCompileExceptionprivate IClass getType2(Java.RvalueMemberType rvmt) throws CompileException
CompileExceptionprivate IClass getType2(Java.ArrayType at) throws CompileException
CompileExceptionprivate IClass getType2(Java.AmbiguousName an) throws CompileException
CompileExceptionprivate IClass getType2(Java.Package p) throws CompileException
CompileExceptionprivate IClass getType2(Java.LocalVariableAccess lva)
private IClass getType2(Java.FieldAccess fa) throws CompileException
CompileExceptionprivate IClass getType2(Java.ArrayLength al)
private IClass getType2(Java.ThisReference tr) throws CompileException
CompileExceptionprivate IClass getType2(Java.QualifiedThisReference qtr) throws CompileException
CompileExceptionprivate IClass getType2(Java.ClassLiteral cl)
private IClass getType2(Java.Assignment a) throws CompileException
CompileExceptionprivate IClass getType2(Java.ConditionalExpression ce) throws CompileException
CompileExceptionprivate IClass getType2(Java.Crement c) throws CompileException
CompileExceptionprivate IClass getType2(Java.ArrayAccessExpression aae) throws CompileException
CompileExceptionprivate IClass getType2(Java.FieldAccessExpression fae) throws CompileException
CompileExceptionprivate IClass getType2(Java.SuperclassFieldAccessExpression scfae) throws CompileException
CompileExceptionprivate IClass getType2(Java.UnaryOperation uo) throws CompileException
CompileExceptionprivate IClass getType2(Java.Instanceof io)
private IClass getType2(Java.BinaryOperation bo) throws CompileException
CompileExceptionprivate IClass getUnboxedType(IClass type)
type is a primitive wrapper type, the unwrapped type, otherwise typeprivate IClass getType2(Java.Cast c) throws CompileException
CompileExceptionprivate IClass getType2(Java.ParenthesizedExpression pe) throws CompileException
CompileExceptionprivate IClass getType2(Java.MethodInvocation mi) throws CompileException
CompileExceptionprivate IClass getType2(Java.SuperclassMethodInvocation scmi) throws CompileException
CompileExceptionprivate IClass getType2(Java.NewClassInstance nci) throws CompileException
CompileExceptionprivate IClass getType2(Java.NewAnonymousClassInstance naci)
private IClass getType2(Java.ParameterAccess pa) throws CompileException
CompileExceptionprivate IClass getType2(Java.NewArray na) throws CompileException
CompileExceptionprivate IClass getType2(Java.NewInitializedArray nia) throws CompileException
CompileExceptionprivate IClass getType2(Java.IntegerLiteral il)
private IClass getType2(Java.FloatingPointLiteral fpl)
private IClass getType2(Java.BooleanLiteral bl)
private IClass getType2(Java.CharacterLiteral cl)
private IClass getType2(Java.StringLiteral sl)
private IClass getType2(Java.NullLiteral nl)
private IClass getType2(Java.SimpleConstant sl)
private boolean isType(Java.Atom a) throws CompileException
CompileExceptionprivate boolean isType2(Java.Atom a)
private boolean isType2(Java.AmbiguousName an) throws CompileException
CompileExceptionprivate boolean isAccessible(IClass.IMember member, Java.Scope contextScope) throws CompileException
IClass.IMember is accessible in the given context, according to
JLS7 6.6.1.BL1.B4. Issues a compileError(String) if not.CompileExceptionprivate void checkAccessible(IClass.IMember member, Java.BlockStatement contextBlockStatement) throws CompileException
IClass.IMember is accessible in the given context, according to JLS7
6.6.1.BL1.B4. Issues a compileError(String) if not.CompileExceptionprivate boolean isAccessible(IClass iClassDeclaringMember, Access memberAccess, Java.Scope contextScope) throws CompileException
CompileExceptionprivate void checkAccessible(IClass iClassDeclaringMember, Access memberAccess, Java.BlockStatement contextBlockStatement) throws CompileException
compileError(String) if not.CompileExceptionprivate java.lang.String internalCheckAccessible(IClass iClassDeclaringMember, Access memberAccess, Java.Scope contextScope) throws CompileException
IClass with that Access is inaccessibleCompileExceptionprivate boolean isAccessible(IClass type, Java.Scope contextScope) throws CompileException
IClass is accessible in the given context, according to JLS7 6.6.1.2 and
6.6.1.4.CompileExceptionprivate void checkAccessible(IClass type, Java.BlockStatement contextBlockStatement) throws CompileException
IClass is accessible in the given context, according to JLS7 6.6.1.2 and
6.6.1.4. Issues a compileError(String) if not.CompileExceptionprivate java.lang.String internalCheckAccessible(IClass type, Java.Scope contextScope) throws CompileException
CompileExceptionprivate Java.Type toTypeOrCompileException(Java.Atom a) throws CompileException
CompileExceptionprivate Java.Rvalue toRvalueOrCompileException(Java.Atom a) throws CompileException
CompileExceptionprivate Java.Lvalue toLvalueOrCompileException(Java.Atom a) throws CompileException
CompileExceptionvoid assignSyntheticParametersToSyntheticFields(Java.ConstructorDeclarator cd) throws CompileException
CompileExceptionvoid initializeInstanceVariablesAndInvokeInstanceInitializers(Java.ConstructorDeclarator cd) throws CompileException
CompileExceptionprivate void leaveStatements(Java.Scope from, Java.Scope to, IClass optionalStackValueType)
private IClass compileArithmeticBinaryOperation(Java.Locatable locatable, IClass lhsType, java.lang.String operator, Java.Rvalue rhs) throws CompileException
lhsType is expected on the stack.
The following operators are supported: | ^ & * / % + - << >> >>>
CompileExceptionprivate IClass compileArithmeticOperation(Java.Locatable locatable, IClass type, java.util.Iterator<Java.Rvalue> operands, java.lang.String operator) throws CompileException
operands. If type is non-null, the first
operand with that type is already on the stack.
The following operators are supported: | ^ & * / % + - << >> >>>
CompileExceptionprivate IClass compileStringConcatenation(Java.Locatable locatable, IClass type, Java.Rvalue operand, java.util.Iterator<Java.Rvalue> operands) throws CompileException
type - If non-null, the first operand with that type is already on the stackoperand - The next operandoperands - All following operands (Iterator over Java.Rvalues)CompileExceptionprivate void stringConversion(Java.Locatable locatable, IClass sourceType) throws CompileException
CompileExceptionprivate void invokeConstructor(Java.Locatable locatable, Java.Scope scope, Java.Rvalue optionalEnclosingInstance, IClass targetClass, Java.Rvalue[] arguments) throws CompileException
Notice: This method is used both for explicit constructor invocation (first statement of a constructor body) and implicit constructor invocation (right after NEW).
optionalEnclosingInstance - Used if the target class is an inner classCompileExceptionprivate IClass.IField[] getIFields(Java.FieldDeclaration fieldDeclaration)
IClass.IFields that are declared by the fieldDeclarationJava.ArrayInitializerOrRvalue getNonConstantFinalInitializer(Java.FieldDeclaration fd, Java.VariableDeclarator vd) throws CompileException
Java.VariableDeclarator.null if the variable is declared without an initializer or if the initializer is
constant-finalCompileExceptionprivate Java.Atom reclassify(Java.AmbiguousName an) throws CompileException
CompileExceptionprivate Java.Atom reclassifyName(Location location, Java.Scope scope, java.lang.String[] identifiers, int n) throws CompileException
n of the identifiers (JLS7 6.5.2.2).CompileExceptionprivate IClass findTypeByName(Location location, java.lang.String className) throws CompileException
IClass in this compilation unit, or through the iClassLoader.className - Fully qualified class name, e.g. "pkg1.pkg2.Outer$Inner".null iff an IClass with that name could not be loadedCompileException - An exception was raised while loading the IClassprivate Java.Atom reclassifyName(Location location, Java.Scope scope, java.lang.String identifier) throws CompileException
CompileExceptionprivate void determineValue(Java.FieldAccessExpression fae) throws CompileException
CompileExceptionprivate void determineValue(Java.SuperclassFieldAccessExpression scfae) throws CompileException
CompileExceptionpublic IClass.IMethod findIMethod(Java.MethodInvocation mi) throws CompileException
Notice that the returned IClass.IMethod may be declared in an enclosing type.
IClass.IMethod or nullCompileExceptionprivate IClass.IMethod findIMethod(IClass targetType, Java.Invocation invocation) throws CompileException
IClass.IMethod in the given targetType, its superclasses or superinterfaces with the
given name and for the given arguments. If more than one such method exists, choose the most
specific one (JLS7 15.11.2).null if no appropriate method could be foundCompileExceptionprivate IClass.IMethod fakeIMethod(IClass targetType, java.lang.String name, Java.Rvalue[] arguments) throws CompileException
CompileExceptionpublic void getIMethods(IClass type, java.lang.String methodName, java.util.List<IClass.IMethod> v) throws CompileException
methodName that are declared by the type, its superclasses and
all their superinterfaces to the result list v.CompileExceptionpublic IClass.IMethod findIMethod(Java.SuperclassMethodInvocation superclassMethodInvocation) throws CompileException
IClass.IMethod that implements the superclassMethodInvocationCompileExceptionprivate IClass.IInvocable findMostSpecificIInvocable(Java.Locatable locatable, IClass.IInvocable[] iInvocables, Java.Rvalue[] arguments, Java.Scope contextScope) throws CompileException
iInvocables - Length must be greater than zeroIClass.IInvocableCompileExceptionpublic IClass.IInvocable findMostSpecificIInvocable(Java.Locatable locatable, IClass.IInvocable[] iInvocables, IClass[] argumentTypes, boolean boxingPermitted, Java.Scope contextScope) throws CompileException
IClass.IInvocable or null if no IClass.IInvocable is
applicableCompileExceptionprivate boolean isMethodInvocationConvertible(IClass sourceType, IClass targetType, boolean boxingPermitted) throws CompileException
CompileExceptionprivate void checkThrownExceptions(Java.Invocation in, IClass.IMethod iMethod) throws CompileException
CompileException - if the Java.Invocation throws exceptions that are disallowed in the given scopeprivate void checkThrownException(Java.Locatable locatable, IClass type, Java.Scope scope) throws CompileException
CompileException - The exception with the given type must not be thrown in the given scopeprivate IClass getTargetIClass(Java.QualifiedThisReference qtr) throws CompileException
CompileExceptionJava.LocalVariable isIntLv(Java.Crement c) throws CompileException
CompileExceptionprivate IClass resolve(Java.TypeDeclaration td)
private void referenceThis(Java.Locatable locatable, Java.ClassDeclaration declaringClass, Java.TypeBodyDeclaration declaringTypeBodyDeclaration, IClass targetIClass) throws CompileException
CompileExceptionprivate static java.util.List<Java.TypeDeclaration> getOuterClasses(Java.TypeDeclaration inner)
inner class and all its outer classes.List of Java.TypeDeclarationstatic Java.TypeDeclaration getOuterClass(Java.TypeDeclaration typeDeclaration)
Java.TypeDeclaration that immediately encloses the typeDeclaration, or nullprivate IClass getIClass(Java.ThisReference tr) throws CompileException
CompileExceptionprivate IClass getReturnType(Java.FunctionDeclarator fd) throws CompileException
CompileExceptionIClass.IConstructor toIConstructor(Java.ConstructorDeclarator constructorDeclarator)
IClass.IConstructor that implements the constructorDeclaratorpublic IClass.IMethod toIMethod(Java.MethodDeclarator methodDeclarator)
IClass.IMethod that implements the methodDeclaratorprivate IClass.IInvocable toIInvocable(Java.FunctionDeclarator fd)
private IClass importSingleType(java.lang.String simpleTypeName, Location location) throws CompileException
CompileExceptionpublic java.lang.String[] getSingleTypeImport(java.lang.String name,
Location location)
throws CompileException
name - The simple type name, e.g. Inner{ "pkg", "Outer", "Inner" }, or nullCompileExceptionpublic IClass importTypeOnDemand(java.lang.String simpleTypeName, Location location) throws CompileException
null if the given simpleTypeName cannot be resolved through any of the
import-on-demand directivesCompileExceptionprivate void declareClassDollarMethod(Java.ClassLiteral cl)
private IClass pushConstant(Java.Locatable locatable, java.lang.Object value) throws CompileException
value - A Character, Byte, Short, Integer, Long, Float,
Double, String, Boolean or nullCompileExceptionprivate static int hex2Int(Java.Locatable locatable, java.lang.String value) throws CompileException
CompileExceptionprivate static int oct2Int(Java.Locatable locatable, java.lang.String value) throws CompileException
CompileExceptionprivate static long hex2Long(Java.Locatable locatable, java.lang.String value) throws CompileException
CompileExceptionprivate static long oct2Long(Java.Locatable locatable, java.lang.String value) throws CompileException
CompileExceptionprivate static java.lang.String[] makeUtf8Able(java.lang.String s)
s - The string to split into suitable chunksprivate void writeLdc(Java.Locatable locatable, short index)
private void assignmentConversion(Java.Locatable locatable, IClass sourceType, IClass targetType, java.lang.Object optionalConstantValue) throws CompileException
CompileExceptionprivate boolean tryAssignmentConversion(Java.Locatable locatable, IClass sourceType, IClass targetType, java.lang.Object optionalConstantValue) throws CompileException
CompileExceptionprivate java.lang.Object assignmentConversion(Java.Locatable locatable, java.lang.Object value, IClass targetType) throws CompileException
CompileExceptionprivate IClass unaryNumericPromotion(Java.Locatable locatable, IClass type) throws CompileException
CompileExceptionprivate void reverseUnaryNumericPromotion(Java.Locatable locatable, IClass sourceType, IClass targetType) throws CompileException
CompileExceptionprivate IClass convertToPrimitiveNumericType(Java.Locatable locatable, IClass type) throws CompileException
CompileExceptionprivate void numericPromotion(Java.Locatable locatable, IClass sourceType, IClass targetType)
private IClass unaryNumericPromotionType(Java.Locatable locatable, IClass type) throws CompileException
CompileExceptionprivate IClass binaryNumericPromotion(Java.Locatable locatable, IClass type1, CodeContext.Inserter convertInserter1, IClass type2) throws CompileException
CompileExceptionprivate IClass binaryNumericPromotion(Java.Locatable locatable, IClass type1, CodeContext.Inserter convertInserter1, IClass type2, CodeContext.Inserter convertInserter2) throws CompileException
CompileExceptionprivate IClass binaryNumericPromotionType(Java.Locatable locatable, IClass type1, IClass type2) throws CompileException
CompileExceptionprivate boolean isIdentityConvertible(IClass sourceType, IClass targetType)
private boolean tryIdentityConversion(IClass sourceType, IClass targetType)
private boolean isWideningPrimitiveConvertible(IClass sourceType, IClass targetType)
private boolean tryWideningPrimitiveConversion(Java.Locatable locatable, IClass sourceType, IClass targetType)
private static void fillConversionMap(java.lang.Object[] array,
java.util.Map<java.lang.String,byte[]> map)
private boolean isWideningReferenceConvertible(IClass sourceType, IClass targetType) throws CompileException
CompileExceptionprivate boolean tryWideningReferenceConversion(IClass sourceType, IClass targetType) throws CompileException
CompileExceptionprivate boolean isNarrowingPrimitiveConvertible(IClass sourceType, IClass targetType)
private boolean tryNarrowingPrimitiveConversion(Java.Locatable locatable, IClass sourceType, IClass targetType)
private boolean tryConstantAssignmentConversion(Java.Locatable locatable, java.lang.Object constantValue, IClass targetType) throws CompileException
constantValue - The constant value that is to be convertedtargetType - The type to convert toCompileExceptionprivate boolean isNarrowingReferenceConvertible(IClass sourceType, IClass targetType) throws CompileException
CompileExceptionprivate boolean tryNarrowingReferenceConversion(Java.Locatable locatable, IClass sourceType, IClass targetType) throws CompileException
CompileExceptionprivate boolean isCastReferenceConvertible(IClass sourceType, IClass targetType) throws CompileException
CompileExceptionprivate IClass isBoxingConvertible(IClass sourceType)
nullprivate boolean tryBoxingConversion(Java.Locatable locatable, IClass sourceType, IClass targetType) throws CompileException
CompileExceptionprivate void boxingConversion(Java.Locatable locatable, IClass sourceType, IClass targetType) throws CompileException
sourceType - a primitive type (except VOID)targetType - the corresponding wrapper typeCompileExceptionprivate IClass isUnboxingConvertible(IClass sourceType)
sourceType is a primitive wrapper type, the unboxed type, otherwise nullprivate boolean isConvertibleToPrimitiveNumeric(IClass sourceType)
sourceType is a primitive numeric type, or a wrapper type of a primitive numeric
typeprivate boolean tryUnboxingConversion(Java.Locatable locatable, IClass sourceType, IClass targetType, CodeContext.Inserter optionalInserter)
private void unboxingConversion(Java.Locatable locatable, IClass sourceType, IClass targetType, CodeContext.Inserter optionalInserter)
targetType - a primitive type (except VOID)sourceType - the corresponding wrapper typeprivate void unboxingConversion(Java.Locatable locatable, IClass sourceType, IClass targetType)
targetType - a primitive type (except VOID)sourceType - the corresponding wrapper typeprivate IClass findTypeByFullyQualifiedName(Location location, java.lang.String[] identifiers) throws CompileException
IClass by fully-qualified name through iClassLoader.location - TODOidentifiers - The fully qualified type name, e.g. '{ "pkg", "Outer", "Inner" }'null if a class with the given name could not be loadedCompileException - The type exists, but a problem occurred when it was loadedprivate IClass load(Java.Locatable locatable, Java.LocalVariable localVariable)
private void load(Java.Locatable locatable, IClass type, int index)
private void store(Java.Locatable locatable, Java.LocalVariable localVariable)
private void store(Java.Locatable locatable, IClass lvType, short lvIndex)
private void getfield(Java.Locatable locatable, IClass.IField iField) throws CompileException
CompileExceptionprivate void putfield(Java.Locatable locatable, IClass.IField iField) throws CompileException
CompileExceptionprivate void dup(Java.Locatable locatable, int n)
private void dupx(Java.Locatable locatable, IClass type, int x)
private void pop(Java.Locatable locatable, IClass type)
private static int ilfd(IClass t)
private static int ilfd(IClass t, int opcodeInt, int opcodeLong, int opcodeFloat, int opcodeDouble)
private static int ilfda(IClass t)
private static int ilfdabcs(IClass t)
private void invoke(Java.Locatable locatable, IClass.IMethod iMethod) throws CompileException
CompileExceptionprivate void invoke(Java.Locatable locatable, IClass.IConstructor iConstructor) throws CompileException
CompileExceptionprivate IClass.IField findIField(IClass iClass, java.lang.String name, Location location) throws CompileException
IClass. Honors superclasses and interfaces. See JLS7 8.3.null if no field is foundCompileExceptionprivate IClass findMemberType(IClass iClass, java.lang.String name, Location location) throws CompileException
IClass. Honors superclasses, interfaces and enclosing type declarations.null if no type with the given name is foundCompileExceptionpublic IClass findClass(java.lang.String className)
className - Fully qualified class name, e.g. "pkg1.pkg2.Outer$Inner".null if a class or an interface with that name is not declared in this compilation unitprivate void compileError(java.lang.String message)
throws CompileException
compileError(String, Location) with a null location argument.CompileExceptionprivate void compileError(java.lang.String message,
Location optionalLocation)
throws CompileException
ErrorHandler that was installed
through setCompileErrorHandler(ErrorHandler). Such a handler typically throws a CompileException, but it may as well decide to return normally. Consequently, the calling code must be prepared
that compileError(String, Location) returns normally, and must attempt to continue compiling.message - The message to reportoptionalLocation - The location to reportCompileExceptionprivate void warning(java.lang.String handle,
java.lang.String message,
Location optionalLocation)
throws CompileException
WarningHandler
that was installed through setWarningHandler(WarningHandler).
The handle argument qualifies the warning and is typically used by the WarningHandler to
suppress individual warnings.
CompileExceptionpublic void setCompileErrorHandler(ErrorHandler optionalCompileErrorHandler)
CompileExceptions are thrown on compile errors, but an application my install its own
(thread-local) ErrorHandler.
Be aware that a single problem during compilation often causes a bunch of compile errors, so a good ErrorHandler counts errors and throws a CompileException when a limit is reached.
If the given ErrorHandler does not throw CompileExceptions, then compileUnit(boolean, boolean, boolean) will throw one when the compilation of the unit is finished, and errors
had occurred. In other words: The ErrorHandler may throw a CompileException or not, but compileUnit(boolean, boolean, boolean) will definitely throw a CompileException if one or more compile
errors have occurred.
optionalCompileErrorHandler - null to restore the default behavior (throwing a CompileExceptionpublic void setWarningHandler(WarningHandler optionalWarningHandler)
WarningHandler.optionalWarningHandler - null to indicate that no warnings be issuedprivate CodeContext replaceCodeContext(CodeContext newCodeContext)
private void writeByte(int v)
private void writeShort(int v)
private void writeInt(int v)
private void writeOpcode(Java.Locatable locatable, int opcode)
private void writeOpcodes(Java.Locatable locatable, byte[] opcodes)
private void writeBranch(Java.Locatable locatable, int opcode, CodeContext.Offset dst)
private void writeOffset(CodeContext.Offset src, CodeContext.Offset dst)
private void writeConstantClassInfo(java.lang.String descriptor)
private void writeConstantFieldrefInfo(java.lang.String classFd,
java.lang.String fieldName,
java.lang.String fieldFd)
private void writeConstantMethodrefInfo(java.lang.String classFd,
java.lang.String methodName,
java.lang.String methodMd)
private void writeConstantInterfaceMethodrefInfo(java.lang.String classFd,
java.lang.String methodName,
java.lang.String methodMd)
private short addConstantStringInfo(java.lang.String value)
private short addConstantIntegerInfo(int value)
private short addConstantFloatInfo(float value)
private void writeConstantLongInfo(long value)
private void writeConstantDoubleInfo(double value)
private CodeContext.Offset getWhereToBreak(Java.BreakableStatement bs)
private Java.TypeBodyDeclaration getDeclaringTypeBodyDeclaration(Java.QualifiedThisReference qtr) throws CompileException
CompileExceptionprivate Java.ClassDeclaration getDeclaringClass(Java.QualifiedThisReference qtr) throws CompileException
CompileExceptionprivate void referenceThis(Java.Locatable locatable)
private IClass newArray(Java.Locatable locatable, int dimExprCount, int dims, IClass componentType)
dimExprCount values of type int on the operand stack. Creates an array of dimExprCount + dims dimensions of componentType.private static Access modifiers2Access(short modifiers)
private static java.lang.String last(java.lang.String[] sa)
private static java.lang.String[] allButLast(java.lang.String[] sa)
private static java.lang.String[] concat(java.lang.String[] sa,
java.lang.String s)
private static CompileException compileException(Java.Locatable locatable, java.lang.String message)
private static java.lang.String unescape(java.lang.String s)