am.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. <----------

-- am.sa: An abstract machine representation for Sather programs.

-- $AM: Supertype of everything in abstract machine representation. -- AM: Implementation to be included by $AM nodes. -- -- AM_OB_DEF: The layout of objects of a particular type. -- AM_ROUT_DEF: A function definition representing a routine or iter.

abstract class $AM < $PROG_ERR

abstract class $AM < $PROG_ERR is -- Supertype of everything in abstract machine representation. source:SFILE_ID; -- The origin of a node in a Sather -- source file. end;

class AM

class AM is -- Supertype of everything in abstract machine representation. attr source:SFILE_ID; -- Information identifying the -- origin of a node in Sather source. It encodes the file and -- the character offset of the originating construct. create(source:SFILE_ID):SAME is -- A new object for the location `source' with default -- initialization. r::=new; r.source:=source; return r end;-- AM_ASSIGN_STMT::source end;

class AM_OB_DEF < $AM

class AM_OB_DEF < $AM is -- The layout of a particular object type. include AM; attr tp:$TP; -- The type this represents. attr at:FMAP{IDENT,$TP}; -- Maps from attribute names to types. attr arr:$TP; -- The type of the array elements, if any. attr asize:INT; -- The size of the array portion if it -- is constant. -1 for variable sized arrays. end;

class AM_ROUT_DEF <$AM

class AM_ROUT_DEF <$AM is -- The definition of a function representing Sather routines and iters. include AM create->; include ARRAY{AM_FORMAL_ARG} append->,merge_with_by->; -- An array of the argument local -- variables in order. The first is `self'. attr sig:SIG; -- The signature of the routine. attr is_abstract:BOOL; -- True for an abstract routine, in -- this case none of the below are defined. attr calls:FLIST{$AM_EXPR}; -- The calls that occur in the -- body of this routine or iter. attr locals:FLIST{AM_LOCAL_EXPR}; -- The list of local variables. attr rres:AM_LOCAL_EXPR; -- The result local variable if used. attr code:$AM_STMT; -- Code to execute when called. attr is_external:BOOL; -- True if this is an external routine -- with a body, i.e. it is defined in Sather but callable from an -- external language. We don't generate an AM_ROUT_DEF for -- routines defined in the external language. attr is_clean:BOOL; -- True if known to not affect existing -- state. attr num_yields:INT; -- The number of yields in the body. attr srcsig:SIG; -- The signature of this routine or iter -- in the class it originally came from. Used to detect built-in ops. attr specul_prefetch:AM_LOCAL_EXPR; -- used if the function uses speculative prefetch -- only used in pSather create(nargs:INT, source:SFILE_ID):SAME is -- A new definition for a routine or iter with `nargs' arguments -- (including self). r::=new(nargs); r.source:=source; return r end;-- AM_ROUT_DEF::source calls_size:INT is if void(calls) then return 0 end; return calls.size end; is_iter:BOOL is -- True if an iter. return sig.is_iter end;-- AM_ROUT_DEF::sig SIG::is_iter name:IDENT is -- The Sather name. return sig.name end; number_of_args:INT is -- The number of arguments for this routine or iter -- (including self). return size end; self_local:AM_LOCAL_EXPR is -- The local variable representing self. return [0].expr end;-- AM_ROUT_DEF::aget AM_FORMAL_ARG::expr local_is_hot(l:AM_LOCAL_EXPR):BOOL is -- True if `l' is a hot argument to an iter. if ~is_iter or void(sig.hot) then return false end;-- AM_ROUT_DEF::is_iter BOOL::not AM_ROUT_DEF::sig SIG::hot i:INT:=0; loop while!(i<asize); -- AM_ROUT_DEF::asize if SYS::ob_eq([i].expr,l) then return sig.hot[i] end;-- SYS::ob_eq AM_ROUT_DEF::aget AM_FORMAL_ARG::expr AM_ROUT_DEF::sig SIG::hot ARRAY{1}::aget i:=i+1 end;-- INT::plus return false end; arg_local(i:INT):AM_LOCAL_EXPR is -- The local variable for the `i'th argument. 0 is self, the rest -- follow in order. return [i].expr end; --pSather attr is_fork_routine : BOOL; -- this routine implements the body of a fork attr is_par_routine : BOOL; -- this routine implements the body of a par attr is_attach_routine : BOOL; -- ... of an attach private attr n_import_locals : BOOL; private attr n_import_call : BOOL; private attr n_export_locals : BOOL; private attr n_export_call : BOOL; needs_import_locals is sig.needs_import := ~sig.is_forked; -- = true if ~is_forked-- AM_ROUT_DEF::sig SIG::needs_import AM_ROUT_DEF::sig SIG::is_forked BOOL::not n_import_locals := true -- AM_ROUT_DEF::n_import_locals end; needs_import_call is n_import_call := true end;-- AM_ROUT_DEF::n_import_call needs_import_locals:BOOL is return sig.needs_import end; import_locals_pending:BOOL is return n_import_locals end;-- AM_ROUT_DEF::n_import_locals import_call_pending:BOOL is return n_import_call end;-- AM_ROUT_DEF::n_import_call import_done is n_import_locals := false; n_import_call := false end;-- AM_ROUT_DEF::n_import_locals AM_ROUT_DEF::n_import_call needs_export_locals is sig.needs_export := ~sig.is_forked; -- = true if ~is_forked-- AM_ROUT_DEF::sig SIG::needs_export AM_ROUT_DEF::sig SIG::is_forked BOOL::not n_export_locals := true-- AM_ROUT_DEF::n_export_locals end; needs_export_call is n_export_call := true end;-- AM_ROUT_DEF::n_export_call needs_export_locals:BOOL is return sig.needs_export end; export_locals_pending:BOOL is return n_export_locals end;-- AM_ROUT_DEF::n_export_locals export_call_pending: BOOL is return n_export_call end;-- AM_ROUT_DEF::n_export_call export_done is n_export_locals := false; n_export_call := false end;-- AM_ROUT_DEF::n_export_locals AM_ROUT_DEF::n_export_call end;