##############################################################
class Node(kind,vlineno,pre_num,post_num)
method dump(nodes_created_file)
{
	    write(nodes_created_file, left("kind   = ",40) || self.kind)
	    write(nodes_created_file, left("vlineno   = ",40) || dump_info(self.vlineno))
	    write(nodes_created_file, left("pre_num   = ",40) || dump_info(self.pre_num))
	    write(nodes_created_file, left("post_num   = ",40) || dump_info(self.post_num))
	}
end
method dump_tree()
{
	    proc_dump_tree(self,"kind   = ", self.kind)
	    proc_dump_tree(self,"vlineno   = ",self.vlineno)
	    proc_dump_tree(self,"pre_num   = ",self.pre_num)
	    proc_dump_tree(self,"post_num   = ",self.post_num)
	}
end
initially (knd, line, pre, post)
{
kind := knd
vlineno := line
pre_num := pre
post_num := post
}
end
##########################################################################
class ConsNode(unique_id,cn_hd_field,cn_tl_field)
method dump(nodes_created_file)
{ # SignatureSig
	    write(nodes_created_file, left("cn_hd_field   = ",40) || dump_info(self.cn_hd_field))
	    write(nodes_created_file, left("cn_tl_field   = ",40) || dump_info(self.cn_tl_field))
	    write(nodes_created_file, left("Unique Id   = ",40) || dump_info(self.unique_id))
	}
end
method dump_tree()
{
	    proc_dump_tree(self,"cn_hd_field   = ",self.cn_hd_field)
	    proc_dump_tree(self,"cn_tl_field   = ",self.cn_tl_field)
	    proc_dump_tree(self,"Unique Id   = ",self.unique_id)
	}
end
method cons_dump(cons_file)
{ # SignatureSig
	    consinfo(left("cn_hd_field   = ",40) || dump_info(self.cn_hd_field))
	    consinfo(left("cn_tl_field   = ",40) || dump_info(self.cn_tl_field))
	    consinfo(left("Unique Id   = ",40) || dump_info(self.unique_id))
	}
end
initially(cn_hd,cn_tl)
{
cn_tl_field := cn_tl
cn_hd_field := cn_hd

unique_node_id +:= 1
unique_id := unique_node_id
}
end
#########################################################################
class RElementNode : Node : ConsNode(re_id,re_denotation,re_New_index,re_ValueOf_index,re_assign_index,kind,vlineno,pre_num,post_num,cn_hd_field,cn_tl_field,cn_hd_field,cn_tl_field)
method dump(nodes_created_file)
{ # RElement
self$Node.dump(nodes_created_file)
self$ConsNode.dump(nodes_created_file)
	    write(nodes_created_file,left("re_id   = ",40) || dump_info(self.re_id))
	    write(nodes_created_file,left("re_denotation   = ",40) || dump_info(self.re_denotation))
	    write(nodes_created_file,left("re_New_index   = ",40) || dump_info(self.re_New_index))
	    write(nodes_created_file,left("re_ValueOf_index   = ",40) || dump_info(self.re_ValueOf_index))
	    write(nodes_created_file,left("re_assign_index   = ",40) || dump_info(self.re_assign_index))
	}
end
method dump_tree()
{ # RElement
self$Node.dump(nodes_created_file)
self$ConsNode.dump(nodes_created_file)

proc_dump_tree(self,"re_id   = ", self.re_id)
proc_dump_tree(self,"re_denotation   = ", self.re_denotation)
proc_dump_tree(self,"re_New_index   = ", self.re_New_index)
proc_dump_tree(self,"re_ValueOf_index   = ", self.re_ValueOf_index)
proc_dump_tree(self,"re_assign_index   = ", self.re_assign_index)
	}
end
initially
self$Node.initially (kind,vlineno,pre_num,post_num)
self$ConsNode.initially(cn_hd_field,cn_tl_field)
end
###########################################################################
class VarSignature : Node : ConsNode(signature,sig_done,var_denotation,kind,vlineno,pre_num,post_num,cn_hd_field,cn_tl_field,cn_hd_field,cn_tl_field)
method dump(nodes_created_file)
 { # VarSignature
self$Node.dump(nodes_created_file)
self$ConsNode.dump(nodes_created_file)
	    write(nodes_created_file,left("signature   = ",40) || dump_info(self.signature))
	    write(nodes_created_file,left("sig_done   = ",40) || dump_info(self.sig_done))
	    write(nodes_created_file,left("var_denotation   = ",40) || dump_info(self.var_denotation))
	}
end
method dump_tree()
 { # VarSignature
self$Node.dump_tree(treefile)
self$ConsNode.dump_tree(treefile)
proc_dump_tree(self,"signature   = ", self.signature)
proc_dump_tree(self,"sig_done   = ", self.sig_done)
proc_dump_tree(self,"var_denotation   = ", self.var_denotation)
	}
end
initially
self$Node.initially (kind,vlineno,pre_num,post_num)
self$ConsNode.initially(cn_hd_field,cn_tl_field)
end
########################################################################
procedure main()




end

#######################################################################
procedure dump_info(it)
if type(it) == "integer" then return it
else if type(it) == "string"then return it
else if type(it) == "real" then return it
else return type(it)
end
procedure proc_dump_tree(me,str,it)
static cnt, visited
initial
{
cnt := 0
visited := set()
}
cnt +:= 1
if cnt > 100000 then return
if type(it) == "integer" then write(treefile,left(str,40) || it)
else if type(it) == "string"then write(treefile,left(str,40) || it)
else if type(it) == "real" then write(treefile,left(str,40) || it)
else if type(it) == "co-expression" then write(treefile,left(str,40) || type(it))
else if type(it) == "cset" then write(treefile,left(str,40) || type(it))
else if type(it) == "file" then write(treefile,left(str,40) || type(it))
else if type(it) == "list" then write(treefile,left(str,40) || type(it))
else if type(it) == "null" then write(treefile,left(str,40) || type(it))
else if type(it) == "procedure" then write(treefile,left(str,40) || type(it))
else if type(it) == "set" then write(treefile,left(str,40) || type(it))
else if type(it) == "table" then write(treefile,left(str,40) || type(it))
else if type(it) == "window" then write(treefile,left(str,40) || type(it))
else if type(it) == "Array" then write(treefile,left(str,40) || type(it))
else  if not (member(visited,it)) then
	      {
	      insert(visited,it)
	      write(treefile,left("Begin Subtree",40) ||type(it))
	      it.dump_tree(treefile)
	      write(treefile,left("End Subtree",40) ||type(it))
	  }
	  else
	      {
	      write(treefile,left("End Subtree already visited",40) ||type(it))
	      it.dump(treefile)
	      write(treefile,left("End Subtree already visited",40) ||type(it))
	  }
end
