Package gw.internal.gosu.ir.transform
Class GosuClassTransformer
java.lang.Object
gw.internal.gosu.ir.transform.AbstractElementTransformer<ClassStatement>
gw.internal.gosu.ir.transform.GosuClassTransformer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private GosuClassTransformationContext
private IGosuClassInternal
private IRClass
Generates a synthetic method if: - method overrides with covariant return type - for each in ancestry e.g., Square f() -> Rectangle f() -> Shape f().static final String
static final String
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 -
Method Summary
Modifier and TypeMethodDescriptionprivate void
private void
private boolean
Add a bridge method for a Java interface method that is not only implemented by a method in this Gosu class, but is also itself a covariant "override" of its super interface E.g.,private void
addGosuMarker
(List<IRAnnotation> annotations) private void
private void
private void
private void
private void
addTypeParamDescriptor
(List<IRSymbol> parameters, List<IGenericTypeVariable> genTypeVars) private void
private void
appendTypeVarsFromEnclosingFunctions
(List<IRSymbol> parameters, IGosuClassInternal gsClass) private IRClass
compile()
static IRClass
compile
(IGosuClassInternal gsClass) private void
private void
private void
private IRStatement
private void
private void
private void
private void
private void
private void
private void
private void
compileEnumValuesFieldInitializer
(List<IRStatement> statements) private void
private void
private void
private void
private void
Add constructor so Java can use the Gosu generic class without explicitly passing in type arguments.private void
private void
private void
private void
private void
private boolean
genBridgeMethod
(IJavaClassMethod bridge, IJavaClassMethod m) private boolean
genInterfaceProxyBridgeMethod
(IJavaClassMethod m, IJavaClassInfo iJavaClassInfo) private boolean
##hack: Potentially generates a bridge method for an overridden method where the super method is in a proxy and the proxy is for a Java interface having param types that are transformed to non-bytecode types in the type system.private int
private int
getClassModifiers
(IGosuClass gsClass, boolean bForInnerClass) private IRType
private IGosuClassInternal
private IRType[]
private List<IRAnnotation>
getIRAnnotations
(List<? extends IAnnotationInfo> gosuAnnotations) private IJavaClassMethod
getMethodOverridableFromDfs
(DynamicFunctionSymbol dfs, IJavaClassInfo declaringClass) private List<IVarStatement>
private String
getParameterDescriptors
(IType[] types) private String
getParameterDescriptors
(IJavaClassInfo[] iJavaClassInfos) private IType[]
private DynamicFunctionSymbol
getSuperDfs
(DynamicFunctionSymbol dfs, IType gsClass, IType superType) private IRType
private boolean
hasRetentionPolicy
(IAnnotationInfo annotation, RetentionPolicy policy) void
initCapturedSymbolFields
(List<IRStatement> statements) private IRStatement
void
initializeInstanceFields
(List<IRStatement> statements) void
initializeStaticFields
(List<IRStatement> statements) void
initTypeVarFields
(List<IRStatement> statements) boolean
private boolean
boolean
private boolean
private boolean
private IRExpression
private void
makeCovariantParamBridgeMethod
(DynamicFunctionSymbol dfs, DynamicFunctionSymbol superDfs, IJavaClassMethod method) private int
makeModifiersForBridgeMethod
(int modifiers) (package private) IRSymbol
makeParamSymbol
(DynamicFunctionSymbol dfs, ISymbol param) private void
If this is an enhancement, add a (hacky) marker field to indicate the enhanced type for tooling.private void
maybeAddImplicitEnhancementParameters
(DynamicFunctionSymbol dfs, List<IRSymbol> parameters) private void
maybeAddImplicitExternalSymbolsParameter
(DynamicFunctionSymbol dfs, List<IRSymbol> parameters) void
maybeAssignOuterRef
(List<IRStatement> statements) private void
maybeGetCapturedSymbolTypes
(List<IRSymbol> parameters) private void
maybeGetEnumSuperConstructorSymbols
(List<IRSymbol> parameters) private void
maybeGetOuterThisParamType
(List<IRSymbol> parameters) private List<DynamicFunctionSymbol>
private void
maybeGetTypeVarSymbolTypes
(DynamicFunctionSymbol dfs, List<IRSymbol> parameters) private void
maybeGetTypeVarSymbolTypesForConstructor
(List<IRSymbol> parameters) private void
maybePassTypeParams
(DynamicFunctionSymbol dfs, List<IRExpression> args) void
maybePushSupersEnclosingThisRef
(List<IRExpression> arguments) private IRStatement
maybeWrapProgramEvaluateForManangedProgram
(DynamicFunctionSymbol dfs, IRStatement methodBody) If this is: a Gosu program and it has a superclass that implements IManagedProgramInstance and this method isevaluate( IExternalSymbolMap )
Generate the evaluate() method like so:void
pushEnumNameAndOrdinal
(IType type, List<IRExpression> args) void
private void
setUpFunctionContext
(boolean instanceMethod, List<IRSymbol> params) private void
setUpFunctionContext
(DynamicFunctionSymbol dfs, boolean instanceMethod, List<IRSymbol> params) toString()
private void
visitInnerClass
(IGosuClass innerClass) 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
-
Field Details
-
ENUM_VALUES_FIELD
- See Also:
-
ENHANCED_TYPE_FIELD
- See Also:
-
_gsClass
-
_enumCounter
-
_irClass
-
_context
-
_bHasAsserts
private boolean _bHasAsserts -
bridges
Generates a synthetic method if: - method overrides with covariant return type - for each in ancestry e.g., Square f() -> Rectangle f() -> Shape f(). - method overrides and specifies a concrete type for a parameter that is a type variable in the super e.g., B extends Awhere B#foo( o: String ) -> A#foo( o: T )
-
-
Constructor Details
-
GosuClassTransformer
-
-
Method Details
-
compile
-
compile
-
addAnnotations
private void addAnnotations() -
addGosuMarker
-
getIRAnnotations
-
hasRetentionPolicy
-
compileInnerClasses
private void compileInnerClasses() -
visitInnerClass
-
compileStaticInitializer
private void compileStaticInitializer() -
compileFields
private void compileFields() -
addInstanceFields
private void addInstanceFields() -
maybeAddEnhancedTypeMarkerField
private void maybeAddEnhancedTypeMarkerField()If this is an enhancement, add a (hacky) marker field to indicate the enhanced type for tooling. E.g., private static final <enhanced-type> ENHNANCED$TYPE; -
addStaticFields
private void addStaticFields() -
addOuterThisField
private void addOuterThisField() -
addCapturedSymbolFields
private void addCapturedSymbolFields() -
addTypeParamFields
private void addTypeParamFields() -
isNonStaticInnerClass
public boolean isNonStaticInnerClass() -
getOuterThisFieldName
-
compileConstructors
private void compileConstructors() -
compileJavaInteropBridgeConstructor
Add constructor so Java can use the Gosu generic class without explicitly passing in type arguments. Note this constructor forwards to the given constructor with default type arguments. -
makeParamSymbol
-
maybeGetTypeVarSymbolTypesForConstructor
-
maybeGetEnumSuperConstructorSymbols
-
maybeAddImplicitEnhancementParameters
private void maybeAddImplicitEnhancementParameters(DynamicFunctionSymbol dfs, List<IRSymbol> parameters) -
maybeAddImplicitExternalSymbolsParameter
private void maybeAddImplicitExternalSymbolsParameter(DynamicFunctionSymbol dfs, List<IRSymbol> parameters) -
isOverrideForSuperClass
-
maybeGetTypeVarSymbolTypes
-
addTypeParamDescriptor
private void addTypeParamDescriptor(List<IRSymbol> parameters, List<IGenericTypeVariable> genTypeVars) -
appendTypeVarsFromEnclosingFunctions
private void appendTypeVarsFromEnclosingFunctions(List<IRSymbol> parameters, IGosuClassInternal gsClass) -
maybeGetCapturedSymbolTypes
-
maybeGetOuterThisParamType
-
compileDefaultCtorBody
-
maybeAssignOuterRef
-
maybePushSupersEnclosingThisRef
-
compileMethods
private void compileMethods() -
compileBridgeMethods
-
maybeGetSuperDfs
-
getSuperDfs
private DynamicFunctionSymbol getSuperDfs(DynamicFunctionSymbol dfs, IType gsClass, IType superType) -
makeModifiersForBridgeMethod
private int makeModifiersForBridgeMethod(int modifiers) -
addCovarientProxyBridgeMethods
Add a bridge method for a Java interface method that is not only implemented by a method in this Gosu class, but is also itself a covariant "override" of its super interface E.g.,interface JavaBase { public CharSequence makeText(); } interface JavaSub extends JavaBase { public String makeText(); } class GosuSub extends JavaSub { function makeText() : String ... }
Here we need for this class to define a bridge method implementing JavaBase#makeText() : CharSequence -
getMethodOverridableFromDfs
private IJavaClassMethod getMethodOverridableFromDfs(DynamicFunctionSymbol dfs, IJavaClassInfo declaringClass) -
genInterfaceProxyBridgeMethod
-
genBridgeMethod
-
genProxyCovariantBridgeMethod
private boolean genProxyCovariantBridgeMethod(DynamicFunctionSymbol dfs, DynamicFunctionSymbol superDfs) ##hack: Potentially generates a bridge method for an overridden method where the super method is in a proxy and the proxy is for a Java interface having param types that are transformed to non-bytecode types in the type system. E.g., A guidewire platform plugin interface may declare UserBase or the like as a parameter type, which is always represented as the corresponding app derivative: UserBase -> CC's User. Essentially, we need to generate a bridge method to make the otherwise unsavory covariant parameter types work in method overrides. -
makeCovariantParamBridgeMethod
private void makeCovariantParamBridgeMethod(DynamicFunctionSymbol dfs, DynamicFunctionSymbol superDfs, IJavaClassMethod method) -
getParamsIncludingTypeParams
-
maybePassTypeParams
-
compileOuterAccessMethod
private void compileOuterAccessMethod() -
compileMethod
-
maybeWrapProgramEvaluateForManangedProgram
private IRStatement maybeWrapProgramEvaluateForManangedProgram(DynamicFunctionSymbol dfs, IRStatement methodBody) If this is:- a Gosu program and
- it has a superclass that implements IManagedProgramInstance and
- this method is
evaluate( IExternalSymbolMap )
function evaluate( map: IExternalSymbolMap ) : Object { var $failure : Throwable if( this.beforeExecution() ) { try { [method-body] // returns result } catch( $catchFailure: Throwable ) { $failure = $catchFailure } finally { this.afterExecution( $failure ) } } return null // only get here if exception not rethrown in afterExecution() }
-
isStaticEnumMethod
-
isGosuObjectMethod
-
getGosuObjectInterface
-
compileIntrinsicTypePropertyGetter
private void compileIntrinsicTypePropertyGetter() -
compileMainMethod
private void compileMainMethod() -
compileEnumValuesMethod
private void compileEnumValuesMethod() -
compileEnumAllValuesPropertyGetter
private void compileEnumAllValuesPropertyGetter() -
compileEnumValueOfMethod
private void compileEnumValueOfMethod() -
compileEnumValuePropertyGetter
private void compileEnumValuePropertyGetter() -
compileEnumCodePropertyGetter
private void compileEnumCodePropertyGetter() -
compileEnumOrdinalPropertyGetter
private void compileEnumOrdinalPropertyGetter() -
compileEnumNamePropertyGetter
private void compileEnumNamePropertyGetter() -
compileEnumDisplayNamePropertyGetter
private void compileEnumDisplayNamePropertyGetter() -
makeArrayOfTypeParameters
-
initializeInstanceFields
-
initTypeVarFields
-
initCapturedSymbolFields
-
initializeStaticFields
-
initializeAssertionsDisabledField
-
compileEnumValuesFieldInitializer
-
getOrderedFields
-
getDescriptorNoStructures
-
getParameterDescriptors
-
getParameterDescriptors
-
compileClassHeader
private void compileClassHeader() -
getSuperSlashName
-
addSourceFileRef
private void addSourceFileRef() -
getClassModifiers
private int getClassModifiers() -
getClassModifiers
-
getInterfaceNames
-
getGosuEnhancement
-
pushEnumNameAndOrdinal
-
setHasAsserts
public void setHasAsserts() -
isBlockInvoke
-
setUpFunctionContext
-
setUpFunctionContext
private void setUpFunctionContext(DynamicFunctionSymbol dfs, boolean instanceMethod, List<IRSymbol> params) -
toString
-