Interface CustomCodeGenerator


public interface CustomCodeGenerator
Specifies the methods which must be implemented by a custom code generator to be called-back by the common code generator.
  • Method Details

    • currentModel

      Format currentModel()
      Deliver the format which gives immediate access to the currently focused model element.
      Returns:
      the format which gives immediate access to the currently focused model element.
    • getModelStandardRepresentation

      Format getModelStandardRepresentation()
      Deliver the source text which will create the standard visual representation (as a Format) of the currently focused model element.

      (That focus must be set by calling openSingleScope(eu.bandm.tools.formattext.Model.CustomExpression, boolean).)

      Returns:
      the source text which will create the standard visual representation (as a Format) of the currently focused model element.
    • openSingleScope

      void openSingleScope(Model.CustomExpression expr, boolean isCaught)
      Shift the current focus to the given model element. The model element to switch to is evaluated w.r.t. the current focus. All subsequent model-related code will be evaluated relative to th new focus.
      Parameters:
      expr - indicates the model element which makes the new focus
      isCaught - whether the expression to be built will be executed in a block which catches the "take-alternative" exception.
    • closeSingleScope

      Format closeSingleScope(Format accumulated, boolean isCaught)
      Called after a code expression for a sinlge model element has been compiled.
      Parameters:
      accumulated - the translation result to be applied to each element of the collection.
      isCaught - whether the expression to be built will be executed in a block which catches the "take-alternative" exception.
      Returns:
      the Java source which generates the format for that single model element
    • openCollectionScope

      void openCollectionScope(Model.CustomExpression expr, Format freshLocalVar, boolean isCaught)
      Shift the current focus to the given collection fo model elements. The collection to switch to is evaluated w.r.t. the current focus. All subsequent model-related code will be evaluated relative to th new focus.
      Parameters:
      expr - indicates the collection of model elements which is the new focus.
      freshLocalVar - the name of the variable created allocated by the common code generator which is used to step through the collection.
      isCaught - whether the expression to be built will be executed in a block which catches the "take-alternative" exception.
    • closeCollectionScope

      Format closeCollectionScope(Format accumulated, boolean isCaught)
      Called after a code expression for a collection of model elements has been compiled. Must wrap that accumulated code into some Java "reduce" expression.
      Parameters:
      accumulated - the Java code compiled from the code expression, must be applied to every element of the collection which is the current focus.
      isCaught - whether the expression to be built will be executed in a block which catches the "take-alternative" exception.
      Returns:
      the Java source which generates a collection of formats, one for each model element (Wrapping this collection into some "list-type format will be done by the CommonCodeGenerator.)
    • compileSwitch

      Format compileSwitch(Model.Switch expr, boolean isCaught)
      Construct the Jaca source which realizes a "switch" expression. Adressing the selector value and all case labels is highly specific for the custom layer.
      Parameters:
      expr - the complete switch expression as a model element. It contains how to address the selector value, all cases in a map from label into format, and an optinal default case.
      isCaught - whether the expression to be built will be executed in a block which catches the "take-alternative" exception.
      Returns:
      the Java source which generates the switch statement.
    • compileCustomExpression

      @Opt Format compileCustomExpression(Model.CustomExpression expr, boolean isCaught)
      Return the Java source code which will construct the format representation for one model element.
      Parameters:
      expr - describes the model element to translate
      isCaught - whether the expression to be built will be executed in a block which catches the "take-alternative" exception.
      Returns:
      the Java source which will generates the format representation for the selected model element. // FIXME NĂ–TIG ??? cf getModelStandardRepresentation