Ver código fonte

Constrain the types of constructors further (Element --> Action)

Yentl Van Tendeloo 9 anos atrás
pai
commit
949d8d78dc
2 arquivos alterados com 51 adições e 51 exclusões
  1. 49 49
      bootstrap/constructors.alc
  2. 2 2
      interface/HUTN/includes/constructors.alh

+ 49 - 49
bootstrap/constructors.alc

@@ -5,7 +5,7 @@ include "io.alh"
 
 Element while_stack = ?
 
-Element function construct_top():
+Action function construct_top():
 	String command
 	command = input()
 	if (command == "global"):
@@ -15,8 +15,8 @@ Element function construct_top():
 	else:
 		log("ERROR: did not understand command " + cast_e2s(command))
 
-Element function construct_top_global():
-	Element this_element
+Action function construct_top_global():
+	Action this_element
 	String declared_element
 	String op
 
@@ -25,9 +25,9 @@ Element function construct_top_global():
 	dict_add(this_element, "var", declared_element)
 
 	// Defines
-	Element assign
-	Element resolve
-	Element value
+	Action assign
+	Action resolve
+	Action value
 	assign = create_value(!assign)
 	dict_add(this_element, "next", assign)
 	resolve = create_value(!resolve)
@@ -47,14 +47,14 @@ Element function construct_top_global():
 		dict_add(assign, "next", construct_top())
 	return this_element
 
-Element function construct_top_funcdef():
-	Element assign
-	Element resolve
-	Element constant
+Action function construct_top_funcdef():
+	Action assign
+	Action resolve
+	Action constant
 	Element formal
 	Element func
 	Element params
-	Element global
+	Action global
 
 	global = create_value(!global)
 	assign = create_value(!assign)
@@ -95,7 +95,7 @@ Element function construct_top_funcdef():
 
 	return global
 
-Element function construct_unknown():
+Action function construct_unknown():
 	String elem
 	Element new_model
 	Element new_model_model
@@ -155,8 +155,8 @@ Element function construct_unknown():
 	else:
 		log("ERROR: did not understand command " + cast_e2s(elem))
 
-Element function construct_if():
-	Element this_element
+Action function construct_if():
+	Action this_element
 	this_element = create_value(!if)
 	dict_add(this_element, "cond", construct_unknown())
 	dict_add(this_element, "then", construct_unknown())
@@ -166,8 +166,8 @@ Element function construct_if():
 		dict_add(this_element, "next", construct_unknown())
 	return this_element
 
-Element function construct_while():
-	Element this_element
+Action function construct_while():
+	Action this_element
 	this_element = create_value(!while)
 	dict_add(this_element, "cond", construct_unknown())
 
@@ -179,20 +179,20 @@ Element function construct_while():
 		dict_add(this_element, "next", construct_unknown())
 	return this_element
 
-Element function construct_access():
-	Element this_element
+Action function construct_access():
+	Action this_element
 	this_element = create_value(!access)
 	dict_add(this_element, "var", construct_unknown())
 	return this_element
 
-Element function construct_resolve():
-	Element this_element
+Action function construct_resolve():
+	Action this_element
 	this_element = create_value(!resolve)
 	dict_add(this_element, "var", input())
 	return this_element
 
-Element function construct_assign():
-	Element this_element
+Action function construct_assign():
+	Action this_element
 	this_element = create_value(!assign)
 	dict_add(this_element, "var", construct_unknown())
 	dict_add(this_element, "value", construct_unknown())
@@ -200,8 +200,8 @@ Element function construct_assign():
 		dict_add(this_element, "next", construct_unknown())
 	return this_element
 
-Element function construct_call():
-	Element this_element
+Action function construct_call():
+	Action this_element
 	this_element = create_value(!call)
 	dict_add(this_element, "func", construct_unknown())
 
@@ -236,21 +236,21 @@ Element function construct_call():
 		dict_add(this_element, "next", construct_unknown())
 	return this_element
 
-Element function construct_return():
-	Element this_element
+Action function construct_return():
+	Action this_element
 	this_element = create_value(!return)
 	if (input()):
 		dict_add(this_element, "value", construct_unknown())
 	return this_element
 
-Element function construct_const():
-	Element this_element
+Action function construct_const():
+	Action this_element
 	this_element = create_value(!constant)
 	dict_add(this_element, "node", input())
 	return this_element
 
-Element function construct_declare():
-	Element this_element
+Action function construct_declare():
+	Action this_element
 	Element declared_element
 	this_element = create_value(!declare)
 	declared_element = create_node()
@@ -261,8 +261,8 @@ Element function construct_declare():
 	return this_element
 
 // TODO remove global keyword
-Element function construct_global():
-	Element this_element
+Action function construct_global():
+	Action this_element
 	String declared_element
 	this_element = create_value(!global)
 	declared_element = input()
@@ -271,31 +271,31 @@ Element function construct_global():
 		dict_add(this_element, "next", construct_unknown())
 	return this_element
 
-Element function construct_input():
-	Element this_element
+Action function construct_input():
+	Action this_element
 	this_element = create_value(!input)
 	return this_element
 
-Element function construct_output():
-	Element this_element
+Action function construct_output():
+	Action this_element
 	this_element = create_value(!output)
 	dict_add(this_element, "value", construct_unknown())
 	if (input()):
 		dict_add(this_element, "next", construct_unknown())
 	return this_element
 
-Element function construct_deref():
-	Element this_element
+Action function construct_deref():
+	Action this_element
 	this_element = create_value(!constant)
 	dict_add(this_element, "node", import_node(input()))
 	return this_element
 
-Element function construct_funcdef():
-	Element assign
-	Element resolve
-	Element constant
+Action function construct_funcdef():
+	Action assign
+	Action resolve
+	Action constant
 	Element formal
-	Element func
+	Action func
 	Element params
 
 	assign = create_value(!assign)
@@ -334,14 +334,14 @@ Element function construct_funcdef():
 
 	return assign
 
-Element function construct_break():
-	Element this_element
+Action function construct_break():
+	Action this_element
 	this_element = create_value(!break)
 	dict_add(this_element, "while", dict_read(while_stack, list_len(while_stack) - 1))
 	return this_element
 
-Element function construct_continue():
-	Element this_element
+Action function construct_continue():
+	Action this_element
 	this_element = create_value(!continue)
 	dict_add(this_element, "while", dict_read(while_stack, list_len(while_stack) - 1))
 	return this_element
@@ -371,7 +371,7 @@ Element function instantiate_model(model : Element):
 	Element type
 	type = dict_read(dict_read(dict_read(model, "metamodel"), "model"), input())
 
-	Element name
+	String name
 	name = input()
 
 	Element params
@@ -413,7 +413,7 @@ Element function retype_model(model : Element):
 
 	return retype(model, metamodel, inheritance, mapping)
 
-Element function find_attribute(source : Element, attr_name : Element, types : Element, inheritance_link : Element):
+Element function find_attribute(source : Element, attr_name : String, types : Element, inheritance_link : Element):
 	if (dict_in(source, attr_name)):
 		return source
 	else:

+ 2 - 2
interface/HUTN/includes/constructors.alh

@@ -1,5 +1,5 @@
-Element function construct_top()
-Element function construct_unknown()
+Action function construct_top()
+Action function construct_unknown()
 Element function find_attribute(a: Element, b: Element, c: Element, d: Element)
 Element function retype_model(a: Element)
 Element function instantiate_model(a: Element)