as.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. <----------
-- as.sa: The Abstract Syntax tree representation for the Sather compiler.
-- $AS_NODE: Supertype of all abstract syntax tree nodes.
-- AS_NODE: Implementation to be included by $AS_NODE nodes.
--
-- AS_CLASS_DEF: Class definitions.
--
-- Other tree components: AS_PARAM_DEC, AS_TYPE_SPEC,
-- AS_ARG_DEC, AS_FEAT_MOD, AS_CASE_WHEN, AS_TYPECASE_WHEN,
-- AS_PROTECT_WHEN
--
-- Each tree node class descends from $AS_NODE and has a name starting
-- with AS_. The rest of the name is the name of the corresponding
-- grammar production from the 1.0 spec using the suffixes:
-- "_DEC" for declarations, "_DEF" for definitions, "_ELT" for elements,
-- "_EXPR" for expressions, "_LIST" for lists, "_SPEC" for
-- specifications, "_STMT" for statements
--
-- Single classes sometimes represent several productions.
-- Whenever a comment says "if any" that means that "void" is a possible
-- value and it indicates the the component was not present.
--
abstract class $AS_NODE < $PROG_ERR
abstract class $AS_NODE < $PROG_ERR is
-- A supertype of all nodes in the tree representation.
source:SFILE_ID;
source(s:SFILE_ID);
--am_node(a:$AM); -- MP
--am_node:$AM;
end;
class AS_NODE
class AS_NODE is
-- A supertype of all nodes in the tree representation.
attr source:SFILE_ID; -- The origin of a node in a Sather
-- source file.
--attr am_node:$AM; -- MP
create: SAME is
-- A new object with default initialization.
return new end;
end; -- class AS_NODE
class AS_CLASS_DEF < $AS_NODE
class AS_CLASS_DEF < $AS_NODE is
-- The definition of a class.
include AS_NODE;
include NEXT{SAME}; -- Next class in the list.
const unused:INT:=0;
const imm:INT:=1; -- Value class.
const ref:INT:=2; -- Reference class.
const abs:INT:=3; -- Abstract class.
const part:INT:=4; -- Partial class.
const c_ext:INT:=5; -- External C class.
const fortran_ext:INT:=6; -- External Fortran class
const spr:INT:=7; -- Spread class (pSather).
attr kind:INT; -- One of imm, ref, abs, ext.
attr name:IDENT; -- Name of the class.
attr params:AS_PARAM_DEC; -- List of parameter declarations,
-- if any.
attr under:AS_TYPE_SPEC; -- List of parents in the type graph.
attr over:AS_TYPE_SPEC; -- List of over children in the type graph.
attr body:$AS_CLASS_ELT; -- The body of the class.
end;
class AS_PARAM_DEC < $AS_NODE
class AS_PARAM_DEC < $AS_NODE is
-- The declaration of a parameter for a class.
include AS_NODE;
include NEXT{SAME}; -- Next parameter, if any.
attr name:IDENT; -- Index of parameter name.
attr type_constraint:AS_TYPE_SPEC; -- Type constraint for type,
-- if any.
end;
class AS_TYPE_SPEC < $AS_NODE
class AS_TYPE_SPEC < $AS_NODE is
-- A type specifier.
include AS_NODE;
include NEXT{SAME}; -- Next parameter, if any.
const ord:INT:=0; -- Abstract, immutable, reference, partial
-- or external.
const rt:INT:=1; -- Bound routine type.
const it:INT:=2; -- Bound iter type.
const same:INT:=3; -- "SAME".
attr kind:INT; -- One of ord, rt, it, or same.
attr is_hot:BOOL; -- True if this is a specifier
-- for a hot bound iter argument type.
attr name:IDENT; -- Name of the type, void for bound types.
attr params:AS_TYPE_SPEC; -- For ordinary types, these are the
-- parameters specifiers, if any. For bound types, these are the
-- argument type specifiers.
attr mode:AS_ARG_MODE; -- Argument mode for bound types
attr ret:AS_TYPE_SPEC; -- Return type spec for bound types.
end;
class AS_ARG_MODE
class AS_ARG_MODE is
-- argument modes
include NEXT{SAME}; -- mode of the next arg
readonly shared in_mode:INT := 1;
readonly shared out_mode:INT := 2;
readonly shared inout_mode:INT := 3;
readonly shared once_mode:INT := 4;
attr mod:INT;
create(m: INT): SAME is
res ::= new;
res.mod := m;-- AS_ARG_MODE::mod
return res;
end;
is_out_inout : BOOL is
if mod = out_mode or mod = inout_mode then-- AS_ARG_MODE::mod AS_ARG_MODE::out_mode AS_ARG_MODE::mod AS_ARG_MODE::inout_mode
return true;
else
return false;
end;
end;
end;