modelling.alc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. include "primitives.alh"
  2. include "io.alh"
  3. include "object_operations.alh"
  4. include "constructors.alh"
  5. include "metamodels.alh"
  6. include "library.alh"
  7. Element global_models = ?
  8. String function instantiated_name(element : Element, original : String):
  9. if (original == ""):
  10. return "__" + cast_id2s(element)!
  11. else:
  12. return original!
  13. Element function instantiate_bottom():
  14. // Just create a new node that serves as the basis for everything
  15. // We don't know anything about the model yet, so just create an empty one
  16. Element new_model
  17. // The actual root node of the model
  18. new_model = create_node()
  19. // Add an empty model and empty type mapping
  20. dict_add_fast(new_model, "model", create_node())
  21. dict_add_fast(new_model, "type_mapping", create_node())
  22. // Return the created model
  23. return new_model!
  24. String function model_add_node(model : Element, name : String):
  25. // Adds a new node to the specified model with the desired name
  26. // This is a bottom operation, as it doesn't take any type
  27. Element new_node
  28. String actual_name
  29. new_node = create_node()
  30. actual_name = instantiated_name(new_node, name)
  31. dict_add_fast(model["model"], actual_name, new_node)
  32. return actual_name!
  33. String function model_add_value(model : Element, name : String, value : Element):
  34. // Similar to model_add_node, but add a value as well
  35. String actual_name
  36. actual_name = instantiated_name(value, name)
  37. dict_add_fast(model["model"], actual_name, value)
  38. return actual_name!
  39. String function model_add_edge(model : Element, name : String, source : String, destination : String):
  40. // Add an edge between the source and destination nodes
  41. // Nodes are specified using their string representation previously defined
  42. Element new_edge
  43. String actual_name
  44. if (bool_not(dict_in(model["model"], source))):
  45. log("In link " + name)
  46. log("ERROR: source of link unknown: " + source)
  47. log("Destination: " + destination)
  48. return ""!
  49. if (bool_not(dict_in(model["model"], destination))):
  50. log("In link " + name)
  51. log("ERROR: destination of link unknown: " + destination)
  52. log("Source: " + source)
  53. return ""!
  54. new_edge = create_edge(model["model"][source], model["model"][destination])
  55. actual_name = instantiated_name(new_edge, name)
  56. dict_add_fast(model["model"], actual_name, new_edge)
  57. return actual_name!
  58. Void function retype_model(model : Element, metamodel : Element):
  59. // Remove the type mapping and add a new one for the specified metamodel
  60. dict_delete(model, "type_mapping")
  61. dict_add_fast(model, "type_mapping", create_node())
  62. dict_add_fast(model, "metamodel", metamodel)
  63. return!
  64. Void function retype(model : Element, element : String, type : String):
  65. // Retype a model, deleting any previous type the element had
  66. // The type string is evaluated in the metamodel previously specified
  67. if (dict_in(model["type_mapping"], element)):
  68. dict_delete(model["type_mapping"], element)
  69. dict_add_fast(model["type_mapping"], element, type)
  70. return!
  71. Element function instantiate_model(metamodel : Element):
  72. // Instantiate a model
  73. // Basically create an untyped model and retype it
  74. Element model
  75. model = instantiate_bottom()
  76. retype_model(model, metamodel)
  77. return model!
  78. String function instantiate_node(model : Element, type_name : String, instance_name : String):
  79. String actual_name
  80. if (bool_not(dict_in(model["metamodel"]["model"], type_name))):
  81. log("ERROR: (instantiate_node) no such type in metamodel: " + type_name)
  82. log(" for " + instance_name)
  83. return ""!
  84. Element value
  85. value = create_node()
  86. actual_name = instantiated_name(value, instance_name)
  87. dict_add_fast(model["model"], actual_name, value)
  88. dict_add_fast(model["type_mapping"], actual_name, type_name)
  89. return actual_name!
  90. String function instantiate_value(model : Element, type_name : String, instance_name : String, value : Element):
  91. String actual_name
  92. if (bool_not(dict_in(model["metamodel"]["model"], type_name))):
  93. log("ERROR: (instantiate_value) no such type in metamodel: " + type_name)
  94. log(" for " + instance_name)
  95. return ""!
  96. actual_name = instantiated_name(value, instance_name)
  97. dict_add_fast(model["model"], actual_name, value)
  98. dict_add_fast(model["type_mapping"], actual_name, type_name)
  99. return actual_name!
  100. String function find_attribute_type(model : Element, elem : String, name : String):
  101. String mm_elem
  102. String direct_type
  103. String result
  104. direct_type = read_type(model, elem)
  105. if (direct_type == ""):
  106. return ""!
  107. mm_elem = find_attribute_definer(model["metamodel"], direct_type, name)
  108. if (value_eq(mm_elem, "")):
  109. // Couldn't find element, so is not allowed!
  110. return ""!
  111. else:
  112. result = reverseKeyLookup(model["metamodel"]["model"], dict_read_edge(model["metamodel"]["model"][mm_elem], name))
  113. return result!
  114. Element function get_subclasses(model : Element, name : String):
  115. Element result
  116. Integer i
  117. Integer j
  118. Integer num_edges
  119. Element edge
  120. String elem
  121. Element nodes
  122. Element inheritance
  123. nodes = create_node()
  124. set_add(nodes, name)
  125. // Initialize empty set
  126. result = create_node()
  127. i = 0
  128. while (list_len(nodes) > 0):
  129. elem = set_pop(nodes)
  130. if (bool_not(set_in(result, elem))):
  131. create_edge(result, elem)
  132. // Read out all incoming edges
  133. num_edges = read_nr_in(model["model"][elem])
  134. j = 0
  135. while (j < num_edges):
  136. edge = read_in(model["model"][elem], j)
  137. if (value_eq(model["type_mapping"][reverseKeyLookup(model["model"], edge)], "Inheritance")):
  138. set_add(nodes, reverseKeyLookup(model["model"], read_edge_src(edge)))
  139. j = j + 1
  140. return result!
  141. Element function get_superclasses(model : Element, name : String):
  142. Element result
  143. Integer i
  144. Integer j
  145. Integer num_edges
  146. Element edge
  147. String elem
  148. Element nodes
  149. Element inheritance
  150. nodes = create_node()
  151. set_add(nodes, name)
  152. inheritance = "Inheritance"
  153. // Initialize empty set
  154. result = create_node()
  155. i = 0
  156. while (list_len(nodes) > 0):
  157. elem = set_pop(nodes)
  158. if (bool_not(set_in(result, elem))):
  159. create_edge(result, elem)
  160. // Read out all outgoing edges
  161. num_edges = read_nr_out(model["model"][elem])
  162. j = 0
  163. while (j < num_edges):
  164. edge = read_out(model["model"][elem], j)
  165. if (value_eq(model["type_mapping"][reverseKeyLookup(model["model"], edge)], inheritance)):
  166. set_add(nodes, reverseKeyLookup(model["model"], read_edge_dst(edge)))
  167. j = j + 1
  168. return result!
  169. String function find_attribute_definer(model : Element, elem_name : String, name : String):
  170. Element superclasses
  171. String current
  172. Integer nr_out
  173. Element out
  174. String name_attr
  175. superclasses = get_superclasses(model, elem_name)
  176. while (list_len(superclasses) > 0):
  177. current = set_pop(superclasses)
  178. nr_out = read_nr_out(model["model"][current])
  179. while (nr_out > 0):
  180. nr_out = nr_out - 1
  181. out = read_out(model["model"][current], nr_out)
  182. name_attr = read_attribute(model, reverseKeyLookup(model["model"], out), "name")
  183. if (name_attr == name):
  184. return current!
  185. return ""!
  186. Void function instantiate_attribute(model : Element, element : String, attribute_name : String, value : Element):
  187. // Instantiate an attribute of something that needs to be instantiated
  188. // Actually a bit more difficult than all the rest, as we need to find the attribute to instantiate
  189. String attr_type
  190. String attr_name
  191. if (element_neq(read_attribute(model, element, attribute_name), read_root())):
  192. unset_attribute(model, element, attribute_name)
  193. attr_type = find_attribute_type(model, element, attribute_name)
  194. if (attr_type == ""):
  195. log("Could not find attribute " + cast_v2s(attribute_name))
  196. log("For element " + element)
  197. log("Type: " + read_type(model, element))
  198. return!
  199. if (has_value(value)):
  200. value = create_value(value)
  201. attr_name = model_add_value(model, (element + ".") + attribute_name, value)
  202. retype(model, attr_name, reverseKeyLookup(model["metamodel"]["model"], read_edge_dst(model["metamodel"]["model"][attr_type])))
  203. instantiate_link(model, attr_type, "", element, attr_name)
  204. return!
  205. Void function instantiate_attribute_ref(model : Element, element : String, attribute_name : String, ref : String):
  206. // Instantiate an attribute of something that needs to be instantiated
  207. // Actually a bit more difficult than all the rest, as we need to find the attribute to instantiate
  208. String attr_type
  209. String attr_name
  210. attr_type = find_attribute_type(model, element, attribute_name)
  211. if (attr_type == ""):
  212. log("Could not find attribute " + cast_v2s(attribute_name))
  213. return!
  214. instantiate_link(model, attr_type, "", element, ref)
  215. return!
  216. Void function add_code_model(model : Element, export_name : String, code : Element):
  217. Element code_model
  218. code_model = instantiate_model(model)
  219. add_AL(code_model, code)
  220. export_node(export_name, code_model)
  221. return !
  222. Void function instantiate_attribute_code(model : Element, element : String, attribute_name : String, code : Element):
  223. // First create a new model for the AL part
  224. String location
  225. location = "code/" + cast_id2s(code)
  226. add_code_model(import_node("models/ActionLanguage"), location, code)
  227. // Now link it with a complex attribute
  228. instantiate_attribute(model, element, attribute_name, location)
  229. return!
  230. Void function instantiate_existing_attribute(model : Element, element : String, attribute_name : String, attr_ref : String):
  231. // Instantiate an attribute of something that needs to be instantiated
  232. // Actually a bit more difficult than all the rest, as we need to find the attribute to instantiate
  233. String attr_type
  234. String attr_name
  235. attr_type = find_attribute_type(model, element, attribute_name)
  236. if (attr_type == ""):
  237. log("Could not find attribute " + cast_v2s(attribute_name))
  238. return!
  239. // Make a copy of the value, as it is likely that this value is reused later on
  240. retype(model, attr_ref, reverseKeyLookup(model["metamodel"]["model"], read_edge_dst(model["metamodel"]["model"][attr_type])))
  241. instantiate_link(model, attr_type, "", element, attr_ref)
  242. return!
  243. String function instantiate_link(model : Element, type : String, name : String, source : String, destination : String):
  244. // Create a typed link between two nodes
  245. String actual_name
  246. if (type == ""):
  247. // Have to find the type ourselves, as it isn't defined
  248. Element out
  249. Element in
  250. Element options
  251. options = allowedAssociationsBetween(model, source, destination)
  252. if (read_nr_out(options) == 1):
  253. type = set_pop(options)
  254. elif (read_nr_out(options) == 0):
  255. log("ERROR: cannot find possible link between entries")
  256. log(" for " + source)
  257. log(" to " + destination)
  258. return ""!
  259. else:
  260. log("ERROR: too many possible links between entries")
  261. log(" options: " + set_to_string(options))
  262. return ""!
  263. if (bool_not(dict_in(model["metamodel"]["model"], type))):
  264. log("ERROR: (instantiate_link) no such type in metamodel: " + type)
  265. log(" for " + name)
  266. return ""!
  267. Element v
  268. v = create_edge(model["model"][source], model["model"][destination])
  269. actual_name = instantiated_name(v, name)
  270. dict_add_fast(model["model"], actual_name, v)
  271. dict_add_fast(model["type_mapping"], actual_name, type)
  272. return actual_name!
  273. Void function model_delete_element(model : Element, name : String):
  274. // Remove the link
  275. // 1) from the type mapping
  276. dict_delete(model["type_mapping"], name)
  277. // 2) from the model
  278. delete_element(model["model"][name])
  279. return!
  280. String function model_define_attribute(model : Element, elem : String, name : String, optional : Boolean, type : String):
  281. // Create the necessary links to make it an attribute
  282. String edge_name
  283. edge_name = (elem + "_") + name
  284. while (dict_in(model["model"], edge_name)):
  285. // Already exists, so make random name
  286. edge_name = edge_name + cast_id2s(model["model"][elem])
  287. log("Name clash detected for attribute: try new name: " + edge_name)
  288. edge_name = instantiate_link(model, "AttributeLink", edge_name, elem, type)
  289. instantiate_attribute(model, edge_name, "name", name)
  290. instantiate_attribute(model, edge_name, "optional", optional)
  291. return edge_name!
  292. Element function read_attribute(model : Element, element : String, attribute : String):
  293. Integer i
  294. Integer count
  295. Element edge
  296. Element edge_type
  297. Element elem
  298. Element typing
  299. Element name
  300. if (dict_in(model["model"], element)):
  301. elem = model["model"][element]
  302. typing = model["type_mapping"]
  303. count = read_nr_out(elem)
  304. i = 0
  305. while (i < count):
  306. edge = read_out(elem, i)
  307. name = reverseKeyLookup(model["model"], edge)
  308. if (dict_in(typing, name)):
  309. edge_type = model["metamodel"]["model"][typing[name]]
  310. if (element_eq(edge_type, dict_read_edge(read_edge_src(edge_type), attribute))):
  311. return read_edge_dst(edge)!
  312. i = i + 1
  313. else:
  314. log("Element does not exist: " + element)
  315. // Not found: either element doesn't exist, or we couldn't find it
  316. return read_root()!
  317. Void function unset_attribute(model : Element, element : String, attribute : String):
  318. // Removes an attribute if it exists
  319. String attr_type
  320. Element attr_links
  321. String attr_link
  322. attr_type = find_attribute_type(model, element, attribute)
  323. attr_links = allOutgoingAssociationInstances(model, element, attr_type)
  324. while (list_len(attr_links) > 0):
  325. attr_link = set_pop(attr_links)
  326. dict_delete(model["type_mapping"], reverseKeyLookup(model["model"], read_edge_dst(model["model"][attr_link])))
  327. dict_delete(model["type_mapping"], attr_link)
  328. dict_delete_node(model["model"], reverseKeyLookup(model["model"], read_edge_dst(model["model"][attr_link])))
  329. delete_element(model["model"][attr_link])
  330. return!
  331. Void function add_AL_links(model : Element, list : Element, element : Element, type: String, linkname : String, expected_type : String):
  332. if (bool_not(dict_in(element, linkname))):
  333. return!
  334. Element link
  335. String link_name
  336. link = dict_read_edge(element, linkname)
  337. link_name = "__" + cast_id2s(link)
  338. // The link
  339. dict_add_fast(model["model"], link_name, link)
  340. dict_add_fast(model["type_mapping"], link_name, (type + "_") + linkname)
  341. // The name link
  342. link = read_out(link, 0)
  343. link_name = "__" + cast_id2s(link)
  344. dict_add_fast(model["model"], link_name, link)
  345. dict_add_fast(model["type_mapping"], link_name, "dict_link_name")
  346. // The name node
  347. link = read_edge_dst(link)
  348. link_name = "__" + cast_id2s(link)
  349. if (bool_not(set_in_node(model["model"], link))):
  350. dict_add_fast(model["model"], link_name, link)
  351. dict_add_fast(model["type_mapping"], link_name, "StringAttr")
  352. // Now add the destination to the worker list
  353. set_add(list, create_tuple(element[linkname], expected_type))
  354. return!
  355. String function add_AL(model : Element, element : Element):
  356. Element todo
  357. Element node
  358. Element work_node
  359. Element elem
  360. String type
  361. String elem_name
  362. todo = create_node()
  363. node = create_node()
  364. list_append(node, element)
  365. list_append(node, "funcdef")
  366. set_add(todo, node)
  367. while (0 < dict_len(todo)):
  368. work_node = set_pop(todo)
  369. elem = list_read(work_node, 0)
  370. type = list_read(work_node, 1)
  371. if (bool_not(set_in_node(model["model"], elem))):
  372. // Determine the type if we don't know it
  373. if (type == ""):
  374. if (is_physical_action(elem)):
  375. type = cast_a2s(elem)
  376. else:
  377. type = "Element"
  378. // Add the node itself
  379. elem_name = "__" + cast_id2s(elem)
  380. dict_add_fast(model["model"], elem_name, elem)
  381. dict_add_fast(model["type_mapping"], elem_name, type)
  382. // Now add its edges
  383. if (type == "if"):
  384. add_AL_links(model, todo, elem, type, "cond", "")
  385. add_AL_links(model, todo, elem, type, "then", "")
  386. add_AL_links(model, todo, elem, type, "else", "")
  387. add_AL_links(model, todo, elem, type, "next", "")
  388. elif (type == "while"):
  389. add_AL_links(model, todo, elem, type, "cond", "")
  390. add_AL_links(model, todo, elem, type, "body", "")
  391. add_AL_links(model, todo, elem, type, "next", "")
  392. elif (type == "assign"):
  393. add_AL_links(model, todo, elem, type, "var", "resolve")
  394. add_AL_links(model, todo, elem, type, "value", "")
  395. add_AL_links(model, todo, elem, type, "next", "")
  396. elif (type == "break"):
  397. add_AL_links(model, todo, elem, type, "while", "while")
  398. elif (type == "continue"):
  399. add_AL_links(model, todo, elem, type, "while", "while")
  400. elif (type == "return"):
  401. add_AL_links(model, todo, elem, type, "value", "")
  402. elif (type == "resolve"):
  403. add_AL_links(model, todo, elem, type, "var", "")
  404. elif (type == "access"):
  405. add_AL_links(model, todo, elem, type, "var", "resolve")
  406. elif (type == "constant"):
  407. add_AL_links(model, todo, elem, type, "node", "")
  408. elif (type == "output"):
  409. add_AL_links(model, todo, elem, type, "node", "")
  410. add_AL_links(model, todo, elem, type, "next", "")
  411. elif (type == "global"):
  412. add_AL_links(model, todo, elem, type, "var", "String")
  413. add_AL_links(model, todo, elem, type, "next", "")
  414. elif (type == "param"):
  415. add_AL_links(model, todo, elem, type, "name", "String")
  416. add_AL_links(model, todo, elem, type, "value", "")
  417. add_AL_links(model, todo, elem, type, "next_param", "param")
  418. elif (type == "funcdef"):
  419. add_AL_links(model, todo, elem, type, "body", "")
  420. // TODO this should be added, but is not the same as "param"
  421. //add_AL_links(model, todo, elem, type, "params", "")
  422. add_AL_links(model, todo, elem, type, "next", "")
  423. elif (type == "call"):
  424. add_AL_links(model, todo, elem, type, "func", "")
  425. add_AL_links(model, todo, elem, type, "params", "param")
  426. add_AL_links(model, todo, elem, type, "last_param", "param")
  427. add_AL_links(model, todo, elem, type, "next", "")
  428. // Mark the node as first
  429. String initial
  430. initial = instantiate_node(model, "Initial", "")
  431. instantiate_link(model, "initial_funcdef", "", initial, reverseKeyLookup(model["model"], element))
  432. return reverseKeyLookup(model["model"], element)!
  433. Void function construct_model():
  434. String command
  435. while (True):
  436. command = input()
  437. if (command == "instantiate_bottom"):
  438. Element m
  439. m = instantiate_bottom()
  440. dict_add_fast(global_models, input(), m)
  441. elif (command == "add_node"):
  442. model_add_node(global_models[input()], input())
  443. elif (command == "add_value"):
  444. model_add_value(global_models[input()], input(), input())
  445. elif (command == "add_edge"):
  446. model_add_edge(global_models[input()], input(), input(), input())
  447. elif (command == "exit"):
  448. return!
  449. elif (command == "retype_model"):
  450. retype_model(global_models[input()], global_models[input()])
  451. elif (command == "retype"):
  452. retype(global_models[input()], input(), input())
  453. elif (command == "instantiate_model"):
  454. Element m
  455. m = instantiate_model(global_models[input()])
  456. dict_add_fast(global_models, input(), m)
  457. elif (command == "instantiate_node"):
  458. instantiate_node(global_models[input()], input(), input())
  459. elif (command == "instantiate_attribute"):
  460. instantiate_attribute(global_models[input()], input(), input(), input())
  461. elif (command == "instantiate_attribute_ref"):
  462. instantiate_attribute_ref(global_models[input()], input(), input(), input())
  463. elif (command == "instantiate_attribute_code"):
  464. instantiate_attribute_code(global_models[input()], input(), input(), construct_function())
  465. elif (command == "instantiate_link"):
  466. instantiate_link(global_models[input()], input(), input(), input(), input())
  467. elif (command == "model_define_attribute"):
  468. model_define_attribute(global_models[input()], input(), input(), input(), input())
  469. elif (command == "initialize_bottom"):
  470. initialize_bottom(input())
  471. elif (command == "export_node"):
  472. String local_name
  473. String location
  474. local_name = input()
  475. location = input()
  476. export_node(location, global_models[local_name])
  477. elif (command == "import_node"):
  478. Element m
  479. command = input()
  480. m = import_node(command)
  481. if (element_eq(m, read_root())):
  482. log("Error: import not found for " + command)
  483. else:
  484. dict_add_fast(global_models, input(), m)
  485. elif (command == "add_code_model"):
  486. add_code_model(global_models[input()], input(), construct_function())
  487. else:
  488. log("Modelling error: did not understand command " + command)
  489. Element function construct_model_raw(metamodel : Element):
  490. String command
  491. Element model
  492. model = instantiate_model(metamodel)
  493. while (True):
  494. command = input()
  495. if (command == "add_node"):
  496. input()
  497. model_add_node(model, input())
  498. elif (command == "add_value"):
  499. input()
  500. model_add_value(model, input(), input())
  501. elif (command == "add_edge"):
  502. input()
  503. model_add_edge(model, input(), input(), input())
  504. elif (command == "exit"):
  505. return model!
  506. elif (command == "instantiate_node"):
  507. input()
  508. instantiate_node(model, input(), input())
  509. elif (command == "model_define_attribute"):
  510. input()
  511. model_define_attribute(model, input(), input(), input(), input())
  512. elif (command == "instantiate_attribute"):
  513. input()
  514. instantiate_attribute(model, input(), input(), input())
  515. elif (command == "instantiate_attribute_ref"):
  516. input()
  517. instantiate_attribute_ref(model, input(), input(), input())
  518. elif (command == "instantiate_attribute_code"):
  519. input()
  520. instantiate_attribute_code(model, input(), input(), construct_function())
  521. elif (command == "instantiate_link"):
  522. input()
  523. instantiate_link(model, input(), input(), input(), input())
  524. elif (command == "import_node"):
  525. input()
  526. input()
  527. elif (command == "export_node"):
  528. input()
  529. input()
  530. elif (command == "instantiate_model"):
  531. input()
  532. input()
  533. elif (command == "add_code_model"):
  534. input()
  535. add_code_model(model, input(), construct_function())
  536. else:
  537. log("Modelling error: did not understand command " + command)
  538. Element function get_func_AL_model(al_model : Element):
  539. Element result
  540. Element initial_function
  541. // Find the initial function
  542. initial_function = allInstances(al_model, "Initial")
  543. if (read_nr_out(initial_function) == 0):
  544. log("Could not find function to execute in this model!")
  545. return create_node()!
  546. elif (read_nr_out(initial_function) > 1):
  547. log("Too many functions to execute in this model!")
  548. return create_node()!
  549. else:
  550. initial_function = al_model["model"][set_pop(allAssociationDestinations(al_model, set_pop(initial_function), "initial_funcdef"))]
  551. return initial_function!