diff options
Diffstat (limited to 'Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDefinitionIndexer.xtend')
-rw-r--r-- | Solvers/VIATRA-Solver/hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra/src/hu/bme/mit/inf/dslreasoner/viatrasolver/logic2viatra/patterns/RelationDefinitionIndexer.xtend | 15 |
1 files changed, 10 insertions, 5 deletions
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 9723373f..0ae28b66 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 | |||
@@ -5,6 +5,7 @@ import hu.bme.mit.inf.dslreasoner.logic.model.logicproblem.LogicProblem | |||
5 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.TransfomedViatraQuery | 5 | import hu.bme.mit.inf.dslreasoner.viatra2logic.viatra2logicannotations.TransfomedViatraQuery |
6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality | 6 | import hu.bme.mit.inf.dslreasoner.viatrasolver.logic2viatra.Modality |
7 | import java.util.Map | 7 | import java.util.Map |
8 | import org.eclipse.emf.common.util.Enumerator | ||
8 | import org.eclipse.emf.ecore.EAttribute | 9 | import org.eclipse.emf.ecore.EAttribute |
9 | import org.eclipse.emf.ecore.EEnumLiteral | 10 | import org.eclipse.emf.ecore.EEnumLiteral |
10 | import org.eclipse.emf.ecore.EReference | 11 | import org.eclipse.emf.ecore.EReference |
@@ -17,6 +18,7 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality | |||
17 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter | 18 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter |
18 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality | 19 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality |
19 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall | 20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall |
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint | ||
20 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.BinaryTransitiveClosure | 22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.BinaryTransitiveClosure |
21 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue | 23 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue |
22 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall | 24 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall |
@@ -24,7 +26,6 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeCo | |||
24 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery | 26 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery |
25 | 27 | ||
26 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 28 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
27 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint | ||
28 | 29 | ||
29 | class RelationDefinitionIndexer { | 30 | class RelationDefinitionIndexer { |
30 | val PatternGenerator base; | 31 | val PatternGenerator base; |
@@ -33,7 +34,7 @@ class RelationDefinitionIndexer { | |||
33 | this.base = base | 34 | this.base = base |
34 | } | 35 | } |
35 | 36 | ||
36 | public def generateRelationDefinitions( | 37 | def generateRelationDefinitions( |
37 | LogicProblem problem, | 38 | LogicProblem problem, |
38 | Iterable<RelationDefinition> relations, | 39 | Iterable<RelationDefinition> relations, |
39 | Map<String,PQuery> fqn2PQuery) { | 40 | Map<String,PQuery> fqn2PQuery) { |
@@ -71,7 +72,7 @@ class RelationDefinitionIndexer { | |||
71 | ] | 72 | ] |
72 | } | 73 | } |
73 | 74 | ||
74 | private def relationDefinitionName(RelationDefinition relation, Modality modality) | 75 | def String relationDefinitionName(RelationDefinition relation, Modality modality) |
75 | '''«modality.name.toLowerCase»InRelation_«base.canonizeName(relation.name)»''' | 76 | '''«modality.name.toLowerCase»InRelation_«base.canonizeName(relation.name)»''' |
76 | 77 | ||
77 | private def canonizeName(PVariable v) { | 78 | private def canonizeName(PVariable v) { |
@@ -109,7 +110,7 @@ class RelationDefinitionIndexer { | |||
109 | else return Modality::MUST | 110 | else return Modality::MUST |
110 | } | 111 | } |
111 | 112 | ||
112 | def public referPattern(PQuery p, String[] variables, Modality modality, boolean positive, boolean transitive) ''' | 113 | def referPattern(PQuery p, String[] variables, Modality modality, boolean positive, boolean transitive) ''' |
113 | «IF !positive»neg «ENDIF»find «IF transitive»twoParam_«ENDIF»«modality.name.toLowerCase»InRelation_pattern_«p.fullyQualifiedName.replace('.','_')»«IF transitive»+«ENDIF»(«IF !transitive»problem,interpretation,«ENDIF»«variables.join(',')»); | 114 | «IF !positive»neg «ENDIF»find «IF transitive»twoParam_«ENDIF»«modality.name.toLowerCase»InRelation_pattern_«p.fullyQualifiedName.replace('.','_')»«IF transitive»+«ENDIF»(«IF !transitive»problem,interpretation,«ENDIF»«variables.join(',')»); |
114 | ''' | 115 | ''' |
115 | 116 | ||
@@ -227,7 +228,11 @@ class RelationDefinitionIndexer { | |||
227 | var String additionalDefinition; | 228 | var String additionalDefinition; |
228 | if(target instanceof EEnumLiteral) { | 229 | if(target instanceof EEnumLiteral) { |
229 | targetString = '''const_«target.name»_«target.EEnum.name»''' | 230 | targetString = '''const_«target.name»_«target.EEnum.name»''' |
230 | additionalDefinition = '''DefinedElement.name(«targetString»,"«target.name» «target.EEnum.name»"); //LogicProblem.elements(problem,«targetString»);''' | 231 | additionalDefinition = '''DefinedElement.name(«targetString»,"«target.name» literal «target.EEnum.name»"); //LogicProblem.elements(problem,«targetString»);''' |
232 | } else if(target instanceof Enumerator) { | ||
233 | // XXX We should get the corresponding EEnum name instead of the java class name. | ||
234 | targetString = '''const_«target.name»_«target.class.simpleName»''' | ||
235 | additionalDefinition = '''DefinedElement.name(«targetString»,"«target.name» literal «target.class.simpleName»"); //LogicProblem.elements(problem,«targetString»);''' | ||
231 | } else if(target instanceof Integer) { | 236 | } else if(target instanceof Integer) { |
232 | targetString = '''const_«target»_Integer''' | 237 | targetString = '''const_«target»_Integer''' |
233 | additionalDefinition = '''IntegerElement.value(«targetString»,«target»);''' | 238 | additionalDefinition = '''IntegerElement.value(«targetString»,«target»);''' |