Class GosuClassTransformer

    • Field Detail

      • ENUM_VALUES_FIELD

        public static final java.lang.String ENUM_VALUES_FIELD
        See Also:
        Constant Field Values
      • ENHANCED_TYPE_FIELD

        public static final java.lang.String ENHANCED_TYPE_FIELD
        See Also:
        Constant Field Values
      • _irClass

        private IRClass _irClass
      • _bHasAsserts

        private boolean _bHasAsserts
      • bridges

        java.util.Set<java.lang.String> 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 A where B#foo( o: String ) -> A#foo( o: T )
    • Constructor Detail

    • Method Detail

      • compile

        private IRClass compile()
      • addAnnotations

        private void addAnnotations()
      • addGosuMarker

        private void addGosuMarker​(java.util.List<IRAnnotation> annotations)
      • getIRAnnotations

        private java.util.List<IRAnnotation> getIRAnnotations​(java.util.List<? extends IAnnotationInfo> gosuAnnotations)
      • hasRetentionPolicy

        private boolean hasRetentionPolicy​(IAnnotationInfo annotation,
                                           java.lang.annotation.RetentionPolicy policy)
      • compileInnerClasses

        private void compileInnerClasses()
      • visitInnerClass

        private void visitInnerClass​(IGosuClass innerClass)
      • 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 ENHNANCED$TYPE;
      • addStaticFields

        private void addStaticFields()
      • addOuterThisField

        private void addOuterThisField()
      • addCapturedSymbolFields

        private void addCapturedSymbolFields()
      • addTypeParamFields

        private void addTypeParamFields()
      • isNonStaticInnerClass

        public boolean isNonStaticInnerClass()
      • getOuterThisFieldName

        public java.lang.String getOuterThisFieldName()
      • compileConstructors

        private void compileConstructors()
      • compileJavaInteropBridgeConstructor

        private void compileJavaInteropBridgeConstructor​(DynamicFunctionSymbol dfs)
        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.
      • maybeGetTypeVarSymbolTypesForConstructor

        private void maybeGetTypeVarSymbolTypesForConstructor​(java.util.List<IRSymbol> parameters)
      • maybeGetEnumSuperConstructorSymbols

        private void maybeGetEnumSuperConstructorSymbols​(java.util.List<IRSymbol> parameters)
      • maybeAddImplicitEnhancementParameters

        private void maybeAddImplicitEnhancementParameters​(DynamicFunctionSymbol dfs,
                                                           java.util.List<IRSymbol> parameters)
      • maybeAddImplicitExternalSymbolsParameter

        private void maybeAddImplicitExternalSymbolsParameter​(DynamicFunctionSymbol dfs,
                                                              java.util.List<IRSymbol> parameters)
      • addTypeParamDescriptor

        private void addTypeParamDescriptor​(java.util.List<IRSymbol> parameters,
                                            java.util.List<IGenericTypeVariable> genTypeVars)
      • appendTypeVarsFromEnclosingFunctions

        private void appendTypeVarsFromEnclosingFunctions​(java.util.List<IRSymbol> parameters,
                                                          IGosuClassInternal gsClass)
      • maybeGetCapturedSymbolTypes

        private void maybeGetCapturedSymbolTypes​(java.util.List<IRSymbol> parameters)
      • maybeGetOuterThisParamType

        private void maybeGetOuterThisParamType​(java.util.List<IRSymbol> parameters)
      • compileDefaultCtorBody

        private IRStatement compileDefaultCtorBody()
      • maybeAssignOuterRef

        public void maybeAssignOuterRef​(java.util.List<IRStatement> statements)
      • maybePushSupersEnclosingThisRef

        public void maybePushSupersEnclosingThisRef​(java.util.List<IRExpression> arguments)
      • compileMethods

        private void compileMethods()
      • makeModifiersForBridgeMethod

        private int makeModifiersForBridgeMethod​(int modifiers)
      • addCovarientProxyBridgeMethods

        private boolean addCovarientProxyBridgeMethods​(DynamicFunctionSymbol dfs)
        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
      • 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.
      • compileOuterAccessMethod

        private void compileOuterAccessMethod()
      • 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 )
        Generate the evaluate() method like so:
           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()
           }
         
      • 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

        private IRExpression makeArrayOfTypeParameters()
      • initializeInstanceFields

        public void initializeInstanceFields​(java.util.List<IRStatement> statements)
      • initTypeVarFields

        public void initTypeVarFields​(java.util.List<IRStatement> statements)
      • initCapturedSymbolFields

        public void initCapturedSymbolFields​(java.util.List<IRStatement> statements)
      • initializeStaticFields

        public void initializeStaticFields​(java.util.List<IRStatement> statements)
      • initializeAssertionsDisabledField

        private IRStatement initializeAssertionsDisabledField()
      • compileEnumValuesFieldInitializer

        private void compileEnumValuesFieldInitializer​(java.util.List<IRStatement> statements)
      • getOrderedFields

        private java.util.List<IVarStatement> getOrderedFields()
      • getDescriptorNoStructures

        private IRType getDescriptorNoStructures​(IType type)
      • getParameterDescriptors

        private java.lang.String getParameterDescriptors​(IType[] types)
      • getParameterDescriptors

        private java.lang.String getParameterDescriptors​(IJavaClassInfo[] iJavaClassInfos)
      • compileClassHeader

        private void compileClassHeader()
      • getSuperSlashName

        private IRType getSuperSlashName()
      • addSourceFileRef

        private void addSourceFileRef()
      • getClassModifiers

        private int getClassModifiers()
      • getClassModifiers

        private int getClassModifiers​(IGosuClass gsClass,
                                      boolean bForInnerClass)
      • getInterfaceNames

        private IRType[] getInterfaceNames()
      • pushEnumNameAndOrdinal

        public void pushEnumNameAndOrdinal​(IType type,
                                           java.util.List<IRExpression> args)
      • setHasAsserts

        public void setHasAsserts()
      • setUpFunctionContext

        private void setUpFunctionContext​(boolean instanceMethod,
                                          java.util.List<IRSymbol> params)
      • setUpFunctionContext

        private void setUpFunctionContext​(DynamicFunctionSymbol dfs,
                                          boolean instanceMethod,
                                          java.util.List<IRSymbol> params)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object