Class AbstractModelTranslator.AbstractRuleTranslator<D extends org.eclipse.emf.ecore.EObject,R extends Rule>
- java.lang.Object
-
- de.uni_hildesheim.sse.buildLanguageTranslation.AbstractModelTranslator.AbstractRuleTranslator<D,R>
-
- Type Parameters:
D- the Ecore language declaration typeR- 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.ObjectAn 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
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractRuleTranslator(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 voidaddRule(M script, R rule)Adds the given rule to theprotected abstract RcreateRule(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.RuleElementBlockgetBlock(D ruleDecl)Returns the actual rule block.protected abstract java.lang.StringgetDisplayName()Returns the display name of the language concept being processed.protected abstract org.eclipse.emf.ecore.EStructuralFeaturegetNameLiteral()Returns the name literal.protected abstract de.uni_hildesheim.sse.vil.expressions.expressionDsl.ParameterListgetParameterList(D ruleDecl)Returns the actual parameter list.protected org.eclipse.emf.ecore.EStructuralFeaturegetPostconditionLiteral()Returns the postcondition literal.protected org.eclipse.emf.ecore.EStructuralFeaturegetPreconditionLiteral()Returns the precondition literal.protected abstract TypeDescriptor<?>getReturnType(D ruleDecl, Resolver resolver)Returns the result type of the givenruleDecl.protected abstract de.uni_hildesheim.sse.vilBuildLanguage.RuleConditionsgetRuleConditions(D ruleDecl)Returns the actual rule conditions.protected voidprocessAdditionalRuleBodyElements(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 voidprocessRuleBody(RuleInfo<D,R> info, M parent)Processes a rule body.private voidprocessRuleConditions(RuleDescriptor descriptor, de.uni_hildesheim.sse.vilBuildLanguage.RuleConditions cond)Processes optional rule pre/postconditions.voidprocessRules(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.
-
-
-
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 processelements- the language elements to be processedscript- 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 objectparent- 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 objectparent- the parent script- Throws:
TranslatorException- in case that the translation fails due to semantic reasons- See Also:
#processRuleBody(RuleInfo)
-
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 declarationreturnType- the desired return typeparams- the resolved parametersparent- 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 givenruleDecl.- Parameters:
ruleDecl- the rule declarationresolver- 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 declarationrule- 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)
-
-