Package gw.internal.gosu.ir.transform
Class AbstractElementTransformer<T extends IParsedElement>
- java.lang.Object
-
- gw.internal.gosu.ir.transform.AbstractElementTransformer<T>
-
- Direct Known Subclasses:
AbstractExpressionTransformer
,AbstractStatementTransformer
,CollectionInitializerExpressionTransformer
,FunctionStatementTransformer
,GosuClassTransformer
,GosuFragmentTransformer
,MapInitializerExpressionTransformer
,ObjectInitializerExpressionTransformer
public abstract class AbstractElementTransformer<T extends IParsedElement> extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
CAPTURED_VAR_PREFIX
static String
CTX_SYMBOL
static String
CTX_SYMBOL_SUFFIX
static Map<String,ICustomExpressionRuntime>
CUSTOM_RUNTIMES
static Class[]
EMPTY_CLASS_ARRAY
static String
ENHANCEMENT_THIS_REF
static String
ENHANCEMENT_TYPE_PARAM_PREFIX
static String
ENUM_PARAM_PREFIX
static gw.internal.ext.org.objectweb.asm.Type
OBJECT_TYPE
static String
OUTER_ACCESS
static String
TYPE_PARAM_PREFIX
-
Constructor Summary
Constructors Constructor Description AbstractElementTransformer(TopLevelTransformationContext cc, T parsedElem)
-
Method Summary
-
-
-
Field Detail
-
CTX_SYMBOL_SUFFIX
public static final String CTX_SYMBOL_SUFFIX
- See Also:
- Constant Field Values
-
CTX_SYMBOL
public static final String CTX_SYMBOL
- See Also:
- Constant Field Values
-
CUSTOM_RUNTIMES
public static final Map<String,ICustomExpressionRuntime> CUSTOM_RUNTIMES
-
EMPTY_CLASS_ARRAY
public static final Class[] EMPTY_CLASS_ARRAY
-
OUTER_ACCESS
public static final String OUTER_ACCESS
- See Also:
- Constant Field Values
-
CAPTURED_VAR_PREFIX
public static final String CAPTURED_VAR_PREFIX
- See Also:
- Constant Field Values
-
ENHANCEMENT_TYPE_PARAM_PREFIX
public static final String ENHANCEMENT_TYPE_PARAM_PREFIX
- See Also:
- Constant Field Values
-
TYPE_PARAM_PREFIX
public static final String TYPE_PARAM_PREFIX
- See Also:
- Constant Field Values
-
ENUM_PARAM_PREFIX
public static final String ENUM_PARAM_PREFIX
- See Also:
- Constant Field Values
-
OBJECT_TYPE
public static final gw.internal.ext.org.objectweb.asm.Type OBJECT_TYPE
-
ENHANCEMENT_THIS_REF
public static final String ENHANCEMENT_THIS_REF
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractElementTransformer
public AbstractElementTransformer(TopLevelTransformationContext cc, T parsedElem)
-
-
Method Detail
-
clearCustomRuntimes
public static void clearCustomRuntimes()
-
_cc
public TopLevelTransformationContext _cc()
-
setCc
protected void setCc(TopLevelTransformationContext cc)
-
getParsedElement
protected T getParsedElement()
-
getGosuClass
public ICompilableTypeInternal getGosuClass()
-
callStaticMethod
public IRExpression callStaticMethod(Class cls, String strMethod, Class[] paramTypes, List<IRExpression> args)
-
callMethod
public IRExpression callMethod(Class cls, String strMethod, Class[] paramTypes, IRExpression root, List<IRExpression> args)
-
callMethod
public IRExpression callMethod(IJavaClassInfo cls, String strMethod, Class[] paramTypes, IRExpression root, List<IRExpression> args)
-
callMethod
public IRExpression callMethod(IRMethod method, IRExpression root, List<IRExpression> explicitArgs)
-
callMethod
public IRExpression callMethod(IRMethod method, IRExpression root, List<IRExpression> explicitArgs, int[] namedArgOrder)
-
callMethod
public IRExpression callMethod(IRMethod method, IRExpression root, List<IRExpression> explicitArgs, int[] namedArgOrder, boolean special)
-
callSpecialMethod
public IRExpression callSpecialMethod(IRType rootType, IRMethod method, IRExpression root, List<IRExpression> explicitArgs)
-
callSpecialMethod
public IRExpression callSpecialMethod(IRType rootType, IRMethod method, IRExpression root, List<IRExpression> explicitArgs, int[] namedArgOrder)
-
callSpecialMethod
public IRExpression callSpecialMethod(IRType rootType, IRMethod method, IRExpression root, List<IRExpression> implicitArgs, List<IRExpression> explicitArgs, int[] namedArgOrder)
-
handleNamedArgs
public List<IRElement> handleNamedArgs(List<IRExpression> explicitArgs, int[] namedArgOrder)
Facilitates evaluation of named args in lexical order. E.g.,callMe( :param3 = expr1, :param1 = expr2, :param2 = expr3 )
is parsed as:callMe( expr2, expr3, expr1 )
which is compiled to:temp1 = expr1 temp2 = expr2 temp3 = expr3 callMe( temp2, temp3, temp1 )
- Parameters:
explicitArgs
- The arg expressions in proper order for the target call. The expressions are replaced with the temp vars.namedArgOrder
- The lexical ordering of the args- Returns:
- The temp var assignments in lexical order
-
isExecuteMethod
public static boolean isExecuteMethod(String name)
-
nullCheckVar
public IRStatement nullCheckVar(IRSymbol symbol)
-
pushLazyType
public IRExpression pushLazyType(IType type)
-
pushLazyType
public IRExpression pushLazyType(IType type, IGenericTypeVariable[] tvs)
-
pushType
public IRExpression pushType(IType type)
-
pushType
public IRExpression pushType(IType type, boolean bKeepLiteralType)
-
pushArrayOfString
protected IRExpression pushArrayOfString(String[] array)
-
pushArrayOfDefValueExpr
protected IRExpression pushArrayOfDefValueExpr(IExpression[] array)
-
pushArrayOfTypes
public IRExpression pushArrayOfTypes(IType[] types)
-
requiresImplicitEnhancementArg
public static boolean requiresImplicitEnhancementArg(ReducedDynamicFunctionSymbol dfs)
-
requiresImplicitEnhancementArg
public static boolean requiresImplicitEnhancementArg(IGosuMethodInfo mi)
-
getClassInfos
public IJavaClassInfo[] getClassInfos(IType[] parameters)
-
getDescriptor
public static IRType getDescriptor(IJavaClassInfo cls)
-
getDefaultConstIns
public IRExpression getDefaultConstIns(IType type)
-
getModifiers
public int getModifiers(Symbol symbol)
-
isCompilingEnhancement
public boolean isCompilingEnhancement()
-
isProgramOrEnclosedInProgram
public boolean isProgramOrEnclosedInProgram(IType type)
-
boxValue
public IRExpression boxValue(IType lhsType, IRExpression root)
-
valueOf
public static Character valueOf(char c)
-
boxValue
public IRExpression boxValue(IRType lhsType, IRExpression root)
-
boxValueToType
public IRExpression boxValueToType(IType toType, IRExpression root)
-
unboxValueToType
public IRExpression unboxValueToType(IType lhsType, IRExpression expression)
-
unboxValueToType
public IRExpression unboxValueToType(IRType lhsType, IRExpression expression)
-
unboxValueFromType
public IRExpression unboxValueFromType(IType boxedType, IRExpression root)
-
isProgram
public boolean isProgram(IType type)
-
isEnhancementType
public static boolean isEnhancementType(IType type)
-
isBytecodeType
public static boolean isBytecodeType(IType type)
-
isBytecodeType
public static boolean isBytecodeType(IConstructorInfo ci)
-
getTypes
public static IType[] getTypes(IParameterInfo[] parameters)
-
pushString
protected IRExpression pushString(IExpression expr)
-
pushParamTypes
protected IRExpression pushParamTypes(IParameterInfo[] parameters)
-
pushNull
protected IRExpression pushNull()
-
pushConstant
protected IRExpression pushConstant(Object constant)
-
convertBoxedNullToPrimitive
protected IRExpression convertBoxedNullToPrimitive(IType boxedType)
-
convertNullToPrimitive
protected IRExpression convertNullToPrimitive(IType primitive)
-
checkCast
protected IRExpression checkCast(Class cls, IRExpression expression)
-
checkCast
protected IRExpression checkCast(IType type, IRExpression expression)
-
checkCast
protected IRExpression checkCast(IType type, IRExpression expression, boolean bGetConcreteTypeForMetaType)
-
convertOperandToBig
protected IRAssignmentStatement convertOperandToBig(IType bigType, Class bigClass, IType operandType, IRExpression operand, IRSymbol tempRet)
-
convertOperandToRational
protected IRAssignmentStatement convertOperandToRational(IType operandType, IRExpression operand, IRSymbol tempRet)
-
convertOperandToPrimitive
protected IRAssignmentStatement convertOperandToPrimitive(IType primitiveType, IType operandType, IRExpression operand, IRSymbol tempRet)
-
numberConvert
protected IRExpression numberConvert(IType from, IType to, IRExpression root)
-
numberConvert
protected IRExpression numberConvert(IRType from, IRType to, IRExpression root)
-
isIntType
public static boolean isIntType(IType from)
-
isPrimitiveNumberType
protected boolean isPrimitiveNumberType(IType type)
-
isBigType
public static boolean isBigType(IType type)
-
isNonBigBoxedNumberType
public static boolean isNonBigBoxedNumberType(IType type)
-
isBoxedIntType
public static boolean isBoxedIntType(IType type)
-
isNumberType
public static boolean isNumberType(IType type)
-
isMemberOnEnclosingType
protected ICompilableTypeInternal isMemberOnEnclosingType(IReducedSymbol symbol)
-
isMemberOnEnhancementOfEnclosingType
protected boolean isMemberOnEnhancementOfEnclosingType(AbstractDynamicSymbol symbol)
-
pushThis
protected IRExpression pushThis()
-
pushThisOrOuter
protected IRExpression pushThisOrOuter(IType currentType)
-
pushOuter
protected IRExpression pushOuter()
-
pushOuter
protected IRExpression pushOuter(IType outerTarget)
-
pushOuter
protected IRExpression pushOuter(IType outerTarget, IType currentOuter, IRExpression root)
-
getInstanceField
protected IRExpression getInstanceField(IType owner, String strField, IRType fieldType, IRelativeTypeInfo.Accessibility accessibility, IRExpression root)
-
getStaticField
protected IRExpression getStaticField(IType owner, String strField, IRType fieldType, IRelativeTypeInfo.Accessibility accessibility)
-
getField
protected IRExpression getField(IRProperty field, IRExpression root)
-
setField
protected IRStatement setField(IRProperty field, IRExpression root, IRExpression value)
-
setInstanceField
protected IRStatement setInstanceField(IType owner, String strField, IRType fieldType, IRelativeTypeInfo.Accessibility accessibility, IRExpression root, IRExpression value)
-
setStaticField
protected IRStatement setStaticField(IType owner, String strField, IRType fieldType, IRelativeTypeInfo.Accessibility accessibility, IRExpression value)
-
avoidVerifyError
protected boolean avoidVerifyError(IType owner, IRType rootType, IRelativeTypeInfo.Accessibility accessibility)
-
setField
protected IRStatement setField(IType owner, String strField, IRType fieldType, IRelativeTypeInfo.Accessibility accessibility, IRExpression root, IRExpression value)
-
isEvalProgram
protected static boolean isEvalProgram(IGosuClassInternal gsClass)
-
getDeclaredMethod
public static Method getDeclaredMethod(Class cls, String strName, Class... params)
-
getDeclaredMethod
public static IJavaClassMethod getDeclaredMethod(IJavaClassInfo cls, String strName, Class... params)
-
newArray
protected IRExpression newArray(IRType atomicType, IRExpression sizeExpression)
-
makeArrayViaTypeInfo
protected IRExpression makeArrayViaTypeInfo(IType atomicType, List<Expression> valueExpressions)
-
makeEmptyArrayViaTypeInfo
protected IRExpression makeEmptyArrayViaTypeInfo(IType atomicType, List<Expression> sizeExpressions)
-
initMultiArray
public static Object initMultiArray(IType componentType, Object instance, int iDimension, int[] sizes)
-
pushRuntimeTypeOfTypeVar
public IRExpression pushRuntimeTypeOfTypeVar(IType type)
-
getEnclosingDFS
public static IDynamicFunctionSymbol getEnclosingDFS(ICompilableType gsClass)
-
getTypeVarsForDFS
public static List<IGenericTypeVariable> getTypeVarsForDFS(IDynamicFunctionSymbol dfs)
-
getConstructorParamTypes
protected IRType[] getConstructorParamTypes(IType[] declaredParams, int iTypeParams, IType type)
Parameters are order like so: ctor( [OuterThis,] [This,] [CapturedSymbols,] [TypeParams,] params )
-
pushTypeParametersForConstructor
protected int pushTypeParametersForConstructor(IExpression expr, IType type, List<IRExpression> args, boolean bSuperCall, boolean genericJavaInterop)
-
pushEnumSuperConstructorArguments
protected void pushEnumSuperConstructorArguments(List<IRExpression> args)
-
initLocalVarWithDefault
protected IRAssignmentStatement initLocalVarWithDefault(Symbol varSym)
-
initLocalVar
protected IRAssignmentStatement initLocalVar(Symbol varSym, IRExpression initialValue)
-
pushCapturedSymbols
protected void pushCapturedSymbols(IType type, List<IRExpression> args, boolean ignoreExternalSymbols)
-
collectArgsIntoObjArray
public IRExpression collectArgsIntoObjArray(List<IRExpression> args)
-
getActualPropertyInfo
protected IGosuVarPropertyInfo getActualPropertyInfo(IPropertyInfo pi)
-
castResultingTypeIfNecessary
protected IRExpression castResultingTypeIfNecessary(IRType expectedType, IRType actualReturnType, IRExpression root)
-
getRuntimeEnclosingType
public static IType getRuntimeEnclosingType(IType type)
- Parameters:
type
-- Returns:
- the actual runtime enclosing type of this type (handles the case of enhancements, when the "enclosing type" at runtime will be the enhanced object, rather than the acutal enclosing type)
-
classLiteral
@Deprecated protected IRExpression classLiteral(Class value)
Deprecated.
-
classLiteral
protected IRExpression classLiteral(IJavaClassInfo value)
-
classLiteral
protected IRExpression classLiteral(IRType value)
-
getCustomRuntime
public static ICustomExpressionRuntime getCustomRuntime(String id, IType enclosingClass)
-
handleCustomExpressionRuntime
protected IRExpression handleCustomExpressionRuntime(ICustomExpressionRuntime customRuntime, IType expectedType)
-
pushExternalSymbolsMap
protected IRExpression pushExternalSymbolsMap()
-
requiresExternalSymbolCapture
public static boolean requiresExternalSymbolCapture(IType type)
-
buildMethodCall
protected IRMethodCallExpression buildMethodCall(IRType ownersType, String name, boolean isInterface, IRType returnType, List<IRType> paramTypes, IRExpression root, List<IRExpression> args)
-
buildMethodCall
protected IRMethodCallExpression buildMethodCall(Class ownersType, String name, Class returnType, Class[] paramTypes, IRExpression root, List<IRExpression> args)
-
buildCast
protected IRExpression buildCast(IRType castType, IRExpression expression)
-
numericLiteral
protected IRExpression numericLiteral(Number value)
-
charLiteral
protected IRExpression charLiteral(char c)
-
booleanLiteral
protected IRExpression booleanLiteral(boolean value)
-
nullLiteral
protected IRExpression nullLiteral()
-
stringLiteral
protected IRExpression stringLiteral(String value)
-
buildArrayLoad
protected IRExpression buildArrayLoad(IRExpression root, int index, IRType componentType)
-
buildArrayLoad
protected IRExpression buildArrayLoad(IRExpression root, IRExpression index, IRType componentType)
-
buildFieldGet
protected IRExpression buildFieldGet(IRType owner, String fieldName, IRType fieldType, IRExpression root)
-
buildFieldSet
protected IRStatement buildFieldSet(IRType owner, String fieldName, IRType fieldType, IRExpression root, IRExpression value)
-
buildAssignment
protected IRAssignmentStatement buildAssignment(IRSymbol symbol, IRExpression value)
-
identifier
protected IRIdentifier identifier(IRSymbol symbol)
-
buildArrayStore
protected IRStatement buildArrayStore(IRExpression lhs, IRExpression index, IRExpression value, IRType componentType)
-
buildInitializedArray
protected IRExpression buildInitializedArray(IRType componentType, List<IRExpression> values)
-
buildNewExpression
protected IRExpression buildNewExpression(IRType type, List<IRType> parameterTypes, List<IRExpression> args)
-
buildNewExpression
protected IRExpression buildNewExpression(Class type, Class[] parameterTypes, List<IRExpression> args)
-
getTypeVarParamName
protected final String getTypeVarParamName(IGenericTypeVariable typeVar)
-
getCapturedSymbolParameterName
protected String getCapturedSymbolParameterName(ICapturedSymbol sym)
-
exprList
protected static List<IRExpression> exprList(IRExpression... expressions)
-
getIRTypes
protected static List<IRType> getIRTypes(IJavaClassInfo[] iJavaClassInfos)
-
buildNullCheckTernary
protected IRExpression buildNullCheckTernary(IRExpression root, IRExpression ifNull, IRExpression ifNotNull)
-
buildThrow
protected IRThrowStatement buildThrow(IRExpression exception)
-
buildIf
protected IRIfStatement buildIf(IRExpression test, IRStatement ifStatement)
-
buildIfElse
protected IRIfStatement buildIfElse(IRExpression test, IRStatement ifStatement, IRStatement elseStatement)
-
buildComposite
protected IRCompositeExpression buildComposite(IRElement... elements)
-
buildComposite
protected IRCompositeExpression buildComposite(List<IRElement> elements)
-
buildMethodCall
protected IRMethodCallStatement buildMethodCall(IRExpression methodCall)
-
buildNewExpression
protected IRNewStatement buildNewExpression(IRNewExpression newExpression)
-
buildReturn
protected IRStatement buildReturn()
-
buildEquals
protected IREqualityExpression buildEquals(IRExpression lhs, IRExpression rhs)
-
buildNotEquals
protected IREqualityExpression buildNotEquals(IRExpression lhs, IRExpression rhs)
-
buildGreaterThan
protected IRRelationalExpression buildGreaterThan(IRExpression lhs, IRExpression rhs)
-
buildTernary
protected IRExpression buildTernary(IRExpression test, IRExpression trueValue, IRExpression falseValue, IRType resultType)
-
buildAddition
protected IRExpression buildAddition(IRExpression lhs, IRExpression rhs)
-
buildSubtraction
protected IRExpression buildSubtraction(IRExpression lhs, IRExpression rhs)
-
buildArithmetic
protected IRExpression buildArithmetic(IRExpression lhs, IRExpression rhs, IRArithmeticExpression.Operation operation)
-
buildNegation
protected IRExpression buildNegation(IRExpression root)
-
buildArrayLength
protected IRExpression buildArrayLength(IRExpression root)
-
inStaticContext
protected boolean inStaticContext()
-
makeAnnotationInfos
public static List<GosuAnnotationInfo> makeAnnotationInfos(List<IGosuAnnotation> gosuAnnotations, IFeatureInfo fiAnnotated)
-
isCheckedArithmeticEnabled
protected boolean isCheckedArithmeticEnabled()
-
isNonStaticInnerClass
public static boolean isNonStaticInnerClass(IType type)
-
getField_new
protected IRExpression getField_new(IRProperty irProp, IRExpression root, IRType expectedType)
-
assignStructuralTypeOwner
protected void assignStructuralTypeOwner(IExpression rootExpr, IRExpression irMethodCall)
-
fastStringCoercion
protected IRExpression fastStringCoercion(IRExpression expr, IType operandType)
-
isHandledByCustomCoercion
protected boolean isHandledByCustomCoercion(IType operandType)
-
-