------------------------->  GNU Sather - sourcefile  <-------------------------
-- Copyright (C) 1995 by International Computer Science Institute            --
-- This file is part of the GNU Sather package. It is free software; you may --
-- redistribute  and/or modify it under the terms of the  GNU General Public --
-- License (GPL)  as  published  by the  Free  Software  Foundation;  either --
-- version 2 of the license, or (at your option) any later version.          --
-- This  program  is distributed  in the  hope that it will  be  useful, but --
-- WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/GPL for more details.        --
-- The license text is also available from:  Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                     --
-------------->  Please email comments to <bug-sather@gnu.org>  <--------------

-- $AS_STMT: Supertype of routine or iter statement nodes.
-- AS_STMT: Implementation to be included by $AS_STMT nodes.
-- AS_STMT_LIST
-- AS_DEC_STMT, AS_ASSIGN_STMT, AS_IF_STMT, AS_LOOP_STMT,
-- AS_RETURN_STMT, AS_YIELD_STMT, AS_QUIT_STMT, AS_CASE_STMT,
-- AS_TYPECASE_STMT, AS_ASSERT_STMT, AS_PROTECT_STMT, AS_RAISE_STMT, 
-- AS_EXPR_STMT, AS_LOCK_STMT, AS_UNLOCK_STMT, AS_INTERF_ATTACH_STMT,
-- AS_WITH_NEAR_STMT, AS_IDENT_LIST, AS_ATTACH_STMT,
-- AS_FORK_STMT, AS_PAR_STMT, AS_LOCK_IF_WHEN, AS_SYNC_STMT
--
-- 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_STMT < $AS_NODE, $NEXT{$AS_STMT} is
   -- A supertype of all routine or iter statement nodes.

   surr_stmt_list : AS_STMT_LIST;
   surr_stmt_list(l:AS_STMT_LIST);

   transformed : BOOL;    -- During pSather transformation of several
   transformed(set:BOOL); -- tr nodes new nodes are added to the tree.
                          -- If a tr node is in a parameterized class
                          -- this node gets transformed for each
                          -- instantiation of the parameter.
                          -- However, the new nodes must be created
                          -- only once.
end;

-------------------------------------------------------------------   
class AS_STMT < $AS_STMT is
   -- A supertype of all routine or iter statement nodes.
   include AS_NODE;
   include NEXT{$AS_STMT};	-- The next statement in the list.

   attr surr_stmt_list : AS_STMT_LIST;
   attr transformed : BOOL;
end;

-------------------------------------------------------------------   
class AS_STMT_LIST < $AS_NODE is
   include AS_NODE;
   attr stmts : $AS_STMT;
end;

-------------------------------------------------------------------
class AS_DEC_STMT < $AS_STMT is
   -- A local declaration statement. Parser should make one of these
   -- for each element in a list like "a,b,c:FOO".
   include AS_STMT;
   
   attr name:IDENT;		-- Name of the local.
   attr tp:AS_TYPE_SPEC;	-- The type of the local.
end;
   
-------------------------------------------------------------------
class AS_ASSIGN_STMT < $AS_STMT is
   -- An assignment statement.
   include AS_STMT;
   
   attr lhs_expr:$AS_EXPR;	-- Lhs expr if no declaration.
   attr name:IDENT;		-- Name, for declaration (::= or :FOO:=).
   attr tp:AS_TYPE_SPEC;	-- Type, for declaration (:FOO:=).   
   attr rhs:$AS_EXPR;		-- Righthand side.
end;

-------------------------------------------------------------------
class AS_IF_STMT < $AS_STMT is
   -- An "if" statement.
   include AS_STMT;
   
   attr test:$AS_EXPR;		-- Boolean expression to test.
   attr then_part:AS_STMT_LIST;	-- Statements to execute if true, if any.
   attr else_part:AS_STMT_LIST;	-- "Else" part, if any.
end;

-------------------------------------------------------------------
class AS_LOOP_STMT < $AS_STMT is
   -- A "loop" statement.
   include AS_STMT;
   
   attr body:AS_STMT_LIST;		-- The body of the loop, if any.
end;
   
-------------------------------------------------------------------
class AS_RETURN_STMT < $AS_STMT is
   -- A "return" statement.
   include AS_STMT;
   
   attr val:$AS_EXPR;		-- Return value, if any.
end;
   
-------------------------------------------------------------------
class AS_YIELD_STMT < $AS_STMT is
   -- A "yield" statement.
   include AS_STMT;
   
   attr val:$AS_EXPR;		-- Yield value, if any.   
end;

-------------------------------------------------------------------
class AS_QUIT_STMT < $AS_STMT is
   -- A "quit" statement.
   include AS_STMT;
end;

-------------------------------------------------------------------   
class AS_CASE_STMT < $AS_STMT is
   -- A "case" statement.
   include AS_STMT;
   
   attr test:$AS_EXPR;		-- The expression to test.
   attr when_part:AS_CASE_WHEN;	-- The list of "when" clauses.
   attr else_part:AS_STMT_LIST;	-- The "else" part.
   attr no_else:BOOL;		-- True if there is no "else" part.   
end;

-------------------------------------------------------------------
class AS_CASE_WHEN < $AS_NODE is
   -- A "when" clause of a "case" statement. The parser should make
   -- one of these for each object listed, eg. "when a,b,c then".
   -- When there are multiple targets, the `then_part's should be
   -- pointers to the same object.
   include AS_NODE;
   include NEXT{SAME};			-- Other clauses, if any.
   
   attr val:$AS_EXPR;		-- A value to compare against.
   attr then_part:AS_STMT_LIST;	-- The statements to execute.
end;

-------------------------------------------------------------------
class AS_TYPECASE_STMT < $AS_STMT is
   -- A "typecase" statement. Parser should put any declaration or
   -- assignment in a separate object before this.
   include AS_STMT;
   
   attr name:IDENT;		-- The local to switch on.
   attr when_part:AS_TYPECASE_WHEN; -- The list of "when" clauses.
   attr else_part:AS_STMT_LIST;	-- The "else" part.
   attr no_else:BOOL;		-- True if there is no "else" part.
end;
   
-------------------------------------------------------------------
class AS_TYPECASE_WHEN < $AS_NODE, $NEXT{AS_TYPECASE_WHEN} is
   -- A "when" clause of a "typecase" statement. 
   include AS_NODE;
   include NEXT{SAME};			-- Other clauses, if any.
   
   attr tp:AS_TYPE_SPEC;	-- A type to compare against.
   attr then_part:AS_STMT_LIST;	-- The statements to execute.
end;

-------------------------------------------------------------------
class AS_ASSERT_STMT < $AS_STMT is
   -- An "assert" statement.
   include AS_STMT;
   
   attr test:$AS_EXPR;		-- The boolean expression to test.
end;

-------------------------------------------------------------------
class AS_PROTECT_STMT < $AS_STMT is
   -- A "protect" statement.
   include AS_STMT;
   
   attr body:AS_STMT_LIST;		-- The statements to protect.
   attr when_part:AS_PROTECT_WHEN; -- The "when" parts.
   attr else_part:AS_STMT_LIST;	-- The "else" parts.
   attr no_else:BOOL;		-- True if there is no "else" part.   
end;

-------------------------------------------------------------------
class AS_PROTECT_WHEN < $AS_NODE is
   -- The "when" part of a "protect" statement.
   include AS_NODE;
   include NEXT{SAME};

   attr tp:AS_TYPE_SPEC;	-- The types to check.
   attr then_part:AS_STMT_LIST;	-- The statements to execute.
end;

-------------------------------------------------------------------

class AS_PAR_STMT < $AS_STMT is
   -- A "par" statement. (pSather)
   include AS_STMT;
   
   attr body: AS_STMT_LIST;
   attr helper_class : IDENT;
   attr rout: AS_ROUT_DEF;  -- Pointer to replacing routine
   

end;

-------------------------------------------------------------------

class AS_INTERF_ATTACH_STMT < $AS_STMT is
   -- pSather
   -- fork, par, and attach will be transformed into AS_INTERF_ATTACH.

   include AS_STMT;
   
   attr routname: IDENT;  
   attr helpername : IDENT;
   attr gatename : IDENT;
   attr at : $AS_EXPR;
  
end;

-------------------------------------------------------------------
class AS_LOCK_STMT < $AS_STMT is
   -- A "lock" statement. (pSather)
   include AS_STMT;
   
   attr e_list: $AS_EXPR;      -- The expressions to be locked.
   attr then_part: AS_STMT_LIST;
   
   attr if_when_part:AS_LOCK_IF_WHEN;	-- The list of "if - when" clauses.
   attr else_part:AS_STMT_LIST;	-- The "else" part.
   attr no_else:BOOL;		-- True if there is no "else" part.   
   
end;
   
-------------------------------------------------------------------
class AS_LOCK_IF_WHEN < $AS_NODE is
   -- A "if - when" clause of a "lock" statement. The parser should make
   -- one of these for each object listed, eg. "if x when a,b,c then".

   include AS_NODE;
   include NEXT{SAME};		-- Other clauses, if any.
   
   attr val:$AS_EXPR;		-- the guard.
   attr e_list: $AS_EXPR;       -- the expressions to be locked.
   attr then_part:AS_STMT_LIST;	-- The statements to execute.
   elts_size:INT is
      if void(e_list) then return 0
      else return e_list.size
      end
   end;
end;

-------------------------------------------------------------------
class AS_UNLOCK_STMT < $AS_STMT is
   -- A "unlock" statement. (pSather)
   include AS_STMT;
   
   attr e: $AS_EXPR;      -- The expression to be unlocked.
end;

-------------------------------------------------------------------
class AS_SYNC_STMT < $AS_STMT is
   -- A "sync" statement.
   include AS_STMT;
   
end;

-------------------------------------------------------------------
class AS_WITH_NEAR_STMT < $AS_STMT is
   -- A "with_near" statement. (pSather)
   include AS_STMT;
   
   attr elts_size: INT;   -- is computed during parse.
   
   attr idents: AS_IDENT_LIST;
   attr self_occurred : BOOL;
   attr near_part: AS_STMT_LIST;
   attr else_part: AS_STMT_LIST;
end;

-------------------------------------------------------------------   
class AS_IDENT_LIST < $AS_NODE is
   -- A list of identifiers. Used to represent the ident_list of
   -- a with_near statement.
   include AS_NODE;
   include NEXT{SAME};			-- Other clauses, if any.
   
   attr name: IDENT
end;

-------------------------------------------------------------------
class AS_ATTACH_STMT < $AS_STMT is
   -- An assignment statement. (pSather)
   include AS_STMT;
   
   attr lhs:$AS_EXPR;     -- Lhs (Gate) expr.
   attr rhs:$AS_EXPR;     -- Right hand side.
   attr dont_print:BOOL;  -- while AS_out
   attr helper_class : IDENT;
   attr rout : AS_ROUT_DEF; -- Pointer to replacing routine
end;

-------------------------------------------------------------------
class AS_FORK_STMT < $AS_STMT is
   -- A "fork" statement (pSather)
   include AS_STMT;

   attr body: AS_STMT_LIST;                 -- The statements to execute.
   attr at   : $AS_EXPR;
   attr helper_class : IDENT;
   attr rout : AS_ROUT_DEF;  -- Pointer to replacing routine

end;

-------------------------------------------------------------------
class AS_RAISE_STMT < $AS_STMT is
   -- A "raise" statement.
   include AS_STMT;
   
   attr val:$AS_EXPR;		-- The exception object.
end;

-------------------------------------------------------------------   
class AS_EXPR_STMT < $AS_STMT is
   -- A "expression" statement.
   include AS_STMT;
   
   attr e: $AS_EXPR;		-- The expression.

   --pSather
  attr at:$AS_EXPR;             -- Computed during pSather Trafo
end;
   
