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 booleanprivate GosuClassTransformationContextprivate IGosuClassInternalprivate IRClassGenerates a synthetic method if: - method overrides with covariant return type - for each in ancestry e.g., Square f() -> Rectangle f() -> Shape f().static final Stringstatic final StringFields 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 voidprivate voidprivate booleanAdd 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 voidaddGosuMarker(List<IRAnnotation> annotations) private voidprivate voidprivate voidprivate voidprivate voidaddTypeParamDescriptor(List<IRSymbol> parameters, List<IGenericTypeVariable> genTypeVars) private voidprivate voidappendTypeVarsFromEnclosingFunctions(List<IRSymbol> parameters, IGosuClassInternal gsClass) private IRClasscompile()static IRClasscompile(IGosuClassInternal gsClass) private voidprivate voidprivate voidprivate IRStatementprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidprivate voidcompileEnumValuesFieldInitializer(List<IRStatement> statements) private voidprivate voidprivate voidprivate voidprivate voidAdd constructor so Java can use the Gosu generic class without explicitly passing in type arguments.private voidprivate voidprivate voidprivate voidprivate voidprivate booleangenBridgeMethod(IJavaClassMethod bridge, IJavaClassMethod m) private booleangenInterfaceProxyBridgeMethod(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 intprivate intgetClassModifiers(IGosuClass gsClass, boolean bForInnerClass) private IRTypeprivate IGosuClassInternalprivate IRType[]private List<IRAnnotation>getIRAnnotations(List<? extends IAnnotationInfo> gosuAnnotations) private IJavaClassMethodgetMethodOverridableFromDfs(DynamicFunctionSymbol dfs, IJavaClassInfo declaringClass) private List<IVarStatement>private StringgetParameterDescriptors(IType[] types) private StringgetParameterDescriptors(IJavaClassInfo[] iJavaClassInfos) private IType[]private DynamicFunctionSymbolgetSuperDfs(DynamicFunctionSymbol dfs, IType gsClass, IType superType) private IRTypeprivate booleanhasRetentionPolicy(IAnnotationInfo annotation, RetentionPolicy policy) voidinitCapturedSymbolFields(List<IRStatement> statements) private IRStatementvoidinitializeInstanceFields(List<IRStatement> statements) voidinitializeStaticFields(List<IRStatement> statements) voidinitTypeVarFields(List<IRStatement> statements) booleanprivate booleanbooleanprivate booleanprivate booleanprivate IRExpressionprivate voidmakeCovariantParamBridgeMethod(DynamicFunctionSymbol dfs, DynamicFunctionSymbol superDfs, IJavaClassMethod method) private intmakeModifiersForBridgeMethod(int modifiers) (package private) IRSymbolmakeParamSymbol(DynamicFunctionSymbol dfs, ISymbol param) private voidIf this is an enhancement, add a (hacky) marker field to indicate the enhanced type for tooling.private voidmaybeAddImplicitEnhancementParameters(DynamicFunctionSymbol dfs, List<IRSymbol> parameters) private voidmaybeAddImplicitExternalSymbolsParameter(DynamicFunctionSymbol dfs, List<IRSymbol> parameters) voidmaybeAssignOuterRef(List<IRStatement> statements) private voidmaybeGetCapturedSymbolTypes(List<IRSymbol> parameters) private voidmaybeGetEnumSuperConstructorSymbols(List<IRSymbol> parameters) private voidmaybeGetOuterThisParamType(List<IRSymbol> parameters) private List<DynamicFunctionSymbol>private voidmaybeGetTypeVarSymbolTypes(DynamicFunctionSymbol dfs, List<IRSymbol> parameters) private voidmaybeGetTypeVarSymbolTypesForConstructor(List<IRSymbol> parameters) private voidmaybePassTypeParams(DynamicFunctionSymbol dfs, List<IRExpression> args) voidmaybePushSupersEnclosingThisRef(List<IRExpression> arguments) private IRStatementmaybeWrapProgramEvaluateForManangedProgram(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:voidpushEnumNameAndOrdinal(IType type, List<IRExpression> args) voidprivate voidsetUpFunctionContext(boolean instanceMethod, List<IRSymbol> params) private voidsetUpFunctionContext(DynamicFunctionSymbol dfs, boolean instanceMethod, List<IRSymbol> params) toString()private voidvisitInnerClass(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
-