Browse Source

Adapted to new SA implementation

Casper Thule 3 years ago
parent
commit
a64bdf4b1e
15 changed files with 841 additions and 657 deletions
  1. 5 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/tests/CgCppBasicTest.xtend
  2. 56 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/window/window_sa_canonical_new.BASE.sa
  3. 3 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/data/InOutRulesBlockResult.java
  4. 34 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/data/ReturnInformation.java
  5. 10 1
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/data/SAScalarVariable.java
  6. 13 2
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/ControlConditionSwitch.xtend
  7. 24 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/Conversions.java
  8. 113 85
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/CppGenerator.xtend
  9. 36 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/GeneralConditionSwitch.xtend
  10. 75 142
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/InOutRulesConditionSwitch.xtend
  11. 5 2
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/InRulesConditionSwitch.xtend
  12. 3 2
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/OutRulesConditionSwitch.xtend
  13. 44 0
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/ParamConditionSwitch.xtend
  14. 410 410
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.ui/plugin.xml_gen
  15. 10 10
      DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/plugin.xml_gen

+ 5 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/tests/CgCppBasicTest.xtend

@@ -33,11 +33,15 @@ class CgCppBasicTest extends AbstractSemanticAdaptationTest {
 	@Inject extension ParseHelper<SemanticAdaptation>
 	@Inject extension  ValidationTestHelper
 
-	@Test def powerwindow_model_only() {
+	@Test def window_sa_canonical() {
 		__parseNoErrors('test_input/single_folder_spec/window/window_sa_canonical.BASE.sa', 'generated', "powerwindow");
 //		__parseNoErrorsWithValidation('test_input/single_folder_spec/window',
 //			'test_input/single_folder_spec/window/window_sa_canonical.BASE.sa');
 	}
+	
+	@Test def window_sa_canonical_new() {
+		__parseNoErrors('test_input/single_folder_spec/window/window_sa_canonical_new.BASE.sa', 'generated', "powerwindow");
+	}
 
 	def __parseNoErrorsWithValidation(String directory, String filename) {
 		val model = __parse(filename);

+ 56 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp.tests/test_input/single_folder_spec/window/window_sa_canonical_new.BASE.sa

@@ -0,0 +1,56 @@
+semantic adaptation reactive mealy WindowSA windowSA
+at "./path/to/WindowSA.fmu"
+
+	for inner fmu Window window
+		at "test_input/single_folder_spec/window/Window.fmu"
+		with input ports displacement (rad), speed (rad/s), reaction_force (N)
+		with output ports height (m), reaction_torque (N.m)
+
+input ports 	reaction_force,
+				displacement,
+				speed
+
+output ports	disp,
+				tau
+
+param 	INIT_WINDOWSA_REACTION_FORCE := 0.0,
+		INIT_WINDOWSA_DISPLACEMENT := 0.0,
+		INIT_WINDOWSA_SPEED := 0.0,
+		INIT_WINDOW_REACTION_TORQUE := 0.0,
+		INIT_WINDOW_REACTION_HEIGHT := 0.0;
+
+control rules {
+	var H_window := do_step(window, t, H);
+	return H_window;
+}
+
+in var 	stored_windowsa_reaction_force := INIT_WINDOWSA_REACTION_FORCE, 
+		stored_windowsa_displacement := INIT_WINDOWSA_DISPLACEMENT, 
+		stored_windowsa_speed := INIT_WINDOWSA_SPEED;
+
+in rules {
+	true -> {
+		stored_windowsa_reaction_force := windowSA.reaction_force;
+		stored_windowsa_displacement := windowSA.displacement;			
+		stored_windowsa_speed := windowSA.speed;
+	} --> {
+		window.reaction_force := stored_windowsa_reaction_force;
+		window.displacement := stored_windowsa_displacement; 
+		window.speed := stored_windowsa_speed;
+	};
+}
+
+out var stored_window_reaction_torque := INIT_WINDOW_REACTION_TORQUE,
+		stored_window_height := INIT_WINDOW_REACTION_HEIGHT;
+
+out rules {
+	true -> {
+		stored_window_reaction_torque := window.reaction_torque;
+		stored_window_height := window.height;
+	} --> {
+		windowSA.disp := stored_window_height / 100;
+	};
+	true -> { } --> {
+		windowSA.tau := -stored_window_reaction_torque;
+	};
+}

+ 3 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/data/InOutRulesBlockResult.java

@@ -8,13 +8,15 @@ import org.eclipse.xtext.xbase.lib.Pair;
 public class InOutRulesBlockResult extends RulesBlockResult {
 	public final LinkedHashMap<String, Pair<SVType, Object>> globalVars;
 	public final LinkedHashMap<String, GlobalInOutVariable> globalVars2;
+	public final String constructorInitialization;
 
 	public InOutRulesBlockResult(String generatedCpp, List<String> functionSignatures, 
 			LinkedHashMap<String, Pair<SVType, Object>> globalVars, 
-			LinkedHashMap<String, GlobalInOutVariable> globalVars2)
+			LinkedHashMap<String, GlobalInOutVariable> globalVars2, String constructorInitialization)
 	{
 		super(generatedCpp, functionSignatures);
 		this.globalVars = globalVars;
 		this.globalVars2 = globalVars2;
+		this.constructorInitialization = constructorInitialization;
 	}
 }

+ 34 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/data/ReturnInformation.java

@@ -11,6 +11,7 @@ public class ReturnInformation {
 	private String code = "";
 	private SAScalarVariable ConSaSv;
 	private GlobalInOutVariable conGlobVar;
+	private boolean forceType = false;
 
 	public ReturnInformation() {
 		// TODO Auto-generated constructor stub
@@ -28,7 +29,12 @@ public class ReturnInformation {
 		this.code = code;
 	}
 
-	public SVType getType() {
+	public SVType getType() throws Exception {
+		if(!typeIsSet)
+		{
+			throw new Exception(
+					"Attempt to retrieve unset type for code: " + code);
+		}
 		return type;
 	}
 
@@ -144,7 +150,34 @@ public class ReturnInformation {
 				this.setConSaSv(information2.ConSaSv);
 			}
 		}
+		
+		if(information.forceType && information2.forceType)
+		{
+			if(information.getType() != information2.getType())
+			{
+				throw new Exception(
+						"Two connected return informations with force types contain different types: "
+								+ information.getType() + " and " + information2.getType());
+			}
+		}
+		else if(information.forceType || information2.forceType)
+		{
+			
+			this.forceType = true;
+			if(information.forceType)
+				this.type = information.type;
+			else
+				this.type = information2.type;
+		}
+
+	}
+
+	public boolean getForceType() {
+		return forceType;
+	}
 
+	public void setForceType(boolean forceType) {
+		this.forceType = forceType;
 	}
 
 }

+ 10 - 1
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/data/SAScalarVariable.java

@@ -10,9 +10,10 @@ public class SAScalarVariable {
 	private String defineName;
 	private Optional<Integer> valueReference = Optional.empty();
 	private Optional<SVCausality> causality = Optional.empty();
-	private Optional<SVType> type = Optional.empty();;
+	private Optional<SVType> type = Optional.empty();
 	private String name;
 	private Optional<SVVariability> variability = Optional.empty();
+	private boolean partOfMD = false;
 
 	public ScalarVariable CalcSVar() throws MissingScalarVariableInformationException {
 
@@ -91,4 +92,12 @@ public class SAScalarVariable {
 	public void setDefineName(String defineName) {
 		this.defineName = defineName;
 	}
+
+	public boolean getPartOfMD() {
+		return partOfMD;
+	}
+
+	public void SetPartOfMD(boolean partOfMD) {
+		this.partOfMD = partOfMD;
+	}
 }

+ 13 - 2
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/ControlConditionSwitch.xtend

@@ -9,6 +9,8 @@ import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.CustomControlR
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.DoStep
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.StepSize
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.CurrentTime
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.DoStepFun
+import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SVType
 
 class ControlConditionSwitch extends InOutRulesConditionSwitch {
 
@@ -16,7 +18,7 @@ class ControlConditionSwitch extends InOutRulesConditionSwitch {
 		String adaptationName, 
 		LinkedHashMap<String,SAScalarVariable> SASVs
 	) {
-		super(adaptationClassName, adaptationName, "", null, SASVs);
+		super(adaptationClassName, adaptationName, "", null, SASVs, newLinkedHashMap());
 	}
 
 	override ReturnInformation caseControlRuleBlock(ControlRuleBlock obj) {
@@ -29,13 +31,15 @@ class ControlConditionSwitch extends InOutRulesConditionSwitch {
 		return retVal;
 	}
 
-	override ReturnInformation caseCustomControlRule(CustomControlRule object) {
+	override ReturnInformation caseCustomControlRule(CustomControlRule object) {	
 		var retVal = new ReturnInformation();
 
 		var String tempDoSwitchCode = "";
 		for (ruleStm : object.controlRulestatements) {
 			tempDoSwitchCode += doSwitch(ruleStm).code;
 		}
+		tempDoSwitchCode += System.lineSeparator() + '''return «doSwitch(object.returnstatement).code»;
+			''';
 		
 		var functionPrefix = "void ";
 		var functionNameArgs = "executeInternalControlFlow(double h, double dt)"
@@ -47,7 +51,14 @@ class ControlConditionSwitch extends InOutRulesConditionSwitch {
 					«tempDoSwitchCode»
 				}
 			''';
+		return retVal;
+	}
 
+	override ReturnInformation caseDoStepFun(DoStepFun object)
+	{
+		var retVal = new ReturnInformation();
+		retVal.code = '''this->do_step(«object.fmu.name»,«doSwitch(object.h).code»,«doSwitch(object.t).code»);''';
+		retVal.type = SVType.Integer;
 		return retVal;
 	}
 

+ 24 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/Conversions.java

@@ -3,6 +3,10 @@ package be.uantwerpen.ansymo.semanticadaptation.cg.cpp.generation;
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SVType;
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SVVariability;
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.exceptions.InvalidConversionException;
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.BoolLiteral;
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.IntLiteral;
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Literal;
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.RealLiteral;
 
 public class Conversions {
 	public static String fmiTypeToCppType(SVType t) throws InvalidConversionException {
@@ -95,5 +99,25 @@ public class Conversions {
 			throw new InvalidConversionException("The type: " + t1 + " is invalid.");
 		}
 	}
+	
+	/*
+	 * UTILITY FUNCTIONS 
+	 */
+	public static Object convertTypeToObject(SVType type, Literal object) throws Exception {
+		switch (type) {
+			case Real: {
+				return (new Float(((RealLiteral)object).getValue())).doubleValue();
+			}
+			case Integer: {
+				return ((IntLiteral)object).getValue();
+			}
+			case Boolean: {
+				return Boolean.parseBoolean(((BoolLiteral)object).getValue());
+			}
+			default: {
+				throw new Exception("Missing conversion");
+			}
+		}
+	}
 
 }

+ 113 - 85
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/CppGenerator.xtend

@@ -29,6 +29,7 @@ import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.RulesBlockResult
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.ScalarVariable
 import java.util.List
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SVType
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.ParamDeclarations
 
 class CppGenerator extends SemanticAdaptationGenerator {
 	private var IFileSystemAccess2 fsa;
@@ -90,6 +91,10 @@ class CppGenerator extends SemanticAdaptationGenerator {
 			// Defines for accessing FMU scalar variables.
 			val String fmusDefines = calcDefines2(mappedScalarVariables);
 
+			// Compile Params 
+			var LinkedHashMap<String, GlobalInOutVariable> params = newLinkedHashMap;
+			val String paramsConstructorSource = compileParams(params, type.params);
+
 			/*
 			 * This map contains all the ScalarVariables for the semantic adaptation. 
 			 * The are not populated yet, but they will be during the compilation of the in and out rule blocks. 
@@ -102,16 +107,17 @@ class CppGenerator extends SemanticAdaptationGenerator {
 
 			// Compile the in rules
 			val inRuleResult = compileInOutRuleBlocks(InputOutputType.Input, adaptation.eAllContents.toIterable.filter(
-				InRulesBlock).map[x|x as InOutRules], adapClassName, adapInteralRefName, mappedScalarVariables, SASVs);
+				InRulesBlock).map[x|x as InOutRules], adapClassName, adapInteralRefName, mappedScalarVariables, SASVs, params);
 
 			// Compile the out rules
 			val outRuleResult = compileInOutRuleBlocks(InputOutputType.Output, adaptation.eAllContents.toIterable.
 				filter(OutRulesBlock).map[x|x as InOutRules], adapClassName, adapInteralRefName, mappedScalarVariables,
-				SASVs);
+				SASVs, params);
 
-			// Merge the global variables
+			// Merge the global variables for h file and cpp file
 			// TODO: Check for duplicates
 			var LinkedHashMap<String, GlobalInOutVariable> globalVariables = newLinkedHashMap();
+			globalVariables.putAll(params);
 			globalVariables.putAll(outRuleResult.globalVars2);
 			globalVariables.putAll(inRuleResult.globalVars2);
 
@@ -119,24 +125,30 @@ class CppGenerator extends SemanticAdaptationGenerator {
 			val crtlRuleResult = compileControlRuleBlock(adaptation.eAllContents.toIterable.filter(ControlRuleBlock),
 				adapClassName, adapInteralRefName, SASVs);
 
-			/*
-			 * As the in and out rules have populated the semantic adaptation scalar variables we can generate the getFmiValue* and setFmiValue functions.
-			 */
-			val String getFuncsSource = compileGetFmiValueFunctions(adapClassName, SASVs);
-			val String setFuncsSource = compileSetFmiValueFunctions(adapClassName, SASVs);
-			
-
 			/*
 			 * Compile the constructor, destructor and initialize functions
 			 */
-			val String deAndConstructorAndInitializeSource = compileDeAndConstructorAndInitialize(adapClassName, globalVariables, fmus.head.key,
-				fmus.head.value, md.guid);
+			val String deAndConstructorAndInitializeSource = compileDeAndConstructorAndInitialize(
+				adapClassName, 
+				fmus.head.key, 
+				fmus.head.value, 
+				md.guid, 
+				paramsConstructorSource, 
+				inRuleResult.constructorInitialization, 
+				outRuleResult.constructorInitialization
+			);
 
 			/*
 			 * Compile getRuleThis function
 			 */
 			val String getRuleThisSource = compileGetRuleThis(adapClassName);
 
+			/*
+			 * The in and out rules have populated the semantic adaptation scalar variables we can generate the getFmiValue* and setFmiValue functions.
+			 */
+			val String getFuncsSource = compileGetFmiValueFunctions(adapClassName, SASVs);
+			val String setFuncsSource = compileSetFmiValueFunctions(adapClassName, SASVs);
+
 			// Compile the source file
 			val String sourceInclude = '''#include "«adapClassName».h"''';
 			val sourceFile = compileSource(
@@ -160,6 +172,7 @@ class CppGenerator extends SemanticAdaptationGenerator {
 				outRuleResult.functionSignatures,
 				crtlRuleResult.functionSignatures,
 				globalVariables,
+				params,
 				fmus,
 				SASVs.values.map[CalcSVar()].toList
 			);
@@ -169,7 +182,7 @@ class CppGenerator extends SemanticAdaptationGenerator {
 			val modelDescCreator = new ModelDescriptionCreator(adapExternalName);
 			val modelDescription = modelDescCreator.generateModelDescription(SASVs.values);
 			fsa.generateFile("modelDescription.xml", modelDescription);
-			
+
 			// Compile the fmu.cpp file
 			val fmuCppFile = StaticGenerators.GenFmuCppFile(adapClassName);
 			fsa.generateFile("Fmu.cpp", fmuCppFile);
@@ -177,6 +190,16 @@ class CppGenerator extends SemanticAdaptationGenerator {
 		}
 	}
 
+	def String compileParams(LinkedHashMap<String, GlobalInOutVariable> gVars, EList<ParamDeclarations> params) {
+		val paramsConditionSwitch = new ParamConditionSwitch(gVars);
+		var String paramsConstructorSource = "";
+		for (paramDecl : params) {
+			val doSwitchRes = paramsConditionSwitch.doSwitch(paramDecl);
+			paramsConstructorSource += doSwitchRes.code;
+		}
+		return paramsConstructorSource;
+	}
+
 	def calcSADefines(Collection<SAScalarVariable> variables) {
 		var ArrayList<String> defines = newArrayList();
 
@@ -232,89 +255,93 @@ class CppGenerator extends SemanticAdaptationGenerator {
 	 */
 	def String compileHeader(String adapClassName, String fmusDefines, String SADefines, List<String> inRulesFuncSig,
 		List<String> outRulesFuncSig, List<String> crtlRulesFuncSig,
-		LinkedHashMap<String, GlobalInOutVariable> globalVariables, ArrayList<Pair<String, String>> fmus,
+		LinkedHashMap<String, GlobalInOutVariable> globalVariables, LinkedHashMap<String, GlobalInOutVariable> params, ArrayList<Pair<String, String>> fmus,
 		Collection<ScalarVariable> sVars) {
 		return '''
-		
-			#ifndef SRC_«adapClassName.toUpperCase»_H
-			#define SRC_«adapClassName.toUpperCase»_H
-		
-			#include "SemanticAdaptation.h"
-			#include <memory>
-			#include "Fmu.h"
 			
-			using namespace std;
-			using namespace fmi2;
+				#ifndef SRC_«adapClassName.toUpperCase»_H
+				#define SRC_«adapClassName.toUpperCase»_H
 			
-			namespace adaptation
-			{
+				#include "SemanticAdaptation.h"
+				#include <memory>
+				#include "Fmu.h"
 				
-				«fmusDefines»
+				using namespace std;
+				using namespace fmi2;
 				
-				«SADefines»
-			
-				class «adapClassName» : public SemanticAdaptation<«adapClassName»>, public enable_shared_from_this<«adapClassName»>
+				namespace adaptation
 				{
-					public:
-						«adapClassName»(shared_ptr<string> resourceLocation, const fmi2CallbackFunctions* functions);
-						void initialize();
-						virtual ~«adapClassName»();
-						
-						void setFmiValue(fmi2ValueReference id, int value);
-						void setFmiValue(fmi2ValueReference id, bool value);
-						void setFmiValue(fmi2ValueReference id, double value);
-						void setFmiValue(fmi2ValueReference id, string value);
 					
-						int getFmiValueInteger(fmi2ValueReference id);
-						bool getFmiValueBoolean(fmi2ValueReference id);
-						double getFmiValueReal(fmi2ValueReference id);
-						string getFmiValueString(fmi2ValueReference id);
-						
-					private:
-						
-						«adapClassName»* getRuleThis();
-						
-						/*in rules*/
-						«inRulesFuncSig.map[x | x+";"].join("\n")»
-						
-						/*out rules*/
-						«outRulesFuncSig.map[x | x+";"].join("\n")»
-						
-						«crtlRulesFuncSig.map[x | x+";"].join("\n")»
-						
-						«FOR fmu : fmus»
-							shared_ptr<FmuComponent> «fmu.key»;
-						«ENDFOR»
-						
-						«FOR sv : sVars»
-							«Conversions.fmiTypeToCppType(sv.type)» «sv.name»;
-							«IF sv.causality == SVCausality.input»
-								bool isSet«sv.name»;
-							«ENDIF»
-						«ENDFOR»
+					«fmusDefines»
+					
+					«SADefines»
+				
+					class «adapClassName» : public SemanticAdaptation<«adapClassName»>, public enable_shared_from_this<«adapClassName»>
+					{
+						public:
+							«adapClassName»(shared_ptr<string> resourceLocation, const fmi2CallbackFunctions* functions);
+							void initialize();
+							virtual ~«adapClassName»();
+							
+							void setFmiValue(fmi2ValueReference id, int value);
+							void setFmiValue(fmi2ValueReference id, bool value);
+							void setFmiValue(fmi2ValueReference id, double value);
+							void setFmiValue(fmi2ValueReference id, string value);
 						
-						«FOR v : globalVariables.entrySet»
-							«Conversions.fmiTypeToCppType(v.value.type)» «v.key»;
-						«ENDFOR»
-				};
-			}
-			
-			#endif
+							int getFmiValueInteger(fmi2ValueReference id);
+							bool getFmiValueBoolean(fmi2ValueReference id);
+							double getFmiValueReal(fmi2ValueReference id);
+							string getFmiValueString(fmi2ValueReference id);
+							
+						private:
+							
+							«adapClassName»* getRuleThis();
+							
+							/*in rules*/
+							«inRulesFuncSig.map[x | x+";"].join("\n")»
+							
+							/*out rules*/
+							«outRulesFuncSig.map[x | x+";"].join("\n")»
+							
+							«crtlRulesFuncSig.map[x | x+";"].join("\n")»
+							
+							«FOR fmu : fmus»
+								shared_ptr<FmuComponent> «fmu.key»;
+							«ENDFOR»
+							
+							«FOR sv : sVars»
+								«Conversions.fmiTypeToCppType(sv.type)» «sv.name»;
+								«IF sv.causality == SVCausality.input»
+									bool isSet«sv.name»;
+								«ENDIF»
+							«ENDFOR»
+							
+							«FOR v : globalVariables.entrySet»
+								«Conversions.fmiTypeToCppType(v.value.type)» «v.key»;
+							«ENDFOR»
+							
+							«FOR v : params.entrySet»
+								«Conversions.fmiTypeToCppType(v.value.type)» «v.key»;
+							«ENDFOR»
+					};
+				}
+				
+				#endif
 		''';
 	}
 
 	/*
 	 * Compiles the source file constructor, destructor and the initialize function
 	 */
-	def String compileDeAndConstructorAndInitialize(String adapClassName, LinkedHashMap<String, GlobalInOutVariable> globalVariables,
-		String fmuName, String fmuTypeName, String guid) {
+	def String compileDeAndConstructorAndInitialize(String adapClassName, String fmuName, String fmuTypeName, String guid, String paramsCons, String inCons, String outCons) {
 		return '''
 			«adapClassName»::«adapClassName»(shared_ptr<string> resourceLocation, const fmi2CallbackFunctions* functions) : 
 				SemanticAdaptation(resourceLocation, createInputRules(),createOutputRules(), functions)
 			{
-				«FOR v : globalVariables.entrySet»
-					this->«(v.key)» = «v.value.value»;
-				«ENDFOR»
+				
+				«paramsCons»
+				«inCons»
+				«outCons»
 			}
 			
 			void «adapClassName»::initialize()
@@ -453,10 +480,9 @@ class CppGenerator extends SemanticAdaptationGenerator {
 	def String SplitAtSpaceAndRemoveFirst(String content) {
 		content.substring(content.indexOf(" ") + 1, content.length);
 	}
-	
-	def String removeEmptyArgumentParenthesis(String content)
-	{
-		return	content.substring(0,content.length-2);
+
+	def String removeEmptyArgumentParenthesis(String content) {
+		return content.substring(0, content.length - 2);
 	}
 
 	/*
@@ -467,12 +493,12 @@ class CppGenerator extends SemanticAdaptationGenerator {
 	def InOutRulesBlockResult compileInOutRuleBlocks(InputOutputType ioType, Iterable<InOutRules> rulesBlocks,
 		String adaptationClassName, String adaptationName,
 		LinkedHashMap<String, LinkedHashMap<String, MappedScalarVariable>> mSVars,
-		LinkedHashMap<String, SAScalarVariable> SASVs) {
+		LinkedHashMap<String, SAScalarVariable> SASVs, LinkedHashMap<String, GlobalInOutVariable> params) {
 
 		val visitor = if (ioType == InputOutputType.Input)
-				new InRulesConditionSwitch(adaptationClassName, adaptationName, mSVars, SASVs)
+				new InRulesConditionSwitch(adaptationClassName, adaptationName, mSVars, SASVs, params)
 			else
-				new OutRulesConditionSwitch(adaptationClassName, adaptationName, mSVars, SASVs);
+				new OutRulesConditionSwitch(adaptationClassName, adaptationName, mSVars, SASVs, params);
 
 		val functionName = "create" + ioType + "Rules()";
 		var String cpp = "";
@@ -509,7 +535,7 @@ class CppGenerator extends SemanticAdaptationGenerator {
 				'''
 			}
 		}
-		return new InOutRulesBlockResult(cpp, visitor.functionSignatures, visitor.vars, visitor.getGlobalVars);
+		return new InOutRulesBlockResult(cpp, visitor.functionSignatures, visitor.vars, visitor.getGlobalVars, visitor.constructorInitialization);
 	}
 
 	/*
@@ -523,6 +549,7 @@ class CppGenerator extends SemanticAdaptationGenerator {
 		var int valueReference = 0;
 		for (inport : inports) {
 			var saSV = new SAScalarVariable();
+			saSV.SetPartOfMD(true);
 			saSV.valueReference = valueReference++;
 			saSV.name = inport.name;
 			saSV.defineName = (definePrefix + inport.name).toUpperCase
@@ -532,6 +559,7 @@ class CppGenerator extends SemanticAdaptationGenerator {
 
 		for (outport : outports) {
 			var saSV = new SAScalarVariable();
+			saSV.SetPartOfMD(true);
 			saSV.valueReference = valueReference++;
 			saSV.defineName = (definePrefix + outport.name).toUpperCase
 			saSV.name = outport.name;

+ 36 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/GeneralConditionSwitch.xtend

@@ -0,0 +1,36 @@
+package be.uantwerpen.ansymo.semanticadaptation.cg.cpp.generation
+
+import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.ReturnInformation
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.util.SemanticAdaptationSwitch
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SingleParamDeclaration
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.ParamDeclarations
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Expression
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.RealLiteral
+import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SVType
+import org.eclipse.emf.ecore.EObject
+
+class GeneralConditionSwitch extends SemanticAdaptationSwitch<ReturnInformation> {
+	override ReturnInformation caseParamDeclarations(ParamDeclarations object) {
+		for (SingleParamDeclaration declaration : object.declarations) {
+			doSwitch(declaration);
+		}
+		return new ReturnInformation();
+	}
+
+	override ReturnInformation caseRealLiteral(RealLiteral object) {
+		var retInfo = new ReturnInformation();
+		retInfo.type = SVType.Real;
+		retInfo.value = Conversions.convertTypeToObject(retInfo.type, object);
+		retInfo.code = '''«object.value»''';
+		return retInfo;
+	}
+
+	override ReturnInformation defaultCase(EObject object) {
+		var retVal = new ReturnInformation();
+		retVal.code = '''[«object.class»]''';
+		System.out.println('''[«object.class»]''');
+		return retVal;
+
+//		return '''[«object.class»]''';
+	}
+}

+ 75 - 142
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/InOutRulesConditionSwitch.xtend

@@ -28,11 +28,13 @@ import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Variable
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.LValueDeclaration
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Declaration
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.IsSet
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Div
 
 abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<ReturnInformation> {
 
 	protected var LinkedHashMap<String, Pair<SVType, Object>> globalVars = newLinkedHashMap();
 	protected var LinkedHashMap<String, GlobalInOutVariable> globalVars2 = newLinkedHashMap();
+	protected var LinkedHashMap<String, GlobalInOutVariable> params;
 	private var Pair<SVType, Object> lastVal;
 	protected final String adaptationName;
 	protected final String adaptationClassName;
@@ -45,14 +47,21 @@ abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<Return
 	protected boolean inRuleCondition;
 	protected boolean inRuleTransition;
 	protected boolean inRuleOutput;
+	protected String constructorInitialization = "";
+	protected boolean inControlRule;
+	protected boolean globalDeclaration = false;
+// Add scope information to this.
+	protected var LinkedHashMap<String, SVType> localDeclarations = newLinkedHashMap();
 
 	new(
 		String adaptationClassName,
 		String adaptationName,
 		String functionPrefix,
 		LinkedHashMap<String, LinkedHashMap<String, MappedScalarVariable>> mSVars,
-		LinkedHashMap<String, SAScalarVariable> SASVs
+		LinkedHashMap<String, SAScalarVariable> SASVs,
+		LinkedHashMap<String, GlobalInOutVariable> params
 	) {
+		this.params = params;
 		this.SASVs = SASVs;
 		this.adaptationName = adaptationName;
 		this.adaptationClassName = adaptationClassName;
@@ -80,9 +89,11 @@ abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<Return
 	}
 
 	public def getVars() { return this.globalVars; }
-	
+
 	public def getGlobalVars() { return this.globalVars2; }
 
+	public def getConstructorInitialization() { return this.constructorInitialization; }
+
 	/**
 	 * This function adds a header style function signature to the list <i>functionsignatures</i> 
 	 * and returns the source style function signature
@@ -101,37 +112,30 @@ abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<Return
 	 * COMPILATION FUNCTIONS
 	 */
 	override ReturnInformation caseOutRulesBlock(OutRulesBlock object) {
+		this.globalDeclaration = true;
+
 		var retVal = new ReturnInformation();
 
 		// Get the global variables added to globalVars
 		for (gVar : object.globalOutVars) {
-			doSwitch(gVar)
+			constructorInitialization += doSwitch(gVar).code;
 		}
 		for (dataRule : object.eAllContents.toIterable.filter(DataRule)) {
 			this.incrementCount;
 			retVal.appendCode(doSwitch(dataRule).code);
 		}
-
+		this.globalDeclaration = false;
 		return retVal;
-
-//		var cpp = ""
-//		for (gVar : object.globalOutVars) {
-//			doSwitch(gVar)
-//		}
-//		for (dataRule : object.eAllContents.toIterable.filter(DataRule)) {
-//			this.incrementCount;
-//			cpp += doSwitch(dataRule);
-//		}
-//		return cpp;
 	}
 
 	override ReturnInformation caseInRulesBlock(InRulesBlock object) {
+		this.globalDeclaration = true;
 
 		var retVal = new ReturnInformation();
 
 		// Get the global variables added to globalVars
 		for (gVar : object.globalInVars) {
-			doSwitch(gVar)
+			constructorInitialization += doSwitch(gVar).code
 		}
 
 		for (DataRule dataRule : object.eAllContents.toIterable.filter(DataRule)) {
@@ -140,17 +144,8 @@ abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<Return
 			retVal.appendCode(doSwitch(dataRule).code);
 		}
 
+		this.globalDeclaration = false;
 		return retVal;
-
-//		var cpp = ""
-//		for (gVar : object.globalInVars) {
-//			doSwitch(gVar)
-//		}
-//		for (DataRule dataRule : object.eAllContents.toIterable.filter(DataRule)) {
-//			this.incrementCount;
-//			cpp += doSwitch(dataRule);
-//		}
-//		return cpp;
 	}
 
 	override ReturnInformation caseDataRule(DataRule object) {
@@ -164,12 +159,11 @@ abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<Return
 		inRuleOutput = true;
 		val outputSwitch = doSwitch(object.outputfunction);
 		inRuleOutput = false;
-		retVal.code = 
-			'''
-				«conditionSwitch.code»
-				«transitionSwitch.code»
-				«outputSwitch.code»
-			'''
+		retVal.code = '''
+			«conditionSwitch.code»
+			«transitionSwitch.code»
+			«outputSwitch.code»
+		'''
 
 		return retVal;
 	}
@@ -185,13 +179,6 @@ abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<Return
 		''';
 
 		return retVal;
-
-//		val functionSignature = createFunctionSignature("condition", "bool");
-//		'''
-//			«functionSignature»{
-//				return «doSwitch(object.condition)»;
-//			}
-//		''';
 	}
 
 	override ReturnInformation caseStateTransitionFunction(StateTransitionFunction object) {
@@ -215,31 +202,12 @@ abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<Return
 		''';
 
 		return retVal;
-
-//		val functionSig = createFunctionSignature("body", "void");
-//		'''
-//			«functionSig»{
-//				«IF object.expression !== null»
-//					«doSwitch(object.expression)»
-//				«ENDIF»
-//				«IF object.statements !== null»
-//					«FOR stm : object.statements»
-//						«doSwitch(stm)»
-//					«ENDFOR»
-//				«ENDIF»			
-//				«IF object.assignment !== null»
-//					«doSwitch(object.assignment)»
-//				«ENDIF»
-//			}
-//		''';
 	}
 
 	override ReturnInformation defaultCase(EObject object) {
 		var retVal = new ReturnInformation();
 		retVal.code = '''[«object.class»]''';
 		return retVal;
-
-//		return '''[«object.class»]''';
 	}
 
 	override ReturnInformation caseIf(If object) {
@@ -253,14 +221,6 @@ abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<Return
 		''';
 
 		return retVal;
-
-//		return '''
-//			if(«doSwitch(object.ifcondition)»){
-//				«FOR stm : object.ifstatements»
-//					«doSwitch(stm)»
-//				«ENDFOR»
-//			}
-//		''';
 	}
 
 	private def calcConSaSvData(SAScalarVariable SASV, ReturnInformation rI) {
@@ -295,39 +255,40 @@ abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<Return
 
 		retVal.code = '''«lValSwitch.code» = «rValSwitch.code»;''';
 		return retVal;
-
-//		return '''«doSwitch(object.lvalue)» = «doSwitch(object.expr)»;'''
 	}
 
 	override ReturnInformation caseMulti(Multi object) {
-		
+
 		val doSwitchLeft = doSwitch(object.left);
-		val doSwitchRight =  doSwitch(object.right);
+		val doSwitchRight = doSwitch(object.right);
 		var retVal = new ReturnInformation(doSwitchLeft, doSwitchRight);
 		retVal.code = '''«doSwitchLeft.code» * «doSwitchRight.code»''';
 		return retVal;
+	}
 
-//		return '''«doSwitch(object.left)» * «doSwitch(object.right)»''';
+	override ReturnInformation caseDiv(Div object) {
+		val doSwitchLeft = doSwitch(object.left);
+		val doSwitchRight = doSwitch(object.right);
+		var retVal = new ReturnInformation(doSwitchLeft, doSwitchRight);
+		retVal.code = '''«doSwitchLeft.code» / «doSwitchRight.code»''';
+		retVal.type = SVType.Real;
+		retVal.forceType = true;
+		return retVal;
 	}
 
 	override ReturnInformation caseNeg(Neg object) {
-		
+
 		var doSwitch = doSwitch(object.right);
 		var retVal = new ReturnInformation(doSwitch);
 		retVal.code = doSwitch.code;
 
 		return retVal;
-
-//		return '''-«doSwitch(object.right)»'''
 	}
 
 	override ReturnInformation caseSingleVarDeclaration(SingleVarDeclaration object) {
 		var retVal = new ReturnInformation();
 		retVal.code = '''«object.name»''';
 		return retVal;
-
-//		var returnVal = '''«object.name»'''
-//		return returnVal;
 	}
 
 	override ReturnInformation caseCompositeOutputFunction(CompositeOutputFunction object) {
@@ -342,16 +303,6 @@ abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<Return
 			}
 		''';
 		return retVal;
-
-//		val functionSig = createFunctionSignature("flush", "void");
-//		val returnVal = '''
-//			«functionSig»{
-//				«FOR stm : object.statements»
-//					«doSwitch(stm)»
-//				«ENDFOR»
-//			}
-//		''';
-//		return returnVal;
 	}
 
 	override ReturnInformation caseVariable(Variable object) {
@@ -360,10 +311,21 @@ abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<Return
 
 		if (object.owner === null || object.owner.name == this.adaptationName) {
 			retVal.code = '''this->«object.ref.name»''';
-			if (SASVs.containsKey(object.ref.name)) {
-				retVal.conSaSv = SASVs.get(object.ref.name);
-			} else if (globalVars2.containsKey(object.ref.name)) {
-				retVal.conGlobVar = globalVars2.get(object.ref.name);
+			if (SASVs.containsKey(object.ref.name) || globalVars2.containsKey(object.ref.name) ||
+				params.containsKey(object.ref.name)) {
+					
+				retVal.code = '''this->«object.ref.name»''';
+				
+				if (SASVs.containsKey(object.ref.name)) {
+					retVal.conSaSv = SASVs.get(object.ref.name);
+				} else if (globalVars2.containsKey(object.ref.name)) {
+					retVal.conGlobVar = globalVars2.get(object.ref.name);
+				} else if (params.containsKey(object.ref.name)) {
+					retVal.conGlobVar = params.get(object.ref.name);
+				}
+			} else if (localDeclarations.containsKey(object.ref.name)) {
+				retVal.code = '''«object.ref.name»'''
+				retVal.type = localDeclarations.get(object.ref.name);
 			}
 		} else {
 			// TODO: Extract the correct variable here
@@ -371,13 +333,6 @@ abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<Return
 			retVal.code = '''«doSwitch(object.ref).code»''';
 		}
 		return retVal;
-
-//		if (object.owner === null || object.owner.name == this.adaptationName) {
-//			return '''this->«object.ref.name»''';
-//		} else {
-//			this.externalVariableOwner = object.owner.name;
-//			return '''«doSwitch(object.ref)»''';
-//		}
 	}
 
 	override ReturnInformation caseLValueDeclaration(LValueDeclaration object) {
@@ -385,47 +340,41 @@ abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<Return
 		var retVal = new ReturnInformation();
 		retVal.code = '''«object.name»''';
 		return retVal;
-
-//		return '''«object.name»'''
 	}
 
-	/*
-	 * This is out var and in var declarations.
-	 */
 	override ReturnInformation caseDeclaration(Declaration object) {
-		var retVal2 = new ReturnInformation();
-		for (decl : object.declarations) {
+		var retVal = new ReturnInformation();
+		for (SingleVarDeclaration decl : object.declarations) {
 			var doSwitchRes = doSwitch(decl.expr);
-
-			retVal2.appendCode(doSwitchRes.code);
-
-			var globVar = new GlobalInOutVariable();
-			globVar.name = decl.name;
-			globVar.value = doSwitchRes.value;
-			globVar.type = doSwitchRes.type;
-
-			globalVars2.put(decl.name, globVar);
+			var String code = "";
+
+			if (globalDeclaration) {
+				// This is an in var or out var declaration	
+				code = '''
+					this->«decl.name» = «doSwitchRes.code»;
+				'''
+				var globVar = new GlobalInOutVariable();
+				globVar.name = decl.name;
+				globVar.value = doSwitchRes.value;
+				globVar.type = doSwitchRes.type;
+
+				globalVars2.put(decl.name, globVar);
+			} else {
+				// This is a local declaration.
+				val String type = Conversions.fmiTypeToCppType(doSwitchRes.type)
+				code = '''«type» «decl.name» = «doSwitchRes.code»''';
+				this.localDeclarations.put(decl.name, doSwitchRes.type);
+			}
+			retVal.appendCode = code;
 		}
 
-		return retVal2;
-
-//		var returnVal = "";
-//
-//		for (decl : object.declarations) {
-//			returnVal += doSwitch(decl.expr);
-//			globalVars.put(decl.name, lastVal);
-//		}
-//		return returnVal;
+		return retVal;
 	}
 
 	override ReturnInformation caseIsSet(IsSet object) {
 		var retInfo = new ReturnInformation();
-//		retInfo.type = SVType.Real;
-//		retInfo.value = convertTypeToObject(retInfo.type, object);
 		retInfo.code = '''this->isSet«(object.args as Variable).ref.name»''';
 		return retInfo;
-
-//		return '''this->isSet«(object.args as Variable).ref.name»'''
 	}
 
 	override ReturnInformation caseRealLiteral(RealLiteral object) {
@@ -434,9 +383,6 @@ abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<Return
 		retInfo.value = convertTypeToObject(retInfo.type, object);
 		retInfo.code = '''«object.value»''';
 		return retInfo;
-
-//		lastVal = convertType(SVType.Real, object);
-//		return '''«object.value»''';
 	}
 
 	override ReturnInformation caseIntLiteral(IntLiteral object) {
@@ -445,8 +391,6 @@ abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<Return
 		retInfo.value = convertTypeToObject(retInfo.type, object);
 		retInfo.code = '''«object.value»''';
 		return retInfo;
-
-//		return '''«object.value»''';
 	}
 
 	override ReturnInformation caseBoolLiteral(BoolLiteral object) {
@@ -456,17 +400,6 @@ abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<Return
 		retInfo.code = '''«object.value»''';
 
 		return retInfo;
-
-//		return '''«object.value»''';
 	}
 
-//	private def Pair<SVType, Object> convertType(SVType type, Literal object) {
-//		switch (type) {
-//			case Real: {
-//				return type -> (object as RealLiteral).value.doubleValue;
-//			}
-//			default: {
-//			}
-//		}
-//	}
 }

+ 5 - 2
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/InRulesConditionSwitch.xtend

@@ -6,13 +6,16 @@ import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SAScalarVariable
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.CompositeOutputFunction
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.ReturnInformation
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Assignment
+import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.GlobalInOutVariable
 
 class InRulesConditionSwitch extends InOutRulesConditionSwitch {
 
 	private Boolean inOutputFunction = false;
 
-	new(String adaptationClassName, String adaptationName, LinkedHashMap<String, LinkedHashMap<String, MappedScalarVariable>> mSVars, LinkedHashMap<String,SAScalarVariable> SASVs) {
-		super(adaptationClassName, adaptationName, "in_rule_", mSVars, SASVs);
+	new(String adaptationClassName, String adaptationName, LinkedHashMap<String, LinkedHashMap<String, MappedScalarVariable>> mSVars, LinkedHashMap<String,SAScalarVariable> SASVs
+		,LinkedHashMap<String, GlobalInOutVariable> params
+	) {
+		super(adaptationClassName, adaptationName, "in_rule_", mSVars, SASVs, params);
 	}
 
 

+ 3 - 2
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/OutRulesConditionSwitch.xtend

@@ -5,13 +5,14 @@ import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.MappedScalarVariable
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.SAScalarVariable
 import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.ReturnInformation
 import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.Port
+import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.GlobalInOutVariable
 
 public class OutRulesConditionSwitch extends InOutRulesConditionSwitch {
 	new(String adaptationClassName, 
 		String adaptationName,  
 		LinkedHashMap<String, LinkedHashMap<String, MappedScalarVariable>> mSVars,
-		LinkedHashMap<String,SAScalarVariable> SASVs) {
-		super(adaptationClassName, adaptationName, "out_rule_", mSVars, SASVs);
+		LinkedHashMap<String,SAScalarVariable> SASVs, LinkedHashMap<String, GlobalInOutVariable> params) {
+		super(adaptationClassName, adaptationName, "out_rule_", mSVars, SASVs, params);
 	}
 	
 	override ReturnInformation casePort(Port object){

+ 44 - 0
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/ParamConditionSwitch.xtend

@@ -0,0 +1,44 @@
+package be.uantwerpen.ansymo.semanticadaptation.cg.cpp.generation
+
+import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.GlobalInOutVariable
+import be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data.ReturnInformation
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.ParamDeclarations
+import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SingleParamDeclaration
+import java.util.LinkedHashMap
+
+class ParamConditionSwitch extends GeneralConditionSwitch {
+	var LinkedHashMap<String, GlobalInOutVariable> gVars;
+	new(LinkedHashMap<String, GlobalInOutVariable> gVars) {
+		this.gVars = gVars;
+	}
+
+	override ReturnInformation caseParamDeclarations(ParamDeclarations object) {
+		var retInfo = new ReturnInformation();
+		for (SingleParamDeclaration declaration : object.declarations) {
+			var doSwitchRes = doSwitch(declaration);
+			retInfo.code = retInfo.code +
+				'''
+					«doSwitchRes.code»
+				'''
+		}
+		return retInfo;
+	}
+
+	override ReturnInformation caseSingleParamDeclaration(SingleParamDeclaration object) {
+		val doSwitchRes = doSwitch(object.expr);
+		var GlobalInOutVariable gVar = new GlobalInOutVariable();
+		gVar.type = doSwitchRes.type;
+		gVar.name = object.name;
+		// TODO: Does this hold?
+		gVar.value = doSwitchRes.value;
+		this.gVars.put(gVar.name, gVar);		
+		val retInfo = new ReturnInformation();
+		retInfo.code = 
+		'''
+			«gVar.name» = «doSwitchRes.code»;
+		'''
+		return retInfo;
+
+	}
+
+}

+ 410 - 410
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.ui/plugin.xml_gen

@@ -1,410 +1,410 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin>
-	<extension
-		point="org.eclipse.ui.editors">
-		<editor
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.XtextEditor"
-			contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor"
-			default="true"
-			extensions="sa"
-			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
-			name="SemanticAdaptation Editor">
-		</editor>
-	</extension>
-	<extension
-		point="org.eclipse.ui.handlers">
-		<handler
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclarationHandler"
-			commandId="org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclaration">
-			<activeWhen>
-				<reference
-					definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
-				</reference>
-			</activeWhen>
-		</handler>
-		<handler
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.handler.ValidateActionHandler"
-			commandId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.validate">
-		<activeWhen>
-			<reference
-					definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
-			</reference>
-		</activeWhen>
-		</handler>
-		<!-- copy qualified name -->
-		<handler
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedNameHandler"
-			commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName">
-			<activeWhen>
-				<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened" />
-			</activeWhen>
-		</handler>
-		<handler
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedNameHandler"
-			commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName">
-			<activeWhen>
-				<and>
-					<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.XtextEditor.opened" />
-					<iterate>
-						<adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" />
-					</iterate>
-				</and>
-			</activeWhen>
-		</handler>
-	</extension>
-	<extension point="org.eclipse.core.expressions.definitions">
-		<definition id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
-			<and>
-				<reference definitionId="isActiveEditorAnInstanceOfXtextEditor"/>
-				<with variable="activeEditor">
-					<test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName"
-						value="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
-						forcePluginActivation="true"/>
-				</with>
-			</and>
-		</definition>
-		<definition id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.XtextEditor.opened">
-			<and>
-				<reference definitionId="isXtextEditorActive"/>
-				<with variable="activeEditor">
-					<test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName"
-						value="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
-						forcePluginActivation="true"/>
-				</with>
-			</and>
-		</definition>
-	</extension>
-	<extension
-			point="org.eclipse.ui.preferencePages">
-		<page
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
-			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
-			name="SemanticAdaptation">
-			<keywordReference id="be.uantwerpen.ansymo.semanticadaptation.ui.keyword_SemanticAdaptation"/>
-		</page>
-		<page
-			category="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.syntaxcoloring.SyntaxColoringPreferencePage"
-			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.coloring"
-			name="Syntax Coloring">
-			<keywordReference id="be.uantwerpen.ansymo.semanticadaptation.ui.keyword_SemanticAdaptation"/>
-		</page>
-		<page
-			category="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.templates.XtextTemplatePreferencePage"
-			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.templates"
-			name="Templates">
-			<keywordReference id="be.uantwerpen.ansymo.semanticadaptation.ui.keyword_SemanticAdaptation"/>
-		</page>
-	</extension>
-	<extension
-			point="org.eclipse.ui.propertyPages">
-		<page
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
-			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
-			name="SemanticAdaptation">
-			<keywordReference id="be.uantwerpen.ansymo.semanticadaptation.ui.keyword_SemanticAdaptation"/>
-			<enabledWhen>
-				<adapt type="org.eclipse.core.resources.IProject"/>
-			</enabledWhen>
-			<filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/>
-		</page>
-	</extension>
-	<extension
-		point="org.eclipse.ui.keywords">
-		<keyword
-			id="be.uantwerpen.ansymo.semanticadaptation.ui.keyword_SemanticAdaptation"
-			label="SemanticAdaptation"/>
-	</extension>
-	<extension
-		point="org.eclipse.ui.commands">
-	<command
-			description="Trigger expensive validation"
-			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.validate"
-			name="Validate">
-	</command>
-	<!-- copy qualified name -->
-	<command
-			id="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
-			categoryId="org.eclipse.ui.category.edit"
-			description="Copy the qualified name for the selected element"
-			name="Copy Qualified Name">
-	</command>
-	<command
-			id="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName"
-			categoryId="org.eclipse.ui.category.edit"
-			description="Copy the qualified name for the selected element"
-			name="Copy Qualified Name">
-	</command>
-	</extension>
-	<extension point="org.eclipse.ui.menus">
-		<menuContribution
-			locationURI="popup:#TextEditorContext?after=group.edit">
-			 <command
-				 commandId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.validate"
-				 style="push"
-				 tooltip="Trigger expensive validation">
-			<visibleWhen checkEnabled="false">
-				<reference
-					definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
-				</reference>
-			</visibleWhen>
-		</command>
-		</menuContribution>
-		<!-- copy qualified name -->
-		<menuContribution locationURI="popup:#TextEditorContext?after=copy">
-			<command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
-				style="push" tooltip="Copy Qualified Name">
-				<visibleWhen checkEnabled="false">
-					<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened" />
-				</visibleWhen>
-			</command>
-		</menuContribution>
-		<menuContribution locationURI="menu:edit?after=copy">
-			<command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
-				style="push" tooltip="Copy Qualified Name">
-				<visibleWhen checkEnabled="false">
-					<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened" />
-				</visibleWhen>
-			</command>
-		</menuContribution>
-		<menuContribution locationURI="popup:org.eclipse.xtext.ui.outline?after=additions">
-			<command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName"
-				style="push" tooltip="Copy Qualified Name">
-				<visibleWhen checkEnabled="false">
-					<and>
-						<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.XtextEditor.opened" />
-						<iterate>
-							<adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" />
-						</iterate>
-					</and>
-				</visibleWhen>
-			</command>
-		</menuContribution>
-	</extension>
-	<extension point="org.eclipse.ui.menus">
-		<menuContribution locationURI="popup:#TextEditorContext?endof=group.find">
-			<command commandId="org.eclipse.xtext.ui.editor.FindReferences">
-				<visibleWhen checkEnabled="false">
-					<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
-					</reference>
-				</visibleWhen>
-			</command>
-		</menuContribution>
-	</extension>
-	<extension point="org.eclipse.ui.handlers">
-		<handler
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.findrefs.FindReferencesHandler"
-			commandId="org.eclipse.xtext.ui.editor.FindReferences">
-			<activeWhen>
-				<reference
-					definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
-				</reference>
-			</activeWhen>
-		</handler>
-	</extension>
-	<!-- adding resource factories -->
-	<extension
-		point="org.eclipse.emf.ecore.extension_parser">
-		<parser
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceFactory"
-			type="sa">
-		</parser>
-	</extension>
-	<extension point="org.eclipse.xtext.extension_resourceServiceProvider">
-		<resourceServiceProvider
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.resource.IResourceUIServiceProvider"
-			uriExtension="sa">
-		</resourceServiceProvider>
-	</extension>
-	<!-- marker definitions for be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation -->
-	<extension
-			id="semanticadaptation.check.fast"
-			name="SemanticAdaptation Problem"
-			point="org.eclipse.core.resources.markers">
-		<super type="org.eclipse.xtext.ui.check.fast"/>
-		<persistent value="true"/>
-	</extension>
-	<extension
-			id="semanticadaptation.check.normal"
-			name="SemanticAdaptation Problem"
-			point="org.eclipse.core.resources.markers">
-		<super type="org.eclipse.xtext.ui.check.normal"/>
-		<persistent value="true"/>
-	</extension>
-	<extension
-			id="semanticadaptation.check.expensive"
-			name="SemanticAdaptation Problem"
-			point="org.eclipse.core.resources.markers">
-		<super type="org.eclipse.xtext.ui.check.expensive"/>
-		<persistent value="true"/>
-	</extension>
-	<extension point="org.eclipse.xtext.builder.participant">
-		<participant
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.builder.IXtextBuilderParticipant"
-			fileExtensions="sa"/>
-	</extension>
-	<extension point="org.eclipse.ui.preferencePages">
-		<page
-			category="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage"
-			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.compiler.preferencePage"
-			name="Compiler">
-			<keywordReference id="be.uantwerpen.ansymo.semanticadaptation.ui.keyword_SemanticAdaptation"/>
-		</page>
-	</extension>
-	<extension point="org.eclipse.ui.propertyPages">
-		<page
-			category="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage"
-			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.compiler.propertyPage"
-			name="Compiler">
-			<keywordReference id="be.uantwerpen.ansymo.semanticadaptation.ui.keyword_SemanticAdaptation"/>
-			<enabledWhen>
-				<adapt type="org.eclipse.core.resources.IProject"/>
-			</enabledWhen>
-			<filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/>
-		</page>
-	</extension>
-	<extension point="org.eclipse.ui.menus">
-		<menuContribution locationURI="popup:#TextEditorContext?after=xtext.ui.openDeclaration">
-			<command
-				commandId="org.eclipse.xtext.ui.OpenGeneratedFileCommand"
-				id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.OpenGeneratedCode"
-				style="push">
-				<visibleWhen checkEnabled="false">
-					<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened" />
-				</visibleWhen>
-			</command>
-		</menuContribution>
-	</extension>
-	<extension point="org.eclipse.ui.handlers">
-		<handler
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.generator.trace.OpenGeneratedFileHandler"
-			commandId="org.eclipse.xtext.ui.OpenGeneratedFileCommand">
-			<activeWhen>
-				<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened" />
-			</activeWhen>
-		</handler>
-	</extension>
-	<!-- Quick Outline -->
-	<extension
-		point="org.eclipse.ui.handlers">
-		<handler 
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.outline.quickoutline.ShowQuickOutlineActionHandler"
-			commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline">
-			<activeWhen>
-				<reference
-					definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
-				</reference>
-			</activeWhen>
-		</handler>
-	</extension>
-	<extension
-		point="org.eclipse.ui.commands">
-		<command
-			description="Open the quick outline."
-			id="org.eclipse.xtext.ui.editor.outline.QuickOutline"
-			name="Quick Outline">
-		</command>
-	</extension>
-	<extension point="org.eclipse.ui.menus">
-		<menuContribution
-			locationURI="popup:#TextEditorContext?after=group.open">
-			<command commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline"
-				style="push"
-				tooltip="Open Quick Outline">
-				<visibleWhen checkEnabled="false">
-					<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened"/>
-				</visibleWhen>
-			</command>
-		</menuContribution>
-	</extension>
-	<!-- quickfix marker resolution generator for be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation -->
-	<extension
-			point="org.eclipse.ui.ide.markerResolution">
-		<markerResolutionGenerator
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
-			markerType="be.uantwerpen.ansymo.semanticadaptation.ui.semanticadaptation.check.fast">
-			<attribute
-				name="FIXABLE_KEY"
-				value="true">
-			</attribute>
-		</markerResolutionGenerator>
-		<markerResolutionGenerator
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
-			markerType="be.uantwerpen.ansymo.semanticadaptation.ui.semanticadaptation.check.normal">
-			<attribute
-				name="FIXABLE_KEY"
-				value="true">
-			</attribute>
-		</markerResolutionGenerator>
-		<markerResolutionGenerator
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
-			markerType="be.uantwerpen.ansymo.semanticadaptation.ui.semanticadaptation.check.expensive">
-			<attribute
-				name="FIXABLE_KEY"
-				value="true">
-			</attribute>
-		</markerResolutionGenerator>
-	</extension>
-	<!-- Rename Refactoring -->
-	<extension point="org.eclipse.ui.handlers">
-		<handler 
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.DefaultRenameElementHandler"
-			commandId="org.eclipse.xtext.ui.refactoring.RenameElement">
-			<activeWhen>
-				<reference
-					definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
-				</reference>
-			</activeWhen>
-		</handler>
-	</extension>
-	<extension point="org.eclipse.ui.menus">
-		<menuContribution
-			locationURI="popup:#TextEditorContext?after=group.edit">
-			<command commandId="org.eclipse.xtext.ui.refactoring.RenameElement"
-				style="push">
-				<visibleWhen checkEnabled="false">
-					<reference
-						definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
-					</reference>
-				</visibleWhen>
-			</command>
-		</menuContribution>
-	</extension>
-	<extension point="org.eclipse.ui.preferencePages">
-		<page
-			category="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.RefactoringPreferencePage"
-			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.refactoring"
-			name="Refactoring">
-			<keywordReference id="be.uantwerpen.ansymo.semanticadaptation.ui.keyword_SemanticAdaptation"/>
-		</page>
-	</extension>
-	<extension point="org.eclipse.compare.contentViewers">
-		<viewer id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.compare.contentViewers"
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator"
-			extensions="sa">
-		</viewer>
-	</extension>
-	<extension point="org.eclipse.compare.contentMergeViewers">
-		<viewer id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.compare.contentMergeViewers"
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator"
-			extensions="sa" label="SemanticAdaptation Compare">
-		</viewer>
-	</extension>
-	<extension point="org.eclipse.ui.editors.documentProviders">
-		<provider id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.editors.documentProviders"
-			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.model.XtextDocumentProvider"
-			extensions="sa">
-		</provider>
-	</extension>
-	<extension point="org.eclipse.team.core.fileTypes">
-		<fileTypes
-			extension="sa"
-			type="text">
-		</fileTypes>
-	</extension>
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+	<extension
+		point="org.eclipse.ui.editors">
+		<editor
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.XtextEditor"
+			contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor"
+			default="true"
+			extensions="sa"
+			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
+			name="SemanticAdaptation Editor">
+		</editor>
+	</extension>
+	<extension
+		point="org.eclipse.ui.handlers">
+		<handler
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclarationHandler"
+			commandId="org.eclipse.xtext.ui.editor.hyperlinking.OpenDeclaration">
+			<activeWhen>
+				<reference
+					definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
+				</reference>
+			</activeWhen>
+		</handler>
+		<handler
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.handler.ValidateActionHandler"
+			commandId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.validate">
+		<activeWhen>
+			<reference
+					definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
+			</reference>
+		</activeWhen>
+		</handler>
+		<!-- copy qualified name -->
+		<handler
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedNameHandler"
+			commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName">
+			<activeWhen>
+				<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened" />
+			</activeWhen>
+		</handler>
+		<handler
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedNameHandler"
+			commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName">
+			<activeWhen>
+				<and>
+					<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.XtextEditor.opened" />
+					<iterate>
+						<adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" />
+					</iterate>
+				</and>
+			</activeWhen>
+		</handler>
+	</extension>
+	<extension point="org.eclipse.core.expressions.definitions">
+		<definition id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
+			<and>
+				<reference definitionId="isActiveEditorAnInstanceOfXtextEditor"/>
+				<with variable="activeEditor">
+					<test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName"
+						value="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
+						forcePluginActivation="true"/>
+				</with>
+			</and>
+		</definition>
+		<definition id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.XtextEditor.opened">
+			<and>
+				<reference definitionId="isXtextEditorActive"/>
+				<with variable="activeEditor">
+					<test property="org.eclipse.xtext.ui.editor.XtextEditor.languageName"
+						value="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
+						forcePluginActivation="true"/>
+				</with>
+			</and>
+		</definition>
+	</extension>
+	<extension
+			point="org.eclipse.ui.preferencePages">
+		<page
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
+			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
+			name="SemanticAdaptation">
+			<keywordReference id="be.uantwerpen.ansymo.semanticadaptation.ui.keyword_SemanticAdaptation"/>
+		</page>
+		<page
+			category="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.syntaxcoloring.SyntaxColoringPreferencePage"
+			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.coloring"
+			name="Syntax Coloring">
+			<keywordReference id="be.uantwerpen.ansymo.semanticadaptation.ui.keyword_SemanticAdaptation"/>
+		</page>
+		<page
+			category="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.templates.XtextTemplatePreferencePage"
+			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.templates"
+			name="Templates">
+			<keywordReference id="be.uantwerpen.ansymo.semanticadaptation.ui.keyword_SemanticAdaptation"/>
+		</page>
+	</extension>
+	<extension
+			point="org.eclipse.ui.propertyPages">
+		<page
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage"
+			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
+			name="SemanticAdaptation">
+			<keywordReference id="be.uantwerpen.ansymo.semanticadaptation.ui.keyword_SemanticAdaptation"/>
+			<enabledWhen>
+				<adapt type="org.eclipse.core.resources.IProject"/>
+			</enabledWhen>
+			<filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/>
+		</page>
+	</extension>
+	<extension
+		point="org.eclipse.ui.keywords">
+		<keyword
+			id="be.uantwerpen.ansymo.semanticadaptation.ui.keyword_SemanticAdaptation"
+			label="SemanticAdaptation"/>
+	</extension>
+	<extension
+		point="org.eclipse.ui.commands">
+	<command
+			description="Trigger expensive validation"
+			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.validate"
+			name="Validate">
+	</command>
+	<!-- copy qualified name -->
+	<command
+			id="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
+			categoryId="org.eclipse.ui.category.edit"
+			description="Copy the qualified name for the selected element"
+			name="Copy Qualified Name">
+	</command>
+	<command
+			id="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName"
+			categoryId="org.eclipse.ui.category.edit"
+			description="Copy the qualified name for the selected element"
+			name="Copy Qualified Name">
+	</command>
+	</extension>
+	<extension point="org.eclipse.ui.menus">
+		<menuContribution
+			locationURI="popup:#TextEditorContext?after=group.edit">
+			 <command
+				 commandId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.validate"
+				 style="push"
+				 tooltip="Trigger expensive validation">
+			<visibleWhen checkEnabled="false">
+				<reference
+					definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
+				</reference>
+			</visibleWhen>
+		</command>
+		</menuContribution>
+		<!-- copy qualified name -->
+		<menuContribution locationURI="popup:#TextEditorContext?after=copy">
+			<command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
+				style="push" tooltip="Copy Qualified Name">
+				<visibleWhen checkEnabled="false">
+					<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened" />
+				</visibleWhen>
+			</command>
+		</menuContribution>
+		<menuContribution locationURI="menu:edit?after=copy">
+			<command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.EditorCopyQualifiedName"
+				style="push" tooltip="Copy Qualified Name">
+				<visibleWhen checkEnabled="false">
+					<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened" />
+				</visibleWhen>
+			</command>
+		</menuContribution>
+		<menuContribution locationURI="popup:org.eclipse.xtext.ui.outline?after=additions">
+			<command commandId="org.eclipse.xtext.ui.editor.copyqualifiedname.OutlineCopyQualifiedName"
+				style="push" tooltip="Copy Qualified Name">
+				<visibleWhen checkEnabled="false">
+					<and>
+						<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.XtextEditor.opened" />
+						<iterate>
+							<adapt type="org.eclipse.xtext.ui.editor.outline.IOutlineNode" />
+						</iterate>
+					</and>
+				</visibleWhen>
+			</command>
+		</menuContribution>
+	</extension>
+	<extension point="org.eclipse.ui.menus">
+		<menuContribution locationURI="popup:#TextEditorContext?endof=group.find">
+			<command commandId="org.eclipse.xtext.ui.editor.FindReferences">
+				<visibleWhen checkEnabled="false">
+					<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
+					</reference>
+				</visibleWhen>
+			</command>
+		</menuContribution>
+	</extension>
+	<extension point="org.eclipse.ui.handlers">
+		<handler
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.findrefs.FindReferencesHandler"
+			commandId="org.eclipse.xtext.ui.editor.FindReferences">
+			<activeWhen>
+				<reference
+					definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
+				</reference>
+			</activeWhen>
+		</handler>
+	</extension>
+	<!-- adding resource factories -->
+	<extension
+		point="org.eclipse.emf.ecore.extension_parser">
+		<parser
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.resource.IResourceFactory"
+			type="sa">
+		</parser>
+	</extension>
+	<extension point="org.eclipse.xtext.extension_resourceServiceProvider">
+		<resourceServiceProvider
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.resource.IResourceUIServiceProvider"
+			uriExtension="sa">
+		</resourceServiceProvider>
+	</extension>
+	<!-- marker definitions for be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation -->
+	<extension
+			id="semanticadaptation.check.fast"
+			name="SemanticAdaptation Problem"
+			point="org.eclipse.core.resources.markers">
+		<super type="org.eclipse.xtext.ui.check.fast"/>
+		<persistent value="true"/>
+	</extension>
+	<extension
+			id="semanticadaptation.check.normal"
+			name="SemanticAdaptation Problem"
+			point="org.eclipse.core.resources.markers">
+		<super type="org.eclipse.xtext.ui.check.normal"/>
+		<persistent value="true"/>
+	</extension>
+	<extension
+			id="semanticadaptation.check.expensive"
+			name="SemanticAdaptation Problem"
+			point="org.eclipse.core.resources.markers">
+		<super type="org.eclipse.xtext.ui.check.expensive"/>
+		<persistent value="true"/>
+	</extension>
+	<extension point="org.eclipse.xtext.builder.participant">
+		<participant
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.builder.IXtextBuilderParticipant"
+			fileExtensions="sa"/>
+	</extension>
+	<extension point="org.eclipse.ui.preferencePages">
+		<page
+			category="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage"
+			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.compiler.preferencePage"
+			name="Compiler">
+			<keywordReference id="be.uantwerpen.ansymo.semanticadaptation.ui.keyword_SemanticAdaptation"/>
+		</page>
+	</extension>
+	<extension point="org.eclipse.ui.propertyPages">
+		<page
+			category="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage"
+			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.compiler.propertyPage"
+			name="Compiler">
+			<keywordReference id="be.uantwerpen.ansymo.semanticadaptation.ui.keyword_SemanticAdaptation"/>
+			<enabledWhen>
+				<adapt type="org.eclipse.core.resources.IProject"/>
+			</enabledWhen>
+			<filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/>
+		</page>
+	</extension>
+	<extension point="org.eclipse.ui.menus">
+		<menuContribution locationURI="popup:#TextEditorContext?after=xtext.ui.openDeclaration">
+			<command
+				commandId="org.eclipse.xtext.ui.OpenGeneratedFileCommand"
+				id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.OpenGeneratedCode"
+				style="push">
+				<visibleWhen checkEnabled="false">
+					<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened" />
+				</visibleWhen>
+			</command>
+		</menuContribution>
+	</extension>
+	<extension point="org.eclipse.ui.handlers">
+		<handler
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.generator.trace.OpenGeneratedFileHandler"
+			commandId="org.eclipse.xtext.ui.OpenGeneratedFileCommand">
+			<activeWhen>
+				<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened" />
+			</activeWhen>
+		</handler>
+	</extension>
+	<!-- Quick Outline -->
+	<extension
+		point="org.eclipse.ui.handlers">
+		<handler 
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.outline.quickoutline.ShowQuickOutlineActionHandler"
+			commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline">
+			<activeWhen>
+				<reference
+					definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
+				</reference>
+			</activeWhen>
+		</handler>
+	</extension>
+	<extension
+		point="org.eclipse.ui.commands">
+		<command
+			description="Open the quick outline."
+			id="org.eclipse.xtext.ui.editor.outline.QuickOutline"
+			name="Quick Outline">
+		</command>
+	</extension>
+	<extension point="org.eclipse.ui.menus">
+		<menuContribution
+			locationURI="popup:#TextEditorContext?after=group.open">
+			<command commandId="org.eclipse.xtext.ui.editor.outline.QuickOutline"
+				style="push"
+				tooltip="Open Quick Outline">
+				<visibleWhen checkEnabled="false">
+					<reference definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened"/>
+				</visibleWhen>
+			</command>
+		</menuContribution>
+	</extension>
+	<!-- quickfix marker resolution generator for be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation -->
+	<extension
+			point="org.eclipse.ui.ide.markerResolution">
+		<markerResolutionGenerator
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
+			markerType="be.uantwerpen.ansymo.semanticadaptation.ui.semanticadaptation.check.fast">
+			<attribute
+				name="FIXABLE_KEY"
+				value="true">
+			</attribute>
+		</markerResolutionGenerator>
+		<markerResolutionGenerator
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
+			markerType="be.uantwerpen.ansymo.semanticadaptation.ui.semanticadaptation.check.normal">
+			<attribute
+				name="FIXABLE_KEY"
+				value="true">
+			</attribute>
+		</markerResolutionGenerator>
+		<markerResolutionGenerator
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"
+			markerType="be.uantwerpen.ansymo.semanticadaptation.ui.semanticadaptation.check.expensive">
+			<attribute
+				name="FIXABLE_KEY"
+				value="true">
+			</attribute>
+		</markerResolutionGenerator>
+	</extension>
+	<!-- Rename Refactoring -->
+	<extension point="org.eclipse.ui.handlers">
+		<handler 
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.DefaultRenameElementHandler"
+			commandId="org.eclipse.xtext.ui.refactoring.RenameElement">
+			<activeWhen>
+				<reference
+					definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
+				</reference>
+			</activeWhen>
+		</handler>
+	</extension>
+	<extension point="org.eclipse.ui.menus">
+		<menuContribution
+			locationURI="popup:#TextEditorContext?after=group.edit">
+			<command commandId="org.eclipse.xtext.ui.refactoring.RenameElement"
+				style="push">
+				<visibleWhen checkEnabled="false">
+					<reference
+						definitionId="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.Editor.opened">
+					</reference>
+				</visibleWhen>
+			</command>
+		</menuContribution>
+	</extension>
+	<extension point="org.eclipse.ui.preferencePages">
+		<page
+			category="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation"
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.RefactoringPreferencePage"
+			id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.refactoring"
+			name="Refactoring">
+			<keywordReference id="be.uantwerpen.ansymo.semanticadaptation.ui.keyword_SemanticAdaptation"/>
+		</page>
+	</extension>
+	<extension point="org.eclipse.compare.contentViewers">
+		<viewer id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.compare.contentViewers"
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator"
+			extensions="sa">
+		</viewer>
+	</extension>
+	<extension point="org.eclipse.compare.contentMergeViewers">
+		<viewer id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.compare.contentMergeViewers"
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.compare.InjectableViewerCreator"
+			extensions="sa" label="SemanticAdaptation Compare">
+		</viewer>
+	</extension>
+	<extension point="org.eclipse.ui.editors.documentProviders">
+		<provider id="be.uantwerpen.ansymo.semanticadaptation.SemanticAdaptation.editors.documentProviders"
+			class="be.uantwerpen.ansymo.semanticadaptation.ui.SemanticAdaptationExecutableExtensionFactory:org.eclipse.xtext.ui.editor.model.XtextDocumentProvider"
+			extensions="sa">
+		</provider>
+	</extension>
+	<extension point="org.eclipse.team.core.fileTypes">
+		<fileTypes
+			extension="sa"
+			type="text">
+		</fileTypes>
+	</extension>
+</plugin>

+ 10 - 10
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation/plugin.xml_gen

@@ -1,10 +1,10 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin>
-	<extension point="org.eclipse.emf.ecore.generated_package">
-		<package 
-			uri = "http://www.uantwerpen.be/ansymo/semanticadaptation/SemanticAdaptation"
-			class = "be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SemanticAdaptationPackage"
-			genModel = "model/generated/SemanticAdaptation.genmodel" />
-	</extension>
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+	<extension point="org.eclipse.emf.ecore.generated_package">
+		<package 
+			uri = "http://www.uantwerpen.be/ansymo/semanticadaptation/SemanticAdaptation"
+			class = "be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SemanticAdaptationPackage"
+			genModel = "model/generated/SemanticAdaptation.genmodel" />
+	</extension>
+</plugin>