home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
sa104os2.zip
/
SATHR104.ZIP
/
SATHER
/
COMPILER
/
GLOBAL.SA
< prev
next >
Wrap
Text File
|
1994-11-15
|
2KB
|
42 lines
-- 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 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);
if ~void(m) then return m.get(name) end;
return void end;
insert(g:AM_GLOBAL_EXPR) is
-- Insert the global `g' into the table.
m::=tbl.get(g.class_tp);
m:=m.insert(g.name,g);
tbl:=tbl.insert(g.class_tp,m);
top_sort:=top_sort.push(g);
end;
end;
-------------------------------------------------------------------