get_main_sig.sa


Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
 
---------------------------> Sather 1.1 source file <--------------------------


class GET_MAIN_SIG < $GET_MAIN_SIG

class GET_MAIN_SIG < $GET_MAIN_SIG is -- This phase determines the signature of main. include CS_COMPONENT; attr main_sig:SIG; -- The signature of `main'. create(p:PROG):SAME is r::=new; r.prog:=p; return r end;-- GET_MAIN_SIG::prog get_main_sig(nm:STR) is -- Get the signature of the main routine in the class named `nm' -- and put it in `main_sig'. as::=prog.parse.tree_for(#IDENT(nm),0);-- GET_MAIN_SIG::prog PROG::parse IDENT::create err_loc(as);-- GET_MAIN_SIG::err_loc if void(as) then err("There is no type " + nm + " for main."); return end;-- GET_MAIN_SIG::err STR::plus STR::plus mt::=prog.tp_tbl.tp_class_for(#IDENT(nm),void);-- GET_MAIN_SIG::prog PROG::tp_tbl TP_TBL::tp_class_for IDENT::create im:IMPL := mt.impl;-- TP_CLASS::impl ifc:IFC:=mt.ifc; if void(ifc) then return end;-- TP_CLASS::ifc msig,omsig:SIG; loop msig:=ifc.sigs.get_query!(IDENT_BUILTIN::main_ident);-- IFC::sigs SIG_TBL::get_query! IDENT_BUILTIN::main_ident if ~void(omsig) then-- BOOL::not err("There may only be one `main' routine in the main class."); -- GET_MAIN_SIG::err return end; omsig:=msig end; if void(msig) then err("No routine named `main' in " + ifc.tp.str + ".");-- GET_MAIN_SIG::err STR::plus IFC::tp STR::plus return end; if ~void(msig.args) then-- SIG::args BOOL::not if msig.args.size/=1 or msig.args[0].tp/=TP_BUILTIN::arr_of_str-- SIG::args ARRAY{1}::size INT::is_eq BOOL::not SIG::args ARRAY{1}::aget ARG::tp TP_BUILTIN::arr_of_str then err("The signature of main: " + msig.str +-- BOOL::not GET_MAIN_SIG::err STR::plus SIG::str " doesn't have legal arguments."); return end;-- STR::plus elsif ~void(msig.ret) and msig.ret/=TP_BUILTIN::int then-- SIG::ret BOOL::not SIG::ret TP_BUILTIN::int BOOL::not err("The signature of main: " + msig.str +-- GET_MAIN_SIG::err STR::plus SIG::str " doesn't have a legal return type."); return end;-- STR::plus if prog.show_main then #OUT + "Main sig=" + msig.str + "\n" end;-- GET_MAIN_SIG::prog PROG::show_main OUT::create OUT::plus OUT::plus SIG::str OUT::plus main_sig:=msig end;-- GET_MAIN_SIG::main_sig end;