Class AbstractModelTranslator.AbstractRuleTranslator<D extends org.eclipse.emf.ecore.EObject,R extends net.ssehub.easy.instantiation.core.model.buildlangModel.Rule>

java.lang.Object
de.uni_hildesheim.sse.buildLanguageTranslation.AbstractModelTranslator.AbstractRuleTranslator<D,R>
Type Parameters:
D - the Ecore language declaration type
R - the model rule type
Direct Known Subclasses:
AbstractModelTranslator.RuleTranslator
Enclosing class:
AbstractModelTranslator<M extends net.ssehub.easy.instantiation.core.model.buildlangModel.Script,L extends LanguageUnit>

protected abstract class AbstractModelTranslator.AbstractRuleTranslator<D extends org.eclipse.emf.ecore.EObject,R extends net.ssehub.easy.instantiation.core.model.buildlangModel.Rule> extends Object
An extensible rule translator. The functions used here are more or less the same for rules as well as later rt-VIL strategies and tactics.
Author:
Holger Eichelberger
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private Class<D>
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a rule translator.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    addRule(M script, R rule)
    Adds the given rule to the
    protected abstract R
    createRule(D ruleDecl, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> returnType, net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration[] params, M parent)
    Creates a specific rule from the given declaration, parameters and parent.
    protected abstract RuleElementBlock
    getBlock(D ruleDecl)
    Returns the actual rule block.
    protected abstract String
    Returns the display name of the language concept being processed.
    protected abstract org.eclipse.emf.ecore.EStructuralFeature
    Returns the name literal.
    protected abstract de.uni_hildesheim.sse.vil.expressions.expressionDsl.ParameterList
    getParameterList(D ruleDecl)
    Returns the actual parameter list.
    protected org.eclipse.emf.ecore.EStructuralFeature
    Returns the postcondition literal.
    protected org.eclipse.emf.ecore.EStructuralFeature
    Returns the precondition literal.
    protected abstract net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?>
    getReturnType(D ruleDecl, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver resolver)
    Returns the result type of the given ruleDecl.
    protected abstract RuleConditions
    getRuleConditions(D ruleDecl)
    Returns the actual rule conditions.
    protected void
    processAdditionalRuleBodyElements(D ruleDecl, R rule, M parent, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver resolver)
    Is called to process additional rule body elements.
    protected RuleInfo<D,R>
    processRule(D ruleDecl, M parent)
    Processes a rule declaration.
    private void
    processRuleBody(RuleInfo<D,R> info, M parent)
    Processes a rule body.
    private void
    processRuleConditions(net.ssehub.easy.instantiation.core.model.buildlangModel.RuleDescriptor descriptor, RuleConditions cond)
    Processes optional rule pre/postconditions.
    void
    processRules(L unit, List<org.eclipse.emf.ecore.EObject> elements, M script)
    Processes all rules considering dependencies and terminates with an error if not all can be resolved.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • cls

      private Class<D extends org.eclipse.emf.ecore.EObject> cls
  • Constructor Details

    • AbstractRuleTranslator

      protected AbstractRuleTranslator(Class<D> cls)
      Creates a rule translator.
      Parameters:
      cls - the language declaration class
  • Method Details

    • processRules

      public void processRules(L unit, List<org.eclipse.emf.ecore.EObject> elements, M script) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes all rules considering dependencies and terminates with an error if not all can be resolved.
      Parameters:
      unit - the language unit to process
      elements - the language elements to be processed
      script - the resulting instance being created
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException
    • processRule

      protected RuleInfo<D,R> processRule(D ruleDecl, M parent) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes a rule declaration.
      Parameters:
      ruleDecl - the ECore rule object
      parent - the parent script
      Returns:
      the actual rule information object linking ECore and build language instances
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails due to semantic reasons
      See Also:
      • invalid reference
        #processRuleBody(RuleInfo)
    • processRuleBody

      private void processRuleBody(RuleInfo<D,R> info, M parent) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes a rule body.
      Parameters:
      info - the rule information object containing the link between the ECore and the model instance
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails due to semantic reasons
    • processRuleConditions

      private void processRuleConditions(net.ssehub.easy.instantiation.core.model.buildlangModel.RuleDescriptor descriptor, RuleConditions cond) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes optional rule pre/postconditions.
      Parameters:
      ruleDecl - the ECore rule object
      parent - the parent script
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that the translation fails due to semantic reasons
      See Also:
      • invalid reference
        #processRuleBody(RuleInfo)
    • addRule

      protected abstract void addRule(M script, R rule)
      Adds the given rule to the
    • getDisplayName

      protected abstract String getDisplayName()
      Returns the display name of the language concept being processed.
      Returns:
      the display name
    • getNameLiteral

      protected abstract org.eclipse.emf.ecore.EStructuralFeature getNameLiteral()
      Returns the name literal.
      Returns:
      the name literal
    • getPreconditionLiteral

      protected org.eclipse.emf.ecore.EStructuralFeature getPreconditionLiteral()
      Returns the precondition literal.
      Returns:
      the precondition literal
    • getPostconditionLiteral

      protected org.eclipse.emf.ecore.EStructuralFeature getPostconditionLiteral()
      Returns the postcondition literal.
      Returns:
      the postcondition literal
    • createRule

      protected abstract R createRule(D ruleDecl, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> returnType, net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration[] params, M parent)
      Creates a specific rule from the given declaration, parameters and parent.
      Parameters:
      ruleDecl - the rule declaration
      returnType - the desired return type
      params - the resolved parameters
      parent - the parent
      Returns:
      the specific rule, tactic or strategy (rt-VIL)
    • getReturnType

      protected abstract net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> getReturnType(D ruleDecl, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Returns the result type of the given ruleDecl.
      Parameters:
      ruleDecl - the rule declaration
      resolver - the actual resolver instance
      Returns:
      the result type
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that resolving the type fails
    • getParameterList

      protected abstract de.uni_hildesheim.sse.vil.expressions.expressionDsl.ParameterList getParameterList(D ruleDecl)
      Returns the actual parameter list.
      Parameters:
      ruleDecl - the rule declaration
      Returns:
      the parameter list of the rule declaration
    • getRuleConditions

      protected abstract RuleConditions getRuleConditions(D ruleDecl)
      Returns the actual rule conditions.
      Parameters:
      ruleDecl - the rule declaration
      Returns:
      the rule conditions of the rule declaration
    • processAdditionalRuleBodyElements

      protected void processAdditionalRuleBodyElements(D ruleDecl, R rule, M parent, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Is called to process additional rule body elements.
      Parameters:
      ruleDecl - the rule declaration
      rule - the actual rule (to be modified as a side effect)
      resolver - the variable resolver
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case of translation problems
    • getBlock

      protected abstract RuleElementBlock getBlock(D ruleDecl)
      Returns the actual rule block.
      Parameters:
      ruleDecl - the rule declaration
      Returns:
      the rule block of the rule declaration (may be null)