include "io.alh"
include "primitives.alh"

Void function task_management():
	String taskname
	Element task_root
	Element task_frame
	Element output_value
	Element input_value
	
	while (True):
		taskname = input()
		if (bool_not(dict_in(read_root(), taskname))):
			task_root = create_node()
			task_frame = create_node()
			output_value = create_node()
			input_value = create_node()
			dict_add(task_root, "frame", task_frame)
			dict_add(task_root, "globals", create_node())
			dict_add(task_root, "output", output_value)
			dict_add(task_root, "last_output", output_value)
			dict_add(task_root, "input", input_value)
			dict_add(task_root, "last_input", input_value)
			dict_add(task_frame, "evalstack", create_node())
			dict_add(task_frame, "returnvalue", create_node())
			dict_add(task_frame, "phase", "init")
			dict_add(task_frame, "IP", dict_read(dict_read(read_root(), "__hierarchy"), "__IP"))
			dict_add(task_frame, "symbols", create_node())

			//Add this only at the end, as otherwise the task will already be detected
			dict_add(read_root(), taskname, task_root)
	return!
