Class AbstractModelTranslator.AbstractRuleTranslator<D extends org.eclipse.emf.ecore.EObject,​R extends Rule>

  • Type Parameters:
    D - the Ecore language declaration type
    R - the model rule type
    Direct Known Subclasses:
    AbstractModelTranslator.RuleTranslator
    Enclosing class:
    AbstractModelTranslator<M extends Script,​L extends de.uni_hildesheim.sse.vilBuildLanguage.LanguageUnit>

    protected abstract class AbstractModelTranslator.AbstractRuleTranslator<D extends org.eclipse.emf.ecore.EObject,​R extends Rule>
    extends java.lang.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 java.lang.Class<D> cls  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractRuleTranslator​(java.lang.Class<D> cls)
      Creates a rule translator.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      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, TypeDescriptor<?> returnType, VariableDeclaration[] params, M parent)
      Creates a specific rule from the given declaration, parameters and parent.
      protected abstract de.uni_hildesheim.sse.vilBuildLanguage.RuleElementBlock getBlock​(D ruleDecl)
      Returns the actual rule block.
      protected abstract java.lang.String getDisplayName()
      Returns the display name of the language concept being processed.
      protected abstract org.eclipse.emf.ecore.EStructuralFeature getNameLiteral()
      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 getPostconditionLiteral()
      Returns the postcondition literal.
      protected org.eclipse.emf.ecore.EStructuralFeature getPreconditionLiteral()
      Returns the precondition literal.
      protected abstract TypeDescriptor<?> getReturnType​(D ruleDecl, Resolver resolver)
      Returns the result type of the given ruleDecl.
      protected abstract de.uni_hildesheim.sse.vilBuildLanguage.RuleConditions getRuleConditions​(D ruleDecl)
      Returns the actual rule conditions.
      protected void processAdditionalRuleBodyElements​(D ruleDecl, R rule, M parent, 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​(RuleDescriptor descriptor, de.uni_hildesheim.sse.vilBuildLanguage.RuleConditions cond)
      Processes optional rule pre/postconditions.
      void processRules​(L unit, java.util.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 Detail

      • cls

        private java.lang.Class<D extends org.eclipse.emf.ecore.EObject> cls
    • Constructor Detail

      • AbstractRuleTranslator

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

      • processRules

        public void processRules​(L unit,
                                 java.util.List<org.eclipse.emf.ecore.EObject> elements,
                                 M script)
                          throws 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:
        TranslatorException
      • processRule

        protected RuleInfo<D,​R> processRule​(D ruleDecl,
                                                  M parent)
                                           throws 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:
        TranslatorException - in case that the translation fails due to semantic reasons
        See Also:
        #processRuleBody(RuleInfo)
      • processRuleBody

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

        private void processRuleConditions​(RuleDescriptor descriptor,
                                           de.uni_hildesheim.sse.vilBuildLanguage.RuleConditions cond)
                                    throws TranslatorException
        Processes optional rule pre/postconditions.
        Parameters:
        ruleDecl - the ECore rule object
        parent - the parent script
        Throws:
        TranslatorException - in case that the translation fails due to semantic reasons
        See Also:
        #processRuleBody(RuleInfo)
      • addRule

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

        protected abstract java.lang.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,
                                        TypeDescriptor<?> returnType,
                                        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 TypeDescriptor<?> getReturnType​(D ruleDecl,
                                                           Resolver resolver)
                                                    throws TranslatorException
        Returns the result type of the given ruleDecl.
        Parameters:
        ruleDecl - the rule declaration
        resolver - the actual resolver instance
        Returns:
        the result type
        Throws:
        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 de.uni_hildesheim.sse.vilBuildLanguage.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,
                                                         Resolver resolver)
                                                  throws 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:
        TranslatorException - in case of translation problems
      • getBlock

        protected abstract de.uni_hildesheim.sse.vilBuildLanguage.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)