Browse Source

Updated constructors to deal with mutable functions as well

Yentl Van Tendeloo 8 years ago
parent
commit
f9fa4165c3
2 changed files with 14 additions and 4 deletions
  1. BIN
      bootstrap/bootstrap.m.gz
  2. 14 4
      bootstrap/constructors.alc

BIN
bootstrap/bootstrap.m.gz


+ 14 - 4
bootstrap/constructors.alc

@@ -14,7 +14,9 @@ Action function construct_top():
 		if (command == "global"):
 			return construct_global()!
 		elif (command == "funcdef"):
-			return construct_top_funcdef()!
+			return construct_top_funcdef(False)!
+		elif (command == "mutable_funcdef"):
+			return construct_top_funcdef(True)!
 		else:
 			log("ERROR: did not understand command " + cast_e2s(command))
 
@@ -58,7 +60,7 @@ Action function construct_global():
 		dict_add(assign, "next", construct_top())
 	return this_element!
 
-Action function construct_top_funcdef():
+Action function construct_top_funcdef(mutable : Boolean):
 	Action assign
 	Action resolve
 	Action constant
@@ -87,6 +89,9 @@ Action function construct_top_funcdef():
 	dict_add(constant, "node", func)
 	dict_add(func, "params", params)
 
+	if (mutable):
+		dict_add(func, "mutable", create_node())
+
 	Integer nrParams
 	nrParams = input()
 	Integer counter
@@ -308,12 +313,14 @@ Action function construct_function():
 	Element param
 	Element params
 	String arg_names_decl
+	String inp
 
 	variable_map = create_node()
 
-	while (value_neq(input(), "funcdef")):
+	inp = input()
+	while (bool_or(inp == "funcdef", inp == "mutable_funcdef")):
 		// We skip over everything that is not a funcdef, as these are all just definitions of global stuff
-		log("Skip over input!")
+		inp = input()
 
 	// Consume the name
 	input()
@@ -325,6 +332,9 @@ Action function construct_function():
 	arg_names_decl = "abcdefghijklmnopqrstuvwxyz"
 	dict_add(func, "params", params)
 
+	if (inp == "mutable_funcdef"):
+		dict_add(func, "mutable", create_node())
+
 	while (counter < nrParams):
 		param = create_node()
 		dict_add(params, string_get(arg_names_decl, counter), param)