瀏覽代碼

Fixes for removed add_constraint

Yentl Van Tendeloo 8 年之前
父節點
當前提交
8bd213402d

二進制
bootstrap/bootstrap.m.gz


+ 38 - 36
core/mini_modify.alc

@@ -27,23 +27,24 @@ Element function modify(model : Element, write : Boolean):
 			output("Allowed operations:")
 			if (write):
 				output(" == READ/WRITE ==")
-				output("  instantiate -- Create a new model element")
-				output("  delete      -- Delete an existing element")
-				output("  attr_add    -- Add an attribute to an element")
-				output("  attr_del    -- Delete an attribute of an element")
-				output("  attr_modify -- Modify an attribute of an element")
-				output("  constrain   -- Add a constraint function to the model")
-				output("  rename      -- Rename an existing element")
-				output("  modify      -- Modify the attributes of an element")
-				output("  retype      -- Change the type of an element")
+				output("  instantiate   -- Create a new model element")
+				output("  delete        -- Delete an existing element")
+				output("  attr_add      -- Add an attribute to an element")
+				output("  attr_add_code -- Add a coded attribute to an element")
+				output("  attr_del      -- Delete an attribute of an element")
+				output("  attr_modify   -- Modify an attribute of an element")
+				output("  constrain     -- Add a constraint function to the model")
+				output("  rename        -- Rename an existing element")
+				output("  modify        -- Modify the attributes of an element")
+				output("  retype        -- Change the type of an element")
 			else:
 				output(" == READ-ONLY ==")
-			output("  list        -- Prints the list of elements in the model")
-			output("  list_full   -- Prints the list of all elements in the model")
-			output("  types       -- Prints the list of elements that can be instantiated")
-			output("  read        -- Prints the current state of a model element")
-			output("  verify      -- Check whether the model conforms to the metamodel")
-			output("  exit        -- Leave the modification interface")
+			output("  list          -- Prints the list of elements in the model")
+			output("  list_full     -- Prints the list of all elements in the model")
+			output("  types         -- Prints the list of elements that can be instantiated")
+			output("  read          -- Prints the current state of a model element")
+			output("  verify        -- Check whether the model conforms to the metamodel")
+			output("  exit          -- Leave the modification interface")
 		elif (cmd == "exit"):
 			return model!
 		elif (cmd == "instantiate"):
@@ -82,27 +83,6 @@ Element function modify(model : Element, write : Boolean):
 			else:
 				output("Permission denied")
 
-		elif (cmd == "constrain"):
-			if (write):
-				output("Element to constrain (empty for global)?")
-				String model_name
-				model_name = input()
-
-				if (model_name == ""):
-					// Global constraint
-					output("Give input to function constructors for GLOBAL constraint!")
-					set_model_constraints(model, construct_function())
-				elif (dict_in(model["model"], model_name)):
-					// Local constraint for this model
-					output("Give input to function constructors for LOCAL constraint!")
-					add_constraint(model, model_name, construct_function())
-					output("Added constraint to model!")
-				else:
-					// Local constraint, but model not found
-					output("Unknown model; aborting")
-			else:
-				output("Permission denied")
-
 		elif (cmd == "attr_modify"):
 			if (write):
 				String model_name
@@ -148,6 +128,28 @@ Element function modify(model : Element, write : Boolean):
 			else:
 				output("Permission denied")
 
+		elif (cmd == "attr_add_code"):
+			if (write):
+				String model_name
+				output("Which model do you want to assign a coded attribute to?")
+				model_name = input()
+				if (dict_in(model["model"], model_name)):
+					Element attrs
+					attrs = getAttributeList(model, model_name)
+					String attr_name
+					output("Which attribute do you wish to assign?")
+					attr_name = input()
+					if (set_in(dict_keys(attrs), attr_name)):
+						output("Waiting for code constructors...")
+						instantiate_attribute_code(model, model_name, attr_name, input())
+						output("Added attribute!")
+					else:
+						output("No such attribute!")
+				else:
+					output("No such model!")
+			else:
+				output("Permission denied")
+
 		elif (cmd == "attr_del"):
 			if (write):
 				String model_name

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

@@ -19,6 +19,5 @@ Void function unset_attribute(model : Element, elem : String, name : String)
 Void function construct_model()
 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, optional : Boolean, type : String)
 Element function construct_model_raw(metamodel : Element)

File diff suppressed because it is too large
+ 1 - 1
interface/HUTN/test/modelling_language/expected/petrinets_constraints