|
@@ -72,23 +72,32 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
|
|
|
|
|
|
typename = read_type(schedule_model, current_element)
|
|
|
original_typename = string_substr(typename, 4, string_len(typename))
|
|
|
+
|
|
|
+ log("Getting possible bindings for " + current_element)
|
|
|
+ log(" type: " + typename)
|
|
|
|
|
|
if (is_edge(schedule_model["model"][current_element])):
|
|
|
+ log(" is_edge")
|
|
|
// Is an edge, so check for already bound source/target
|
|
|
src_label = read_attribute(schedule_model, reverseKeyLookup(schedule_model["model"], read_edge_src(schedule_model["model"][current_element])), "label")
|
|
|
dst_label = read_attribute(schedule_model, reverseKeyLookup(schedule_model["model"], read_edge_dst(schedule_model["model"][current_element])), "label")
|
|
|
|
|
|
if (bool_and(set_in(dict_keys(map), src_label), set_in(dict_keys(map), dst_label))):
|
|
|
// Source and destination are bound
|
|
|
+ log(" SD bound")
|
|
|
options = allOutgoingAssociationInstances(host_model, map[src_label], original_typename)
|
|
|
+ log(" Outgoing associations instances: " + set_to_string(options))
|
|
|
+ log(" Incoming associations instances: " + set_to_string(allIncomingAssociationInstances(host_model, map[dst_label], original_typename)))
|
|
|
options = set_overlap(options, allIncomingAssociationInstances(host_model, map[dst_label], original_typename))
|
|
|
|
|
|
elif (set_in(dict_keys(map), src_label)):
|
|
|
// Source is bound
|
|
|
+ log(" S bound")
|
|
|
options = allOutgoingAssociationInstances(host_model, map[src_label], original_typename)
|
|
|
|
|
|
elif (set_in(dict_keys(map), dst_label)):
|
|
|
// Destination is bound
|
|
|
+ log(" D bound")
|
|
|
options = allIncomingAssociationInstances(host_model, map[dst_label], original_typename)
|
|
|
|
|
|
else:
|
|
@@ -97,37 +106,44 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
|
|
|
//TODO should actually return all
|
|
|
return create_node()!
|
|
|
else:
|
|
|
+ log(" is_node")
|
|
|
// Is a node, so find whether or not there are some connections that are already resolved
|
|
|
Element ic
|
|
|
Element oc
|
|
|
String poll
|
|
|
|
|
|
- ic = allIncomingAssociationInstances(schedule_model, current_element, "Pre_Element")
|
|
|
- oc = allOutgoingAssociationInstances(schedule_model, current_element, "Pre_Element")
|
|
|
+ ic = allIncomingAssociationInstances(schedule_model, current_element, "PreElement")
|
|
|
+ oc = allOutgoingAssociationInstances(schedule_model, current_element, "PreElement")
|
|
|
|
|
|
while (bool_and(read_nr_out(ic) > 0, read_nr_out(options) == 0)):
|
|
|
poll = set_pop(ic)
|
|
|
+ log(" poll I " + poll)
|
|
|
if (dict_in(map, read_attribute(schedule_model, poll, "label"))):
|
|
|
// This incoming link is already defined, so we just have one option: the destination of the link we matched
|
|
|
set_add(options, readAssociationDestination(host_model, map[read_attribute(schedule_model, poll, "label")]))
|
|
|
|
|
|
while (bool_and(read_nr_out(oc) > 0, read_nr_out(options) == 0)):
|
|
|
poll = set_pop(oc)
|
|
|
+ log(" poll O " + poll)
|
|
|
if (dict_in(map, read_attribute(schedule_model, poll, "label"))):
|
|
|
// This incoming link is already defined, so we just have one option: the destination of the link we matched
|
|
|
set_add(options, readAssociationSource(host_model, map[read_attribute(schedule_model, poll, "label")]))
|
|
|
|
|
|
if (read_nr_out(options) == 0):
|
|
|
// Is a node and no connections, so we just pick all options
|
|
|
+ log(" empty")
|
|
|
options = allInstances(host_model, original_typename)
|
|
|
elif (read_nr_out(options) > 1):
|
|
|
// Multiple "only" options, which will not work out: no options!
|
|
|
+ log(" multi!")
|
|
|
return create_node()!
|
|
|
|
|
|
// Filter options further
|
|
|
Element filtered_options
|
|
|
String option
|
|
|
|
|
|
+ log(" Got options: " + set_to_string(options))
|
|
|
+
|
|
|
filtered_options = create_node()
|
|
|
while (read_nr_out(options) > 0):
|
|
|
option = set_pop(options)
|
|
@@ -150,6 +166,9 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
|
|
|
func = get_func_AL_model(constraint_function)
|
|
|
result = func(host_model, option)
|
|
|
|
|
|
+ log("Execute constraint on " + dict_to_string(option))
|
|
|
+ log("Result: " + cast_e2s(result))
|
|
|
+
|
|
|
if (result):
|
|
|
set_add(filtered_options, option)
|
|
|
|
|
@@ -229,14 +248,22 @@ Element function match(host_model : Element, schedule_model : Element, LHS : Str
|
|
|
mappings = new_mappings
|
|
|
|
|
|
// Finished, so try the global constraint
|
|
|
- Element constraint
|
|
|
+ String constraint
|
|
|
+ Element func
|
|
|
+ Boolean result
|
|
|
|
|
|
new_mappings = create_node()
|
|
|
constraint = read_attribute(schedule_model, LHS, "constraint")
|
|
|
if (element_neq(constraint, read_root())):
|
|
|
while (read_nr_out(mappings) > 0):
|
|
|
map = set_pop(mappings)
|
|
|
- if (constraint(host_model, map)):
|
|
|
+ func = get_func_AL_model(constraint)
|
|
|
+ result = func(host_model, map)
|
|
|
+
|
|
|
+ log("Execute global constraint on " + dict_to_string(map))
|
|
|
+ log("Result: " + cast_e2s(result))
|
|
|
+
|
|
|
+ if (result):
|
|
|
set_add(new_mappings, map)
|
|
|
mappings = new_mappings
|
|
|
|
|
@@ -382,6 +409,7 @@ Boolean function transform_composite(host_model : Element, schedule_model : Elem
|
|
|
while (is_nominal_instance(schedule_model, current, "Rule")):
|
|
|
// Still a rule that we must execute
|
|
|
typename = read_type(schedule_model, current)
|
|
|
+ log("RULE: " + current)
|
|
|
if (typename == "Atomic"):
|
|
|
result = transform_atomic(host_model, schedule_model, current)
|
|
|
elif (typename == "Query"):
|
|
@@ -435,6 +463,7 @@ Boolean function transform_forall(host_model : Element, schedule_model : Element
|
|
|
while (read_nr_out(mappings) > 0):
|
|
|
mapping = set_pop(mappings)
|
|
|
// TODO check if there are actually no deletions happening in the meantime of other matched elements...
|
|
|
+ log("Execute RHS for binding: " + dict_to_string(mapping))
|
|
|
RHS = set_pop(allAssociationDestinations(schedule_model, current, "RHSLink"))
|
|
|
rewrite(host_model, schedule_model, RHS, mapping)
|
|
|
|