diff options
Diffstat (limited to 'Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu')
2 files changed, 30 insertions, 1 deletions
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Constraint2Logic.xtend b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Constraint2Logic.xtend index 3d2c46a5..3e8b3366 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Constraint2Logic.xtend +++ b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Constraint2Logic.xtend | |||
@@ -29,6 +29,7 @@ import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.Positi | |||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint | 29 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint |
30 | 30 | ||
31 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* | 31 | import static extension hu.bme.mit.inf.dslreasoner.util.CollectionsUtil.* |
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint | ||
32 | 33 | ||
33 | class Constraint2Logic { | 34 | class Constraint2Logic { |
34 | val extension LogicProblemBuilder builder = new LogicProblemBuilder | 35 | val extension LogicProblemBuilder builder = new LogicProblemBuilder |
@@ -209,6 +210,7 @@ class Constraint2Logic { | |||
209 | return transformPathConstraint(type,src,trg,ecore2LogicTrace,variable2Variable,viatra2LogicTrace) | 210 | return transformPathConstraint(type,src,trg,ecore2LogicTrace,variable2Variable,viatra2LogicTrace) |
210 | } else throw new IllegalArgumentException('''unknown tuple: «tuple»''') | 211 | } else throw new IllegalArgumentException('''unknown tuple: «tuple»''') |
211 | } | 212 | } |
213 | |||
212 | def Term transformTypeConstraint( | 214 | def Term transformTypeConstraint( |
213 | EClass type, | 215 | EClass type, |
214 | PVariable variable, | 216 | PVariable variable, |
@@ -242,6 +244,31 @@ class Constraint2Logic { | |||
242 | } | 244 | } |
243 | } | 245 | } |
244 | 246 | ||
247 | def dispatch Term transformConstraint(TypeFilterConstraint constraint, | ||
248 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace, | ||
249 | Viatra2LogicTrace viatra2LogicTrace, | ||
250 | Map<PVariable, Variable> variable2Variable, | ||
251 | Viatra2LogicConfiguration config) | ||
252 | { | ||
253 | val tuple = constraint.variablesTuple | ||
254 | if(tuple.size == 1) { | ||
255 | val typeConstraint = constraint.equivalentJudgement.inputKey | ||
256 | if(typeConstraint instanceof EClassTransitiveInstancesKey) { | ||
257 | val type = typeConstraint.emfKey | ||
258 | val variable = tuple.get(0) as PVariable | ||
259 | return transformTypeConstraint(type,variable,ecore2LogicTrace,variable2Variable,viatra2LogicTrace) | ||
260 | } else if(typeConstraint instanceof EDataTypeInSlotsKey) { | ||
261 | // If the type is a primitive type or EEnum, then instanceof is an unnecessary constraint | ||
262 | return null | ||
263 | } | ||
264 | } else if(tuple.size == 2) { | ||
265 | val type = (constraint.equivalentJudgement.inputKey as EStructuralFeatureInstancesKey).emfKey | ||
266 | val src = tuple.get(0) as PVariable | ||
267 | val trg = tuple.get(1) as PVariable | ||
268 | return transformPathConstraint(type,src,trg,ecore2LogicTrace,variable2Variable,viatra2LogicTrace) | ||
269 | } else throw new IllegalArgumentException('''unknown tuple: «tuple»''') | ||
270 | } | ||
271 | |||
245 | def dispatch Term transformConstraint(PConstraint constraint, | 272 | def dispatch Term transformConstraint(PConstraint constraint, |
246 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace, | 273 | TracedOutput<LogicProblem, Ecore2Logic_Trace> ecore2LogicTrace, |
247 | Viatra2LogicTrace viatra2LogicTrace, | 274 | Viatra2LogicTrace viatra2LogicTrace, |
diff --git a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Viatra2Logic.xtend b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Viatra2Logic.xtend index ce902353..0821db47 100644 --- a/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Viatra2Logic.xtend +++ b/Framework/hu.bme.mit.inf.dslreasoner.viatra2logic/src/hu/bme/mit/inf/dslreasoner/viatra2logic/Viatra2Logic.xtend | |||
@@ -151,7 +151,7 @@ class Viatra2Logic { | |||
151 | val parameterName = '''parameter «vParam.name»''' | 151 | val parameterName = '''parameter «vParam.name»''' |
152 | val parameterType = getType(vParam,types,ecore2LogicTrace) | 152 | val parameterType = getType(vParam,types,ecore2LogicTrace) |
153 | if(parameterType === null) { | 153 | if(parameterType === null) { |
154 | throw new AssertionError('''null type for parameter «vParam.name»''') | 154 | throw new AssertionError('''null type for parameter «vParam.name» in pattern «pquery.fullyQualifiedName»''') |
155 | } | 155 | } |
156 | val lParam = createVar(parameterName,parameterType) | 156 | val lParam = createVar(parameterName,parameterType) |
157 | viatra2LogicTrace.parameter2Variable.put(pquery->vParam,lParam) | 157 | viatra2LogicTrace.parameter2Variable.put(pquery->vParam,lParam) |
@@ -450,6 +450,8 @@ class Viatra2Logic { | |||
450 | return LogicReal | 450 | return LogicReal |
451 | } else if(c == Boolean) { | 451 | } else if(c == Boolean) { |
452 | return LogicBool | 452 | return LogicBool |
453 | } else if(c == String) { | ||
454 | return LogicString | ||
453 | } else if(c.superclass == java.lang.Enum){ | 455 | } else if(c.superclass == java.lang.Enum){ |
454 | val enums = ecore2Logic.allEnumsInScope(ecore2LogicTrace.trace) | 456 | val enums = ecore2Logic.allEnumsInScope(ecore2LogicTrace.trace) |
455 | for(enum : enums) { | 457 | for(enum : enums) { |