global.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, 1994.  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. <----------

-- global.sa: Globals in the Sather compiler.


class GLOBAL_TBL

class GLOBAL_TBL is -- A table of global variables for the Sather compiler. attr tbl:FMAP{$TP,FMAP{IDENT,AM_GLOBAL_EXPR}}; -- Maps from types to hmaps from idents to globals. attr prog:PROG; -- The program this is for. attr top_sort:FLIST{AM_GLOBAL_EXPR}; -- List of globals in an order they can be initialized. create(p:PROG):SAME is -- A new table for the program `p'. return new end; get(name:IDENT, tp:$TP):AM_GLOBAL_EXPR is -- Retrieve the global with the name `name' in the type `tp' -- if present, otherwise return void. m::=tbl.get(tp);-- GLOBAL_TBL::tbl FMAP{2}::get if ~void(m) then return m.get(name) end;-- BOOL::not FMAP{2}::get return void end; insert(g:AM_GLOBAL_EXPR) is -- Insert the global `g' into the table. m::=tbl.get(g.class_tp); -- GLOBAL_TBL::tbl FMAP{2}::get AM_GLOBAL_EXPR::class_tp m:=m.insert(g.name,g);-- FMAP{2}::insert AM_GLOBAL_EXPR::name tbl:=tbl.insert(g.class_tp,m);-- GLOBAL_TBL::tbl GLOBAL_TBL::tbl FMAP{2}::insert AM_GLOBAL_EXPR::class_tp top_sort:=top_sort.push(g);-- GLOBAL_TBL::top_sort GLOBAL_TBL::top_sort FLIST{1}::push end; end;