Browse Source

Refactored to remove unsafe value variable

Casper Thule 7 years ago
parent
commit
690363cab5

+ 4 - 29
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/data/GlobalInOutVariable.java

@@ -2,36 +2,11 @@ package be.uantwerpen.ansymo.semanticadaptation.cg.cpp.data;
 
 public class GlobalInOutVariable {
 
-	private String name;
-	private SVType type;
-	private Object value;
+	public final String name;
+	public final SVType type;
 	
-	public GlobalInOutVariable() {
-		// TODO Auto-generated constructor stub
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public SVType getType() {
-		return type;
-	}
-
-	public void setType(SVType type) {
+	public GlobalInOutVariable(String name, SVType type) {
+		this.name=name;
 		this.type = type;
 	}
-
-	public Object getValue() {
-		return value;
-	}
-
-	public void setValue(Object value) {
-		this.value = value;
-	}
-
 }

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

@@ -74,11 +74,11 @@ public class ReturnInformation {
 	public void setConGlobVar(GlobalInOutVariable conGlobVar) throws InvalidConversionException {
 		this.conGlobVar = conGlobVar;
 		if (this.typeIsSet) {
-			this.type = Conversions.typeDecider(conGlobVar.getType(), this.type);
+			this.type = Conversions.typeDecider(conGlobVar.type, this.type);
 		}
 		else
 		{
-			this.type = conGlobVar.getType();
+			this.type = conGlobVar.type;
 			this.typeIsSet = true;
 		}
 	}
@@ -103,9 +103,9 @@ public class ReturnInformation {
 				}
 				// In this case they must have the same type otherwise the
 				// return value is impossible to typecheck.
-				else if (information.conGlobVar.getType() != information2.conGlobVar.getType()) {
-					throw new Exception("The two connected global variables: " + information.conGlobVar.getName()
-							+ " and " + information2.conGlobVar.getName() + " have different types");
+				else if (information.conGlobVar.type != information2.conGlobVar.type) {
+					throw new Exception("The two connected global variables: " + information.conGlobVar.name
+							+ " and " + information2.conGlobVar.name + " have different types");
 				}
 
 			} else {

+ 1 - 4
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/InOutRulesConditionSwitch.xtend

@@ -363,10 +363,7 @@ abstract class InOutRulesConditionSwitch extends SemanticAdaptationSwitch<Return
 				code = '''
 					this->«decl.name» = «doSwitchRes.code»;
 				'''
-				var globVar = new GlobalInOutVariable();
-				globVar.name = decl.name;
-				globVar.value = doSwitchRes.value;
-				globVar.type = doSwitchRes.type;
+				var globVar = new GlobalInOutVariable(decl.name, doSwitchRes.type);
 
 				gVars.put(decl.name, globVar);
 			} else {

+ 1 - 5
DSL_SemanticAdaptation/be.uantwerpen.ansymo.semanticadaptation.cg.cpp/src/be/uantwerpen/ansymo/semanticadaptation/cg/cpp/generation/ParamConditionSwitch.xtend

@@ -26,11 +26,7 @@ class ParamConditionSwitch extends GeneralConditionSwitch {
 
 	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;
+		var GlobalInOutVariable gVar = new GlobalInOutVariable(object.name, doSwitchRes.type);
 		this.gVars.put(gVar.name, gVar);		
 		val retInfo = new ReturnInformation();
 		retInfo.code =