Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 670bfb37 authored by Tomofumi Yuki's avatar Tomofumi Yuki
Browse files

moved naming of types for exploration to SolutionSpace instead of

internally in profiler
parent 712ee4a0
No related branches found
No related tags found
1 merge request!4Develop
......@@ -284,6 +284,10 @@ class SolutionSpace {
EcoreUtil.copy(this)
}
op String getUniqueTypeName(Symbol s) {
return "TYPE_" + s.getName() + "_" + exploredSymbols.indexOfKey(s)
}
op String toString() {
"Solution Space (" + exploredSymbols.size + "):\n"
+ getSymbols.join("\n", ["\tSymbol '" + SolutionSpaceUtils.printSymbol(it) + "' (" + it.class.simpleName + "):\n" + getTypeSpace(it)])
......
......@@ -262,6 +262,15 @@ public interface SolutionSpace extends EObject {
*/
SolutionSpace copy();
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @model unique="false" sUnique="false"
* annotation="http://www.eclipse.org/emf/2002/GenModel body='&lt;%java.lang.String%&gt; _name = s.getName();\n&lt;%java.lang.String%&gt; _plus = (\"TYPE_\" + _name);\n&lt;%java.lang.String%&gt; _plus_1 = (_plus + \"_\");\nint _indexOfKey = this.getExploredSymbols().indexOfKey(s);\nreturn (_plus_1 + &lt;%java.lang.Integer%&gt;.valueOf(_indexOfKey));'"
* @generated
*/
String getUniqueTypeName(Symbol s);
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
......
......@@ -410,6 +410,19 @@ public class SolutionSpaceImpl extends MinimalEObjectImpl.Container implements S
return EcoreUtil.<SolutionSpace>copy(this);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getUniqueTypeName(final Symbol s) {
String _name = s.getName();
String _plus = ("TYPE_" + _name);
String _plus_1 = (_plus + "_");
int _indexOfKey = this.getExploredSymbols().indexOfKey(s);
return (_plus_1 + Integer.valueOf(_indexOfKey));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
......
......@@ -841,6 +841,9 @@ public class TypeexplorationPackageImpl extends EPackageImpl implements Typeexpl
addEOperation(solutionSpaceEClass, this.getSolutionSpace(), "copy", 0, 1, !IS_UNIQUE, IS_ORDERED);
op = addEOperation(solutionSpaceEClass, theEcorePackage.getEString(), "getUniqueTypeName", 0, 1, !IS_UNIQUE, IS_ORDERED);
addEParameter(op, theCorePackage.getSymbol(), "s", 0, 1, !IS_UNIQUE, IS_ORDERED);
addEOperation(solutionSpaceEClass, theEcorePackage.getEString(), "toString", 0, 1, !IS_UNIQUE, IS_ORDERED);
// Initialize data types
......
......@@ -71,7 +71,7 @@ class InternalProfiler {
this.referenceSolution = UserFactory.solution(solutionSpace);
/** replace type of s by a alias */
solutionSpace.getSymbols().forEach(this::generalizeType);
solutionSpace.getSymbols().forEach(s->generalizeType(solutionSpace, s));
/**
* if multiple symbol have same generic type name, this mean that multiple symbols
......@@ -91,7 +91,7 @@ class InternalProfiler {
}
}
private void generalizeType(Symbol s) {
private void generalizeType(SolutionSpace sol, Symbol s) {
GecosUserTypeFactory.setScope(s.getContainingScope().getRoot());
TypeAnalyzer ta = new TypeAnalyzer(s.getType());
......@@ -114,7 +114,7 @@ class InternalProfiler {
pragma(lookupAliasType, CODEGEN_IGNORE_ANNOTATION);
} else {
/* create a macro generic Type */
genericTypeName = getGenericTypeName(s);
genericTypeName = getGenericTypeName(sol, s);
}
Type generic = ALIAS(VOID(), genericTypeName);
......@@ -135,10 +135,10 @@ class InternalProfiler {
}
int uid = 0;
private String getGenericTypeName(Symbol s) {
private String getGenericTypeName(SolutionSpace sol, Symbol s) {
String name = symbolGenericTypeNameMap.get(s);
if(name == null) {
name = "TYPE_" + s.getName() + "_" + (uid++);
name = sol.getUniqueTypeName(s);
setGenericTypeName(s, name);
}
return name;
......@@ -156,7 +156,7 @@ class InternalProfiler {
}
Map<String, String> typeDefMacros = solution.getSymbols().stream()
.collect(toMap( s -> getGenericTypeName(s),
.collect(toMap( s -> getGenericTypeName(solution.getSolutionSpace(), s),
s -> generator.generate(solution.getType(s))));
if(solIDName.equals(SimulationAccuracyEvaluator.REF_IMPLEM_NAME))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment