cs.sa


Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
 
---------------------------> Sather 1.1 source file <--------------------------
-- Copyright (C) International Computer Science Institute, 1995.  COPYRIGHT  --
-- NOTICE: This code is provided "AS IS" WITHOUT ANY WARRANTY and is subject --
-- to the terms of the SATHER LIBRARY GENERAL PUBLIC LICENSE contained in    --
-- the file "Doc/License" of the Sather distribution.  The license is also   --
-- available from ICSI, 1947 Center St., Suite 600, Berkeley CA 94704, USA.  --
--------> Please email comments to sather-bugs@icsi.berkeley.edu. <----------


class CS

class CS is -- The Sather 1.1 compiler. attr only_parse:BOOL; -- Stop after parsing attr only_reachable:BOOL; -- Don't check unreachable code main(a:ARRAY{STR}):INT is -- Compile a program. Here we go... -- Allocate an object and fill it in with the standard -- compiler components. p::=#PROG; -- PROG::create p.parse:=#PARSE(p);-- PROG::parse PARSE::create p.find_types:=#FIND_TYPES(p);-- PROG::find_types FIND_TYPES::create p.build_type_graph:=#BUILD_TYPE_GRAPH(p);-- PROG::build_type_graph BUILD_TYPE_GRAPH::create p.check_ifc_conformance:=#CHECK_IFC_CONFORMANCE(p);-- PROG::check_ifc_conformance CHECK_IFC_CONFORMANCE::create p.get_main_sig:=#GET_MAIN_SIG(p);-- PROG::get_main_sig GET_MAIN_SIG::create p.generate_am:=#GENERATE_AM(p);-- PROG::generate_am GENERATE_AM::create p.check_am:=#CHECK_AM(p);-- PROG::check_am CHECK_AM::create p.inliner:=#INLINE(p);-- PROG::inliner INLINE::create cgen:CGEN:=#CGEN(p);-- CGEN::create p.back_end:=cgen;-- PROG::back_end p.get_options:=#CS_OPTIONS(p,self);-- PROG::get_options CS_OPTIONS::create -- p.show_tr := true; -- Handle the command line options and SATHER_COMMANDS p.get_options.read_env;-- PROG::get_options common::=p.home+"/System/Common/Common.module";-- PROG::home STR::plus p.get_options.interpret(|"",common|); -- first element of array is ignored-- PROG::get_options p.get_options.interpret(a);-- PROG::get_options p.config:=#CONFIG_TBL(p.home+"/System/Common/CONFIG");-- PROG::config CONFIG_TBL::create PROG::home STR::plus if p.genuine_platforms=0 then-- PROG::genuine_platforms INT::is_eq plt::=UNIX::get_env("SATHER_PLATFORM");-- UNIX::get_env if void(plt) then plt:=p.config.get_str("DEFAULT_PLATFORM",0);-- PROG::config CONFIG_TBL::get_str end; plt:=p.home+"/System/Platforms/"+plt;-- PROG::home STR::plus STR::plus p.platforms:=p.platforms.push(plt);-- PROG::platforms PROG::platforms FLIST{1}::push p.get_options.interpret(|"",plt+"/Platform.module"|); -- first element of array is ignored-- PROG::get_options STR::plus elsif p.genuine_platforms/=1 then-- PROG::genuine_platforms INT::is_eq BOOL::not #ERR+"More than one Platform specified, aborting.\n";-- ERR::create ERR::plus UNIX::exit(-1);-- UNIX::exit end; loop p.config.read(p.platforms.elt!+"/CONFIG"); end;-- PROG::config CONFIG_TBL::read PROG::platforms FLIST{1}::elt! STR::plus p.tp_tbl:=#(p);-- PROG::tp_tbl TP_TBL::create p.tp_graph:=#(p);-- PROG::tp_graph TP_GRAPH::create p.tp_graph_abs_des:=#(p);-- PROG::tp_graph_abs_des TP_GRAPH_ABS_DES::create p.as_tbl:=#;-- PROG::as_tbl PROG_AS_TBL::create p.optimizer:=#OPTIMIZE(p);-- PROG::optimizer OPTIMIZE::create p.boot:=p.config.get_bool("BOOT");-- PROG::boot PROG::config CONFIG_TBL::get_bool p.distributed:=p.config.get_bool("DISTRIBUTED");-- PROG::distributed PROG::config CONFIG_TBL::get_bool p.threads:=p.config.get_bool("THREADS");-- PROG::threads PROG::config CONFIG_TBL::get_bool p.zones:=p.config.get_bool("ZONES");-- PROG::zones PROG::config CONFIG_TBL::get_bool p.trace:=p.config.get_bool("TRACE");-- PROG::trace PROG::config CONFIG_TBL::get_bool if p.print_version then-- PROG::print_version v::=p.config.get_str("VERSION",0);-- PROG::config CONFIG_TBL::get_str #OUT +"ICSI Sather compiler version: " + v + "\n";-- OUT::create OUT::plus OUT::plus OUT::plus #OUT+"Default platform: "+p.config.get_str("DEFAULT_PLATFORM",0)+'\n';-- OUT::create OUT::plus OUT::plus PROG::config CONFIG_TBL::get_str OUT::plus #OUT + "Installed platforms:\n";-- OUT::create OUT::plus loop strs::= p.config.get_def("PLATFORMS").elt!;-- PROG::config CONFIG_TBL::get_def CONFIG_DEF::elt! loop ps ::= strs.elt!;-- ARRAY{1}::elt! #OUT + "\t" + ps + '\n';-- OUT::create OUT::plus OUT::plus OUT::plus end; end; #OUT + "Home directory: " + p.home + '\n';-- OUT::create OUT::plus OUT::plus PROG::home OUT::plus end; sl::=UNIX::get_env(p.config.get_str("LIBRARY",0));-- UNIX::get_env PROG::config CONFIG_TBL::get_str if void(sl) then p.get_options.interpret(|"",p.home+"/"+p.config.get_str("LIBRARY",1)|);-- PROG::get_options PROG::home STR::plus STR::plus PROG::config CONFIG_TBL::get_str else p.get_options.interpret(|"",sl|);-- PROG::get_options end; if p.prolix then #OUT + p.get_options.str +"\n\n"; end;-- PROG::prolix OUT::create OUT::plus PROG::get_options OUT::plus if p.prolix then p.stat:=#STAT; else p.stat:=#NULL_STAT; end;-- PROG::prolix PROG::stat STAT::create PROG::stat NULL_STAT::create TIME::start;-- TIME::start if p.verbose then (#OUT+"Parsing non-library files... ").flush; end;-- PROG::verbose OUT::create OUT::plus OUT::flush loop fn::=p.sather_files.elt!;-- PROG::sather_files FSET{1}::elt! p.parse.parse(fn);-- PROG::parse end; if p.verbose then-- PROG::verbose #OUT+'('+TIME::elapsed+" seconds)"-- OUT::create OUT::plus OUT::plus TIME::elapsed end;-- OUT::plus if p.err_seen then return 1 end;-- PROG::err_seen if only_parse then return 0; end;-- CS::only_parse TIME::start;-- TIME::start if p.verbose then (#OUT+"\nFinding types and parsing library... ").flush; end;-- PROG::verbose OUT::create OUT::plus OUT::flush p.find_types.find_types;-- PROG::find_types if p.verbose then-- PROG::verbose #OUT+'('+TIME::elapsed+" seconds)"-- OUT::create OUT::plus OUT::plus TIME::elapsed end;-- OUT::plus if p.prolix then-- PROG::prolix #OUT + '\n' + p.as_tbl.size.str + " Classes found:\n";-- OUT::create OUT::plus OUT::plus PROG::as_tbl PROG_AS_TBL::size INT::str OUT::plus p.as_tbl.dump;-- PROG::as_tbl PROG_AS_TBL::dump end; if p.err_seen then return 2 end;-- PROG::err_seen p.no_new_types := true;-- PROG::no_new_types TIME::start;-- TIME::start if p.verbose then (#OUT+"\nType graph, conformance, main, init... ").flush; end;-- PROG::verbose OUT::create OUT::plus OUT::flush p.build_type_graph.build_graphs;-- PROG::build_type_graph if p.err_seen then return 3 end; -- PROG::err_seen p.check_ifc_conformance.check_ifc_conformance;-- PROG::check_ifc_conformance if p.err_seen then return 4 end; -- PROG::err_seen p.get_main_sig.get_main_sig(p.main_class);-- PROG::get_main_sig PROG::main_class if p.err_seen then return 5 end; -- PROG::err_seen if ~cgen.only_check then-- CGEN::only_check BOOL::not TIME::start;-- TIME::start p.inliner.init;-- PROG::inliner p.optimizer.init;-- PROG::optimizer if p.err_seen then return 6 end; -- PROG::err_seen end; if p.verbose then #OUT+'('+TIME::elapsed+" seconds)"; end;-- PROG::verbose OUT::create OUT::plus OUT::plus TIME::elapsed OUT::plus TIME::start;-- TIME::start if p.verbose then -- PROG::verbose (#OUT+"\nType check, generate, inline, optimize, and make C... ")-- OUT::create OUT::plus .flush;-- OUT::flush end; p.generate_am.generate_am;-- PROG::generate_am if p.verbose then #OUT+'('+TIME::elapsed+" seconds)"; end;-- PROG::verbose OUT::create OUT::plus OUT::plus TIME::elapsed OUT::plus if p.show_tr then p.as_tbl.as_out(p) end; -- PROG::show_tr PROG::as_tbl PROG_AS_TBL::as_out if p.err_seen then return 7 end; -- PROG::err_seen if ~cgen.only_check then-- CGEN::only_check BOOL::not TIME::start;-- TIME::start if p.verbose then (#OUT+"\nHeaders, compiling C... ").flush; end;-- PROG::verbose OUT::create OUT::plus OUT::flush p.optimizer.finalize; -- PROG::optimizer if p.verbose then #OUT+"("+TIME::elapsed+" seconds)"; end;-- PROG::verbose OUT::create OUT::plus OUT::plus TIME::elapsed OUT::plus if p.err_seen then return 8 end; -- PROG::err_seen end; if ~only_reachable then-- CS::only_reachable BOOL::not TIME::start;-- TIME::start if p.verbose then -- PROG::verbose (#OUT+"\nChecking unreachable code... ").flush;-- OUT::create OUT::plus OUT::flush end; p.check_am.check_code;-- PROG::check_am if p.verbose then #OUT+'('+TIME::elapsed+" seconds)"; end;-- PROG::verbose OUT::create OUT::plus OUT::plus TIME::elapsed OUT::plus if p.err_seen then return 9 end; -- PROG::err_seen end; if p.verbose then -- PROG::verbose #OUT + "\nCompilation complete.\n"; -- OUT::create OUT::plus p.stat.print;-- PROG::stat end; STORE_CALL_MAP::print_stored;-- STORE_CALL_MAP::print_stored return 0; end; end;