diff options
author | 2018-03-24 21:44:49 -0400 | |
---|---|---|
committer | 2018-03-24 21:44:49 -0400 | |
commit | f42954a45bea9f3e40090447804f33f12c080640 (patch) | |
tree | 1c57d4ca595bf7825460c6aa080f93ea04d5689c /Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf | |
parent | Factory for string literals. (diff) | |
download | VIATRA-Generator-f42954a45bea9f3e40090447804f33f12c080640.tar.gz VIATRA-Generator-f42954a45bea9f3e40090447804f33f12c080640.tar.zst VIATRA-Generator-f42954a45bea9f3e40090447804f33f12c080640.zip |
upgraded attribute support for the graph solver
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf')
3 files changed, 24 insertions, 10 deletions
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend index 7caa3e19..34094cac 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/PatternGenerator.xtend | |||
@@ -89,7 +89,8 @@ class PatternGenerator { | |||
89 | String targetVariable, | 89 | String targetVariable, |
90 | Modality modality) | 90 | Modality modality) |
91 | { | 91 | { |
92 | throw new UnsupportedOperationException | 92 | '''find «modality.name.toLowerCase»InRelation«canonizeName('''«attribute.name» attribute «attribute.EContainingClass.name»''') |
93 | »(problem,interpretation,«sourceVariable»,«targetVariable»);''' | ||
93 | } | 94 | } |
94 | 95 | ||
95 | public def canonizeName(String name) { | 96 | public def canonizeName(String name) { |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDefinitionIndexer.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDefinitionIndexer.xtend index 794e706b..39b6fbc0 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDefinitionIndexer.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDefinitionIndexer.xtend | |||
@@ -91,7 +91,8 @@ class RelationDefinitionIndexer { | |||
91 | }«ENDFOR» | 91 | }«ENDFOR» |
92 | ''' | 92 | ''' |
93 | } catch(UnsupportedOperationException e) { | 93 | } catch(UnsupportedOperationException e) { |
94 | throw new UnsupportedOperationException('''Can not transform pattern "«p.fullyQualifiedName»"!''',e) | 94 | e.printStackTrace |
95 | throw new UnsupportedOperationException('''Can not transform pattern "«p.fullyQualifiedName»"! Reason: «e.message»''',e) | ||
95 | } | 96 | } |
96 | } | 97 | } |
97 | private def transformPatternWithTwoParameters(RelationDefinition relation, PQuery p, Modality modality) { | 98 | private def transformPatternWithTwoParameters(RelationDefinition relation, PQuery p, Modality modality) { |
@@ -137,7 +138,7 @@ class RelationDefinitionIndexer { | |||
137 | modality.toMustMay) | 138 | modality.toMustMay) |
138 | } else throw new UnsupportedOperationException('''unknown key: «key.class»''') | 139 | } else throw new UnsupportedOperationException('''unknown key: «key.class»''') |
139 | } else { | 140 | } else { |
140 | throw new UnsupportedOperationException() | 141 | throw new UnsupportedOperationException('''Unsupported touple size: «touple.size»''') |
141 | } | 142 | } |
142 | } | 143 | } |
143 | 144 | ||
@@ -196,10 +197,22 @@ class RelationDefinitionIndexer { | |||
196 | var String additionalDefinition; | 197 | var String additionalDefinition; |
197 | if(target instanceof EEnumLiteral) { | 198 | if(target instanceof EEnumLiteral) { |
198 | targetString = '''const_«target.name»_«target.EEnum.name»''' | 199 | targetString = '''const_«target.name»_«target.EEnum.name»''' |
199 | additionalDefinition = '''DefinedElement.name(«targetString»,"«target.name» «target.EEnum.name»"); LogicProblem.elements(problem,«targetString»);''' | 200 | additionalDefinition = '''DefinedElement.name(«targetString»,"«target.name» «target.EEnum.name»"); //LogicProblem.elements(problem,«targetString»);''' |
200 | } else if(target instanceof Integer) { | 201 | } else if(target instanceof Integer) { |
201 | targetString = target.toString | 202 | targetString = '''const_«target»_Integer''' |
202 | additionalDefinition = '''''' | 203 | additionalDefinition = '''IntegerElement.value(«targetString»,«target»);''' |
204 | } else if(target instanceof Boolean) { | ||
205 | targetString = '''const_«target»_Boolean''' | ||
206 | additionalDefinition = '''BooleanElement.value(«targetString»,«target»);''' | ||
207 | } else if(target instanceof String) { | ||
208 | targetString = '''const_«target»_String''' | ||
209 | additionalDefinition = '''StringElement.value(«targetString»,"«target»");''' | ||
210 | } else if(target instanceof Double) { | ||
211 | targetString = '''const_«target»_Number''' | ||
212 | additionalDefinition = '''RealElement.value(«targetString»,"«target»");''' | ||
213 | } else if(target instanceof Float) { | ||
214 | targetString = '''const_«target»_Number''' | ||
215 | additionalDefinition = '''RealElement.value(«targetString»,"«target»");''' | ||
203 | } else { | 216 | } else { |
204 | throw new UnsupportedOperationException('''Unknown constant type: «target.class»''') | 217 | throw new UnsupportedOperationException('''Unknown constant type: «target.class»''') |
205 | } | 218 | } |
diff --git a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeIndexer.xtend b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeIndexer.xtend index 9afec0de..630fad51 100644 --- a/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeIndexer.xtend +++ b/Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/TypeIndexer.xtend | |||
@@ -23,16 +23,16 @@ abstract class TypeIndexer { | |||
23 | reference.referred.referInstanceOf(modality,variableName) | 23 | reference.referred.referInstanceOf(modality,variableName) |
24 | } | 24 | } |
25 | public def dispatch CharSequence referInstanceOfByReference(BoolTypeReference reference, Modality modality, String variableName) { | 25 | public def dispatch CharSequence referInstanceOfByReference(BoolTypeReference reference, Modality modality, String variableName) { |
26 | '''find instaneofBoolean(problem, interpretation, «variableName»);''' | 26 | '''BooleanElement(«variableName»);''' |
27 | } | 27 | } |
28 | public def dispatch CharSequence referInstanceOfByReference(IntTypeReference reference, Modality modality, String variableName) { | 28 | public def dispatch CharSequence referInstanceOfByReference(IntTypeReference reference, Modality modality, String variableName) { |
29 | '''find pattern instaneofInteger(problem, interpretation, «variableName»);''' | 29 | '''IntegerElement(«variableName»);''' |
30 | } | 30 | } |
31 | public def dispatch CharSequence referInstanceOfByReference(RealTypeReference reference, Modality modality, String variableName) { | 31 | public def dispatch CharSequence referInstanceOfByReference(RealTypeReference reference, Modality modality, String variableName) { |
32 | '''find pattern instaneofReal(problem, interpretation, «variableName»);''' | 32 | '''RealElement(«variableName»);''' |
33 | } | 33 | } |
34 | public def dispatch CharSequence referInstanceOfByReference(StringTypeReference reference, Modality modality, String variableName) { | 34 | public def dispatch CharSequence referInstanceOfByReference(StringTypeReference reference, Modality modality, String variableName) { |
35 | '''find pattern instaneofString(problem, interpretation, «variableName»);''' | 35 | '''StringElement(«variableName»);''' |
36 | } | 36 | } |
37 | 37 | ||
38 | } \ No newline at end of file | 38 | } \ No newline at end of file |