Class AbstractMemberExpansionTransformer<T extends IMemberAccessExpression>
- java.lang.Object
-
- gw.internal.gosu.ir.transform.AbstractElementTransformer<T>
-
- gw.internal.gosu.ir.transform.expression.AbstractExpressionTransformer<T>
-
- gw.internal.gosu.ir.transform.expression.AbstractMemberExpansionTransformer<T>
-
- Direct Known Subclasses:
BeanMethodCallExpansionTransformer,MemberExpansionAccessTransformer
public abstract class AbstractMemberExpansionTransformer<T extends IMemberAccessExpression> extends AbstractExpressionTransformer<T>
-
-
Field Summary
-
Fields inherited from class gw.internal.gosu.ir.transform.AbstractElementTransformer
CAPTURED_VAR_PREFIX, CTX_SYMBOL, CTX_SYMBOL_SUFFIX, CUSTOM_RUNTIMES, EMPTY_CLASS_ARRAY, ENHANCEMENT_THIS_REF, ENHANCEMENT_TYPE_PARAM_PREFIX, ENUM_PARAM_PREFIX, OBJECT_TYPE, OUTER_ACCESS, TYPE_PARAM_PREFIX
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractMemberExpansionTransformer(TopLevelTransformationContext cc, T expr)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static java.util.CollectionarrayToCollection(java.lang.Object value)protected IRExpressioncompile_impl()protected IRExpressioncompileExpansionDirectlyToArray(IType rootType, IType rootComponentType, IType resultType, IType resultCompType)If this method is being called, it means we're expanding a one-dimensional array or collection, with a right hand side that evaluates to a property that's not an array or collection.protected IRExpressioncompileExpansionUsingArrayList(IType rootType, IType rootComponentType, IType resultType, IType resultCompType, IType propertyType)This method will compile the expansion using an ArrayList to collect temporary results.protected IRExpressioncompileExpansionWithNoReturnValue(IType rootType, IType rootComponentType, IType resultType, IType resultCompType)private IRExpressionconvertListToArray(IType resultType, IType resultCompType, IRSymbol resultArrayList)private IRExpressionconvertToPrimitiveArray(IType compType, IRExpression listToConvert)private IRExpressioncreateArrayLengthExpression(IType rootType, IRSymbol tempRoot)private IRForEachStatementcreateArrayListAddLoop(IType rootType, IType rootComponentType, IType resultCompType, IRSymbol tempRoot, IRSymbol resultArrayList, IType propertyType)private IRForEachStatementcreateArrayStoreLoop(IType rootType, IType rootComponentType, IType resultCompType, IRSymbol tempRoot, IRSymbol resultArray)protected abstract IRExpressioncreateIterationExpr(IType rootComponentType, java.lang.String identifierName, IType identifierType, IType compType)Subclassers need only implement this method for the iteration expression i.e., the singular form of the expansion expr.private IRForEachStatementcreateNoValueLoop(IType rootType, IType rootComponentType, IType resultCompType, IRSymbol tempRoot)private ITypegetMoreSpecificType(IType type1, IType type2)protected abstract ITypegetPropertyOrMethodType(IType rootComponentType, IType compType)private static booleanisArrayOrCollection(IType type)static java.lang.ObjectlistToArray(java.util.List l, IType compType)static java.lang.ObjectlistToArray(java.util.List l, java.lang.Class compType)static boolean[]listToPrimitiveArray_boolean(java.util.List l)static byte[]listToPrimitiveArray_byte(java.util.List l)static char[]listToPrimitiveArray_char(java.util.List l)static double[]listToPrimitiveArray_double(java.util.List l)static float[]listToPrimitiveArray_float(java.util.List l)static int[]listToPrimitiveArray_int(java.util.List l)static long[]listToPrimitiveArray_long(java.util.List l)static short[]listToPrimitiveArray_short(java.util.List l)private IRExpressionmakeArray(IType componentType, IRExpression lengthExpression)-
Methods inherited from class gw.internal.gosu.ir.transform.expression.AbstractExpressionTransformer
_expr, compile, getIRParameters, pushArgumentsNoCasting, pushArgumentsWithCasting, shortCircuitValue
-
Methods inherited from class gw.internal.gosu.ir.transform.AbstractElementTransformer
_cc, assignStructuralTypeOwner, avoidVerifyError, booleanLiteral, boxValue, boxValue, boxValueToType, buildAddition, buildArithmetic, buildArrayLength, buildArrayLoad, buildArrayLoad, buildArrayStore, buildAssignment, buildCast, buildComposite, buildComposite, buildEquals, buildFieldGet, buildFieldSet, buildGreaterThan, buildIf, buildIfElse, buildInitializedArray, buildMethodCall, buildMethodCall, buildMethodCall, buildNegation, buildNewExpression, buildNewExpression, buildNewExpression, buildNotEquals, buildNullCheckTernary, buildReturn, buildSubtraction, buildTernary, buildThrow, callMethod, callMethod, callMethod, callMethod, callMethod, callSpecialMethod, callSpecialMethod, callSpecialMethod, callStaticMethod, castResultingTypeIfNecessary, charLiteral, checkCast, checkCast, checkCast, classLiteral, classLiteral, classLiteral, clearCustomRuntimes, collectArgsIntoObjArray, convertBoxedNullToPrimitive, convertNullToPrimitive, convertOperandToBig, convertOperandToPrimitive, convertOperandToRational, exprList, fastStringCoercion, findComparableParamType, findDimensionType, getActualPropertyInfo, getCapturedSymbolParameterName, getClassInfos, getConcreteType, getConstructorParamTypes, getCustomRuntime, getDeclaredField, getDeclaredFieldImpl, getDeclaredMethod, getDeclaredMethod, getDefaultConstIns, getDescriptor, getDescriptor, getDescriptor, getDescriptor, getEnclosingDFS, getField, getField_new, getGosuClass, getInstanceField, getIRTypes, getIRTypes, getModifiers, getParsedElement, getRuntimeEnclosingType, getStaticField, getTypes, getTypeVarParamName, getTypeVarsForDFS, handleCustomExpressionRuntime, handleNamedArgs, identifier, initLocalVar, initLocalVarWithDefault, initMultiArray, inStaticContext, isBigType, isBoxedIntType, isBytecodeType, isBytecodeType, isCheckedArithmeticEnabled, isCompilingEnhancement, isEnhancementType, isEvalProgram, isExecuteMethod, isHandledByCustomCoercion, isIntType, isMemberOnEnclosingType, isMemberOnEnhancementOfEnclosingType, isNonBigBoxedNumberType, isNonStaticInnerClass, isNumberType, isPrimitiveNumberType, isProgram, isProgramOrEnclosedInProgram, makeAnnotationInfos, makeArrayViaTypeInfo, makeEmptyArrayViaTypeInfo, makeIRSymbol, maybeUnwrapMetaType, newArray, nullCheckVar, nullLiteral, numberConvert, numberConvert, numericLiteral, pushArrayOfDefValueExpr, pushArrayOfString, pushArrayOfTypes, pushCapturedSymbols, pushConstant, pushEnumSuperConstructorArguments, pushExternalSymbolsMap, pushLazyType, pushLazyType, pushNull, pushOuter, pushOuter, pushOuter, pushParamTypes, pushRuntimeTypeOfTypeVar, pushString, pushThis, pushThisOrOuter, pushType, pushType, pushTypeParametersForConstructor, requiresExternalSymbolCapture, requiresImplicitEnhancementArg, requiresImplicitEnhancementArg, setCc, setField, setField, setInstanceField, setStaticField, stringLiteral, unboxValueFromType, unboxValueToType, unboxValueToType, valueOf
-
-
-
-
Constructor Detail
-
AbstractMemberExpansionTransformer
protected AbstractMemberExpansionTransformer(TopLevelTransformationContext cc, T expr)
-
-
Method Detail
-
createIterationExpr
protected abstract IRExpression createIterationExpr(IType rootComponentType, java.lang.String identifierName, IType identifierType, IType compType)
Subclassers need only implement this method for the iteration expression i.e., the singular form of the expansion expr.
-
getPropertyOrMethodType
protected abstract IType getPropertyOrMethodType(IType rootComponentType, IType compType)
-
compile_impl
protected IRExpression compile_impl()
- Specified by:
compile_implin classAbstractExpressionTransformer<T extends IMemberAccessExpression>
-
isArrayOrCollection
private static boolean isArrayOrCollection(IType type)
-
compileExpansionWithNoReturnValue
protected IRExpression compileExpansionWithNoReturnValue(IType rootType, IType rootComponentType, IType resultType, IType resultCompType)
-
createNoValueLoop
private IRForEachStatement createNoValueLoop(IType rootType, IType rootComponentType, IType resultCompType, IRSymbol tempRoot)
-
compileExpansionDirectlyToArray
protected IRExpression compileExpansionDirectlyToArray(IType rootType, IType rootComponentType, IType resultType, IType resultCompType)
If this method is being called, it means we're expanding a one-dimensional array or collection, with a right hand side that evaluates to a property that's not an array or collection. In that case, we build up an array and simply store values directly into it. We also null-short-circuit in the event that the root is null. The member expansion portion ends up as a composite that looks like: temp_array = new Foo[temp_root.length] for (a in temp_root index i) { temp_array[i] = a.Bar } temp_array And the overall expression looks like: temp_root = root ( temp_root == null ? (Bar[]) null : (Bar[]) member_expansion )
-
makeArray
private IRExpression makeArray(IType componentType, IRExpression lengthExpression)
-
createArrayLengthExpression
private IRExpression createArrayLengthExpression(IType rootType, IRSymbol tempRoot)
-
createArrayStoreLoop
private IRForEachStatement createArrayStoreLoop(IType rootType, IType rootComponentType, IType resultCompType, IRSymbol tempRoot, IRSymbol resultArray)
-
compileExpansionUsingArrayList
protected IRExpression compileExpansionUsingArrayList(IType rootType, IType rootComponentType, IType resultType, IType resultCompType, IType propertyType)
This method will compile the expansion using an ArrayList to collect temporary results. This is appropriate if the right-hand-side is a Collection or array, if the root is an Iterable or Iterator or other object whose size can't easily be determined up-front, or if the root is a nested Collection or array that will require additional unwrapping. The overall result of the expansion thus looks like the following composite: temp_arraylist = new ArrayList() for (a in temp_root) { temp_arraylist.addAll( AbstractMemberExpansionTransform.arrayToCollection( a.Bars ) ) } AbstractMemberExpansionTransformer.listToArray(temp_array)
-
createArrayListAddLoop
private IRForEachStatement createArrayListAddLoop(IType rootType, IType rootComponentType, IType resultCompType, IRSymbol tempRoot, IRSymbol resultArrayList, IType propertyType)
-
convertListToArray
private IRExpression convertListToArray(IType resultType, IType resultCompType, IRSymbol resultArrayList)
-
convertToPrimitiveArray
private IRExpression convertToPrimitiveArray(IType compType, IRExpression listToConvert)
-
listToPrimitiveArray_boolean
public static boolean[] listToPrimitiveArray_boolean(java.util.List l)
-
listToPrimitiveArray_byte
public static byte[] listToPrimitiveArray_byte(java.util.List l)
-
listToPrimitiveArray_char
public static char[] listToPrimitiveArray_char(java.util.List l)
-
listToPrimitiveArray_int
public static int[] listToPrimitiveArray_int(java.util.List l)
-
listToPrimitiveArray_short
public static short[] listToPrimitiveArray_short(java.util.List l)
-
listToPrimitiveArray_long
public static long[] listToPrimitiveArray_long(java.util.List l)
-
listToPrimitiveArray_float
public static float[] listToPrimitiveArray_float(java.util.List l)
-
listToPrimitiveArray_double
public static double[] listToPrimitiveArray_double(java.util.List l)
-
listToArray
public static java.lang.Object listToArray(java.util.List l, IType compType)
-
listToArray
public static java.lang.Object listToArray(java.util.List l, java.lang.Class compType)
-
arrayToCollection
public static java.util.Collection arrayToCollection(java.lang.Object value)
-
-