Переглянути джерело

Made working again with the indirection for RAMification inbetween

Yentl Van Tendeloo 8 роки тому
батько
коміт
3ad9351d49

BIN
bootstrap/bootstrap.m.gz


+ 8 - 0
bootstrap/ftg.alc

@@ -0,0 +1,8 @@
+include "primitives.alh"
+
+Element function create_ftg(root : Element):
+	Element result
+
+	result = create_node()
+
+	return result!

+ 30 - 0
bootstrap/ramify.alc

@@ -3,6 +3,36 @@ include "object_operations.alh"
 include "modelling.alh"
 include "metamodels.alh"
 
+Element function create_transformation_language(root : Element, source : String, target : String):
+	Element ramified
+	Element fused
+	Element tagged_model
+	Element model_list
+
+	if (source == target):
+		// in-place transformation, so no need to alter meta-model any further
+		ramified = ramify(root[source])
+	else:
+		// out-place transformation, so modify meta-model a bit and add further information
+		model_list = create_node()
+		tagged_model = create_node()
+		list_append(tagged_model, source)
+		list_append(tagged_model, root[source])
+		list_append(model_list, tagged_model)
+		tagged_model = create_node()
+		list_append(tagged_model, target)
+		list_append(tagged_model, root[target])
+		list_append(model_list, tagged_model)
+
+		fused = model_fuse(model_list)
+		ramified = ramify(fused)
+
+	// Augment with information about the source and target
+	dict_add(ramified, "source", source)
+	dict_add(ramified, "target", target)
+
+	return ramified!
+
 Element function ramify(model : Element):
 	// Create new model structure
 	Element new_model

+ 19 - 7
integration/code/pn_interface.alc

@@ -321,7 +321,8 @@ Element function main():
 			output("  delete -- Delete a previously made model")
 			output("  list   -- Show a list of all stored models")
 			output("  upload -- Upload a model using the model constructor commands")
-			output("  ramify -- RAMify a previously made model")
+			output("  ramify -- RAMify existing metamodels to generate a language for transformations")
+			output("  transform -- Execute a previously defined model transformation")
 			output("  help   -- Show a list of possible commands")
 		elif (command == "new"):
 			output("Metamodel to instantiate?")
@@ -385,15 +386,26 @@ Element function main():
 			output("Back in model manager!")
 		elif (command == "ramify"):
 			Element result
-			output("Which model do you want to RAMify?")
+			String old_name
+			output("Name of the new RAMified metamodel")
 			name = input()
 			if (dict_in(root, name)):
-				my_model = root[name]
-				result = ramify(my_model)
-				dict_add(root, name + "_SCHEDULE", result)
-				output("success")
+				output("Already exists; aborting")
 			else:
-				output("Model not found; aborting")
+				output("Source language?")
+				String source
+				String target
+				source = input()
+				if (dict_in(root, source)):
+					output("Target language?")
+					target = input()
+					if (dict_in(root, target)):
+						result = create_transformation_language(root, source, target)
+						dict_add(root, name, result)
+					else:
+						output("Unknown target language; aborting")
+				else:
+					output("Unknown source language; aborting")
 		elif (command == "transform"):
 			Element result
 			String schedule

+ 1 - 1
integration/test_pn_interface.py

@@ -1150,7 +1150,7 @@ Void function action(host_model : Element, name : String, mapping : Element):
         self.assertTrue(run_file(all_files,
             get_model_constructor(PN_runtime) + \
                 get_model_constructor(PN_model) + [
-                "ramify", "PetriNets_Runtime",
+                "ramify", "PetriNets_Runtime_SCHEDULE", "PetriNets_Runtime", "PetriNets_Runtime",
                 ] + get_model_constructor(schedule_model) + [
                 "transform", "pn", "pn_simulate",
                 "load", "pn",

+ 1 - 0
interface/HUTN/includes/modelling.alh

@@ -22,3 +22,4 @@ Element function read_attribute(model : Element, elem : String, name : String)
 Void function model_delete_element(model : Element, name : String)
 Void function add_constraint(model : Element, name : String, constraint : Action)
 String function model_define_attribute(model : Element, elem : String, name : String, type : String)
+Element function model_fuse(models : Element)

+ 1 - 0
interface/HUTN/includes/ramify.alh

@@ -1 +1,2 @@
+Element function create_transformation_language(root : Element, source : String, target : String)
 Element function ramify(model : Element)