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

-- am_out.sa: Print out AM representation for debugging.
-------------------------------------------------------------------
class AM_OUT is
   -- Output AM code for debugging purposes.

   AM_one_stmt(a:$AM) is
      typecase a when $AM_STMT then
	 n::=a.next;
	 a.next:=void;
	 AM_out(a);
	 a.next:=n;
      else
	 AM_out(a);
      end;
   end; 

   AM_out(a:$AM) is AM_out(a,0,0); end;

   AM_out(a:$AM,first:INT,indent:INT) is
      prindent(first);
      if void(a) then #OUT + "(void($AM))\n"; return end;
      #OUT+SYS::str_for_tp(SYS::tp(a))+"["+SYS::id(a)+"] ";
      typecase a
      when AM_OB_DEF then AM_OB_DEF_out(a,0,indent);
      when AM_ROUT_DEF then AM_ROUT_DEF_out(a,0,indent);
      when AM_ASSIGN_STMT then AM_ASSIGN_STMT_out(a,0,indent);
      when AM_COMMENT_STMT then AM_COMMENT_STMT_out(a,0,indent);
      when AM_IF_STMT then AM_IF_STMT_out(a,0,indent);
      when AM_LOOP_STMT then AM_LOOP_STMT_out(a,0,indent);
      when AM_BREAK_STMT then AM_BREAK_STMT_out(a,0,indent);
      when AM_RETURN_STMT then AM_RETURN_STMT_out(a,0,indent);
      when AM_YIELD_STMT then AM_YIELD_STMT_out(a,0,indent);
      when AM_CASE_STMT then AM_CASE_STMT_out(a,0,indent);
      when AM_TYPECASE_STMT then AM_TYPECASE_STMT_out(a,0,indent);
      when AM_PRE_STMT then AM_PRE_STMT_out(a,0,indent);
      when AM_POST_STMT then AM_POST_STMT_out(a,0,indent);
      when AM_INITIAL_STMT then AM_INITIAL_STMT_out(a,0,indent);
      when AM_ASSERT_STMT then AM_ASSERT_STMT_out(a,0,indent);
      when AM_INVARIANT_STMT then AM_INVARIANT_STMT_out(a,0,indent);
      when AM_PROTECT_STMT then AM_PROTECT_STMT_out(a,0,indent);
      when AM_RAISE_STMT then AM_RAISE_STMT_out(a,0,indent);	 
      when AM_EXPR_STMT then AM_EXPR_STMT_out(a,0,indent);
      when AM_LOCAL_EXPR then AM_LOCAL_EXPR_out(a,0,indent);
      when AM_ARRAY_EXPR then AM_ARRAY_EXPR_out(a,0,indent);
      when AM_BND_CREATE_EXPR then AM_BND_CREATE_EXPR_out(a,0,indent);
      when AM_IF_EXPR then AM_IF_EXPR_out(a,0,indent);
      when AM_NEW_EXPR then AM_NEW_EXPR_out(a,0,indent);
      when AM_IS_VOID_EXPR then AM_IS_VOID_EXPR_out(a,0,indent);	 	 
      when AM_SHARED_EXPR then AM_SHARED_EXPR_out(a,0,indent);
      when AM_ATTR_EXPR then AM_ATTR_EXPR_out(a,0,indent);
      when AM_VATTR_ASSIGN_EXPR then AM_VATTR_ASSIGN_EXPR_out(a,0,indent);
      when AM_VARR_ASSIGN_EXPR then AM_VARR_ASSIGN_EXPR_out(a,0,indent);	 	 
      when AM_EXCEPT_EXPR then AM_EXCEPT_EXPR_out(a,0,indent);	 	 
      when AM_STMT_EXPR then AM_STMT_EXPR_out(a,0,indent);	 	 
      when AM_CALL_ARG then AM_CALL_ARG_out(a,0,indent);
      when AM_FORMAL_ARG then AM_FORMAL_ARG_out(a,0,indent);
      when AM_ROUT_CALL_EXPR then AM_ROUT_CALL_EXPR_out(a,0,indent);
      when AM_ITER_CALL_EXPR then AM_ITER_CALL_EXPR_out(a,0,indent);
      when AM_BND_ROUT_CALL_EXPR then AM_BND_ROUT_CALL_EXPR_out(a,0,indent);
      when AM_BND_ITER_CALL_EXPR then AM_BND_ITER_CALL_EXPR_out(a,0,indent);
      when AM_EXT_CALL_EXPR then AM_EXT_CALL_EXPR_out(a,0,indent);
      when AM_VOID_CONST then AM_VOID_CONST_out(a,0,indent);
      when AM_ARR_CONST then AM_ARR_CONST_out(a,0,indent);
      when AM_BOOL_CONST then AM_BOOL_CONST_out(a,0,indent);
      when AM_CHAR_CONST then AM_CHAR_CONST_out(a,0,indent);
      when AM_STR_CONST then AM_STR_CONST_out(a,0,indent);
      when AM_INT_CONST then AM_INT_CONST_out(a,0,indent);
      when AM_INTI_CONST then AM_INTI_CONST_out(a,0,indent);
      when AM_FLT_CONST then AM_FLT_CONST_out(a,0,indent);
      when AM_FLTD_CONST then AM_FLTD_CONST_out(a,0,indent);
      when AM_FLTX_CONST then AM_FLTX_CONST_out(a,0,indent);
      when AM_FLTDX_CONST then AM_FLTDX_CONST_out(a,0,indent);
      when AM_FLTI_CONST then AM_FLTI_CONST_out(a,0,indent);
      --pSather
      when AM_ATTACH_STMT then AM_ATTACH_STMT_out(a,0,indent);
      when AM_FORK_STMT then AM_FORK_STMT_out(a,0,indent);
      when AM_PAR_STMT then AM_PAR_STMT_out(a,0,indent);	 
      when AM_LOCK_STMT then AM_LOCK_STMT_out(a,0,indent);
      when AM_UNLOCK_STMT then AM_UNLOCK_STMT_out(a,0,indent);
      when AM_WITH_NEAR_STMT then AM_WITH_NEAR_STMT_out(a,0,indent);
      when AM_SYNC_STMT then AM_SYNC_STMT_out(a,0,indent);
      when AM_PREFETCH_STMT then AM_PREFETCH_STMT_out(a,0,indent);
      when AM_WAITFOR_STMT then AM_WAITFOR_STMT_out(a,0,indent);
      --pSather
      when AM_HERE_EXPR then AM_HERE_EXPR_out(a,0,indent);
      when AM_ANY_EXPR then AM_ANY_EXPR_out(a,0,indent);
      when AM_WHERE_EXPR then AM_WHERE_EXPR_out(a,0,indent);
      when AM_NEAR_EXPR then AM_NEAR_EXPR_out(a,0,indent);
      when AM_FAR_EXPR then AM_FAR_EXPR_out(a,0,indent);
      when AM_AT_EXPR then AM_AT_EXPR_out(a,0,indent);
      when AM_CLUSTER_EXPR then AM_CLUSTER_EXPR_out(a,0,indent);
      when AM_CLUSTER_SIZE_EXPR then AM_CLUSTER_SIZE_EXPR_out(a,0,indent);	 
      end;
      typecase a 
      when $AM_STMT then
         if ~void(a.next) then AM_out(a.next,indent,indent); end;
      else end;
   end;
   
   private prindent(i:INT) is
      loop
         i.times!;
         #OUT+" ";
      end;
   end;

   private AM_OB_DEF_out(a:AM_OB_DEF,first:INT,indent:INT) is
      if void(a.tp) then #OUT + "void(tp) " 
      else #OUT + "tp=" + a.tp.str + " " end; #OUT + "\n";
      if void(a.at) then #OUT + "void(attributes)" 
      else
         #OUT+"\n";prindent(indent+11);
	 #OUT + "attributes= ";
	 loop p::=a.at.pairs!;
	    #OUT + "(" + p.t1.str + "->" + p.t2.str + ") " end end;
      #OUT+"\n";prindent(indent+11);
      #OUT + "(array type=";
      if void(a.arr) then #OUT + "void" else #OUT + a.arr.str end;
      #OUT + "\n" end;
   
   private AM_ROUT_DEF_out(a:AM_ROUT_DEF,first:INT,indent:INT) is
      if void(a.sig) then #OUT + " void(sig)";
      else #OUT + " sig=" + a.sig.str;
      end;
      if a.sig.needs_import then #OUT+" needs_import"; end;
      if a.sig.needs_export then #OUT+" needs_export"; end;
      if a.is_abstract then #OUT + " is abstract"; return; end;
      #OUT+"\n";
      if a.size>1 then
         prindent(indent+3);
	 #OUT + "args=";
	 AM_out(a[1],0,indent+8);
	 i:INT:=2;
	 loop 
	    AM_out(a[2.upto!(a.asize-1)],indent+8,indent+8);
	 end; 
      end;
      prindent(indent+3);
      if ~void(a.specul_prefetch) then #OUT+"prefetch: ";AM_out(a.specul_prefetch,indent+10,indent+10);#OUT+"\n";prindent(indent+3); end;
      if void(a.locals) then #OUT + "void(locals)\n";
      else 
         #OUT + "locals=";
	 i:INT:=0; 
	 AM_out(a.locals[0],indent+10,indent+10);
	 if a.locals.size>1 then 
	    loop;
	       AM_out(a.locals[1.upto!(a.locals.size-1)],indent+10,indent+10);
	    end;
	 end; 
      end;
      prindent(indent+3);
      if void(a.code) then #OUT + "void(code)\n";
      else #OUT + "code="; AM_out(a.code,0,indent+8);
      end;
   end;
   
   private AM_COMMENT_STMT_out(a:AM_COMMENT_STMT,first:INT,indent:INT) is
      #OUT + "/* "+a.comment+" */\n";
      end;
   
   private AM_ASSIGN_STMT_out(a:AM_ASSIGN_STMT,first:INT,indent:INT) is
      #OUT + "\n";
      prindent(indent+3);
      #OUT + "dest="; AM_out(a.dest,0,indent+8); 
      #OUT+"\n";
      prindent(indent+3);
      #OUT + "src= "; AM_out(a.src,0,indent+8);
      #OUT+"\n";
      end;
   
   private AM_IF_STMT_out(a:AM_IF_STMT,first:INT,indent:INT) is
      #OUT + "\n";
      prindent(indent+3);
      #OUT + "test=    "; AM_out(a.test,0,indent+12); #OUT+"\n";
      prindent(indent+3);
      #OUT + "if_true= "; AM_out(a.if_true,0,indent+12);
      prindent(indent+3);
      #OUT + "if_false="; AM_out(a.if_false,0,indent+12) end;
   
   private AM_LOOP_STMT_out(a:AM_LOOP_STMT,first:INT,indent:INT) is
      if a.has_yield then #OUT + " has_yield=true"
      else #OUT + " has_yield=false" end;
      #OUT+"\n";
      if ~void(a.its) then
	 prindent(indent+3);#OUT+"its=";
	 loop #OUT+",".separate!(a.its.elt!.fun.str); end;
	 #OUT+"\n";
      end;
      prindent(indent+3);#OUT+"init=";
      AM_out(a.init,0,indent+8);
      AM_out(a.body,indent+3,indent+3) end;
   
   private AM_BREAK_STMT_out(a:AM_BREAK_STMT,first:INT,indent:INT) is
      #OUT + "\n" end;
   
   private AM_RETURN_STMT_out(a:AM_RETURN_STMT,first:INT,indent:INT) is
      #OUT + "\n";
      prindent(indent+3);
      #OUT + "val="; AM_out(a.val,0,indent+7);
      #OUT+"\n";
   end; 

   private AM_YIELD_STMT_out(a:AM_YIELD_STMT,first:INT,indent:INT) is
      prindent(indent+3);#OUT + "ret=" + a.ret; #OUT+"\n";
      prindent(indent+3);#OUT + "val="; AM_out(a.val,0,indent+7); #OUT+"\n";
   end;
   
   private AM_CASE_STMT_out(a:AM_CASE_STMT,first:INT,indent:INT) is
      prindent(indent);
      #OUT + "test="; AM_out(a.test,0,indent+8); #OUT+"\n";
      prindent(indent+3);
      #OUT + "branches:\n";
      i:INT:=0;
      loop while!(i<a.tgts.size);
         prindent(indent+3);
	 #OUT + "cond: ";
	 j:INT:=0;
	 loop 
	    AM_OUT::AM_out(a.tgts[i].elt!);
	    #OUT+", ";
	 end;
	 #OUT + "\n";
	 prindent(indent+3);
	 #OUT+"code: ";
	 AM_out(a.stmts[i],0,indent+10);
	 i:=i+1;
      end;
      prindent(indent+3);
      #OUT + "else_stmts: "; AM_out(a.else_stmts,0,indent+15) 
   end;
   
   private AM_TYPECASE_STMT_out(a:AM_TYPECASE_STMT,first:INT,indent:INT) is
      prindent(indent+3);
      #OUT + "test="; AM_out(a.test,0,indent+8); #OUT+"\n";
      prindent(indent+3);
      #OUT + "branches:\n";
      i:INT:=0;
      loop while!(i<a.tgts.size);
         prindent(indent+3);
	 #OUT + "type: "+a.tgts[i].str+"\n";
	 AM_out(a.stmts[i],indent+6,indent+6);
	 i:=i+1;
      end;
      prindent(indent+3);
      #OUT+"else_stmts="; AM_out(a.else_stmts,0,indent+14);
   end;
   
   private AM_PRE_STMT_out(a:AM_PRE_STMT,first:INT,indent:INT) is
      if void(a) then #OUT + "void(AM_PRE_STMT)\n"; return end;
      #OUT + "AM_PRE_STMT";
      prindent(indent+3);
      #OUT + "test="; AM_out(a.test,0,indent+9); #OUT+"\n"; end;
   
   private AM_POST_STMT_out(a:AM_POST_STMT,first:INT,indent:INT) is
      #OUT + "\n";
      prindent(indent+3);
      #OUT + "test="; AM_out(a.test,0,indent+9); #OUT+"\n"; end;
   
   private AM_INITIAL_STMT_out(a:AM_INITIAL_STMT,first:INT,indent:INT) is
      #OUT + "\n";
      prindent(indent+3);
      #OUT + "stmts="; AM_out(a.stmts,0,indent+9);
   end;
   
   private AM_ASSERT_STMT_out(a:AM_ASSERT_STMT,first:INT,indent:INT) is
      #OUT + "\n";prindent(indent+3);
      #OUT + "test="; AM_out(a.test,0,indent+8);
      #OUT + "\n";
   end;
   
   private AM_INVARIANT_STMT_out(a:AM_INVARIANT_STMT,first:INT,indent:INT) is
      #OUT + "\n" end;
   
   private AM_PROTECT_STMT_out(a:AM_PROTECT_STMT,first:INT,indent:INT) is
      #OUT + "\n";
      prindent(indent+3);
      #OUT + "body="; AM_out(a.body,0,indent+8); 
      prindent(indent+3);
      #OUT + "branches:\n";
      i:INT:=0;
      loop while!(i<a.tgts.size);
         prindent(indent+3);
	 #OUT + "type: "+a.tgts[i].str+"\n";
	 AM_out(a.stmts[i],indent+6,indent+6);
	 i:=i+1;
      end;
      prindent(indent+3);
      #OUT+"else_stmts="; AM_out(a.else_stmts,0,indent+14);
   end;

   private AM_RAISE_STMT_out(a:AM_RAISE_STMT,first:INT,indent:INT) is
      #OUT + " val="; AM_out(a.val,0,indent+18);#OUT+"\n"; end;
   
   private AM_EXPR_STMT_out(a:AM_EXPR_STMT,first:INT,indent:INT) is
      #OUT + "\n";
      prindent(indent+3);
	#OUT + "expr="; AM_out(a.expr,0,indent+8);#OUT+"\n"; end;
   
   private AM_SYNC_STMT_out(a:AM_SYNC_STMT,first:INT,indent:INT) is
      #OUT+"\n";
   end;

   private AM_PREFETCH_STMT_out(a:AM_PREFETCH_STMT,first:INT,indent:INT) is
      #OUT + "   prefetch=";AM_out(a.prefetch,0,indent+29);
      #OUT+"\n";
      prindent(indent+3);
      #OUT + "dest="; AM_out(a.dest,0,indent+8); 
      #OUT+"\n";
      prindent(indent+3);
      #OUT + "src= "; AM_out(a.src,0,indent+8);
      #OUT+"\n";
   end;

   private AM_WAITFOR_STMT_out(a:AM_WAITFOR_STMT,first:INT,indent:INT) is
      #OUT + "   prefetch=";AM_out(a.prefetch,0,indent+29);
      #OUT+"\n";
   end;

   private AM_ATTACH_STMT_out(a:AM_ATTACH_STMT,first:INT,indent:INT) is
     --pSather
      #OUT + "\n";prindent(indent+3);
      #OUT + "routine=" + a.rout.str + "\n";prindent(indent+3);
      #OUT + "helper= ";  AM_out(a.helper,0,indent+11); #OUT+"\n";prindent(indent+3);
      #OUT + "gate=   ";  AM_out(a.gate,0,indent+11); #OUT+"\n";prindent(indent+3);
      #OUT + "at=     ";
      if void(a.at) then #OUT+" any" else AM_out(a.at,0,indent+11); end;
      #OUT+"\n";
   end;

   private AM_PAR_STMT_out(a:AM_PAR_STMT,first:INT,indent:INT) is
     --pSather
      #OUT + "\n";prindent(indent+3);#OUT+"body=";
      AM_out(a.body, indent+3, indent+3);
   end;
   
   private AM_FORK_STMT_out(a:AM_FORK_STMT,first:INT,indent:INT) is
     --pSather
      #OUT + "\n";prindent(indent+3);
      #OUT+"at=     ";
      if void(a.at) then #OUT+" any" else AM_out(a.at,0,indent+11); end;
      #OUT+"body=   ";
      AM_out(a.body, 0, indent+11);
   end;   
   
   private AM_LOCK_STMT_out(a:AM_LOCK_STMT,first:INT,indent:INT) is
      --pSather
      #OUT + "\n";
      prindent(indent+3);
      i:INT:=0;
      loop while!(i<a.guards.size);
	 #OUT + "GUARD ";
	 AM_out(a.guards[i],0,9);
	 #OUT + "\n";
	 prindent(indent+3);
	 #OUT+"LOCK  ";
	 loop lck::=a.locks[i].elt!;
	    AM_out(lck,0,indent+9);#OUT+", ";
	 end;
	 #OUT + "\n";
	 prindent(indent+3);
	 #OUT + "THEN  ";
	 AM_out(a.stmts[i],0,indent+9);
	 #OUT+"\n";
	 i := 1+ 1;
      end;
      #OUT+"ELSE_STMT "; AM_out(a.else_stmts,0,13);
   end;
      
   private AM_UNLOCK_STMT_out(a:AM_UNLOCK_STMT,first:INT,indent:INT) is
      --pSather
--      #OUT + " expr="; AM_out(a.lock) 
   end;
      
   private AM_WITH_NEAR_STMT_out(a:AM_WITH_NEAR_STMT,first:INT,indent:INT) is
      --pSather
      #OUT + "\n";
      prindent(indent+3);
      #OUT + "near="; AM_out(a.near_part,0,indent+8);
      prindent(indent+3);
      #OUT + "else="; AM_out(a.else_part,0,indent+8);
   end;
      
   private AM_LOCAL_EXPR_out(a:AM_LOCAL_EXPR,first:INT,indent:INT) is
      if void(a.name) and void(a.tp_at) then
	 #OUT + "noname:notype"
      elsif void(a.name) then
	 #OUT + "noname:" + a.tp_at.str;
      elsif void(a.tp_at) then 
	 #OUT + a.name.str + ":notype";
      else #OUT + a.name.str + ":" + a.tp_at.str;
      end;
      #OUT+"  is_near:"+a.is_near;
   end;	 
   
   private AM_ARRAY_EXPR_out(a:AM_ARRAY_EXPR,first:INT,indent:INT) is
      #OUT + " tp=" + a.tp_at.str+" |";
      loop i::=a.ind!;
         if i/=0 then #OUT + "), ";
	 else #OUT+"(";
	 end;
	 AM_out(a.elt!,0,0);
       end;
      #OUT+")|";
   end;
   
   private AM_BND_CREATE_EXPR_out(a:AM_BND_CREATE_EXPR,first:INT,indent:INT) is
      #OUT + "\n";
      prindent(indent+3);
      #OUT + "args=(";
      loop i::=a.ind!; 
	 if i/=0 then #OUT + " " end; 
	 AM_out(a[i]);
      end;
      #OUT + ")\n";
      prindent(indent+3);
      #OUT + "fun=" + a.fun.str+"\n"; 
      #OUT + "bnd_args=";
      loop j::=a.bnd_args.ind!;
	 if j/=0 then #OUT + " " end; 	 
	 #OUT + a.bnd_args[j] end;
      #OUT + "\n";
      prindent(indent+3);
      #OUT+"unbnd_args=";
      loop j::=a.unbnd_args.ind!;
	 if j/=0 then #OUT + " " end; 	 
	 #OUT + a.unbnd_args[j] end;
      #OUT + "\n";
      prindent(indent+3);
      #OUT + "tp_at=" + a.tp_at.str end;
   
   private AM_IF_EXPR_out(a:AM_IF_EXPR,first:INT,indent:INT) is
      #OUT + "\n";
      prindent(indent+3);
      #OUT + "test=    "; AM_out(a.test,0,indent+12);
      #OUT+"\n";prindent(indent+3);
      #OUT + "if_true= "; AM_out(a.if_true,0,indent+12);
      #OUT+"\n";prindent(indent+3);
      #OUT + "if_false="; AM_out(a.if_false,0,indent+12);
   end;
   
   private AM_NEW_EXPR_out(a:AM_NEW_EXPR,first:INT,indent:INT) is
      #OUT + "asz="; AM_out(a.asz,0,indent+16);
   end;
   
   private AM_IS_VOID_EXPR_out(a:AM_IS_VOID_EXPR,first:INT,indent:INT) is
      #OUT + "arg="; AM_out(a.arg,0,indent+20); 
   end;
   
   private AM_SHARED_EXPR_out(a:AM_SHARED_EXPR,first:INT,indent:INT) is
      #OUT + "name=";
      if void(a.name) then #OUT + "void" else #OUT + a.name.str end;
      #OUT + " tp=";
      if void(a.tp_at) then #OUT + "void" else #OUT + a.tp_at.str end;
      #OUT + " class_tp=";
      if void(a.class_tp) then #OUT + "void" else 
	 #OUT + a.class_tp.str end;
--#      if void(a.invar_ent) then 
--#         #OUT+" invar=void";
--#      else
--#         #OUT+" invar/=void";
--#      end;
      #OUT+"\n";prindent(indent+3);
      #OUT + "init="; AM_out(a.init,0,indent+8);
   end;
   
   private AM_ATTR_EXPR_out(a:AM_ATTR_EXPR,first:INT,indent:INT) is
      #OUT + " ob="; AM_out(a.ob,0,0);                         
      #OUT + " ob_is_near="+a.ob.is_near;
      #OUT + " at=" + a.at.str;
      #OUT + " self_tp=" + a.self_tp.str;       
      #OUT + " tp=" + a.tp_at.str;
      #OUT + " is_near=" + a.is_near;
   end;
   
   private AM_VATTR_ASSIGN_EXPR_out(a:AM_VATTR_ASSIGN_EXPR,first:INT,indent:INT) is
      if void(a.ob) then #OUT + " void(ob)";            
      else #OUT + " ob="; AM_out(a.ob,0,0) end;                         
      if void(a.at) then #OUT + " void(at)";
      else #OUT + " at=" + a.at.str end;
      if void(a.val) then #OUT + " void(val)";
      else #OUT + " val="; AM_out(a.val,0,0) end end;      

   private AM_VARR_ASSIGN_EXPR_out(a:AM_VARR_ASSIGN_EXPR,first:INT,indent:INT) is
      if void(a.ob) then #OUT + " void(ob)";      
      else #OUT + " ob="; AM_out(a.ob,0,0) end;                         
      if void(a.ind) then #OUT + " void(ind)";
      else #OUT + " ind="; AM_out(a.ind,0,0) end;
      if void(a.val) then #OUT + " void(val)";
      else #OUT + " val="; AM_out(a.val,0,0) end end;

   private AM_EXCEPT_EXPR_out(a:AM_EXCEPT_EXPR,first:INT,indent:INT) is
   end;

   private AM_STMT_EXPR_out(a:AM_STMT_EXPR,first:INT,indent:INT) is
      #OUT + "\n";
      prindent(indent+3);
      if void(a.stmts) then #OUT + " void(stmts)";      
      else #OUT + "stmts="; AM_out(a.stmts,0,indent+9) end;
      prindent(indent+3);
      if void(a.expr) then #OUT + " void(expr)";
      else 
	 #OUT + "is_near= "+a.is_near+"\n";prindent(indent+3);
         #OUT + "expr= "; AM_out(a.expr,0,indent+9) end end;

   private AM_HERE_EXPR_out(a:AM_HERE_EXPR,first:INT,indent:INT) is
      --pSather
   end;
      
   private AM_ANY_EXPR_out(a:AM_ANY_EXPR,first:INT,indent:INT) is
      --pSather
      end;
      
   private AM_WHERE_EXPR_out(a:AM_WHERE_EXPR,first:INT,indent:INT) is
      --pSather
      #OUT + " expr="; AM_out(a.arg,0,indent+19); end;
      
   private AM_NEAR_EXPR_out(a:AM_NEAR_EXPR,first:INT,indent:INT) is
      --pSather
      #OUT + " expr="; AM_out(a.arg,0,indent+18); end;
      
   private AM_FAR_EXPR_out(a:AM_FAR_EXPR,first:INT,indent:INT) is
      --pSather
      #OUT + " expr="; AM_out(a.arg,0,17); end;
      
   private AM_AT_EXPR_out(a:AM_AT_EXPR,first:INT,indent:INT) is
      --pSather
      #OUT + " expr="; AM_out(a.e,0,indent+15); 
      #OUT + " at="; AM_out(a.at,0,0); end;
      
   private AM_CLUSTER_EXPR_out(a:AM_CLUSTER_EXPR,first:INT,indent:INT) is
      --pSather
   end;
   
   private AM_CLUSTER_SIZE_EXPR_out(a:AM_CLUSTER_SIZE_EXPR,first:INT,indent:INT) is
      --pSather
      #OUT + "cluster_size";
      end;   
         
   private AM_CALL_ARG_out(a:AM_CALL_ARG, first:INT, indent:INT) is
	#OUT + " (";
	#OUT + " mode=" + a.mode.str; 
	#OUT + " expr="; 
	AM_out(a.expr,0,indent+8); 
	#OUT + ")";
   end;

   private AM_FORMAL_ARG_out(a:AM_FORMAL_ARG, first:INT, indent:INT) is
	#OUT + " (";
	#OUT + " mode=" + a.mode.str; 
	#OUT + " expr="; 
	AM_out(a.expr,0,indent+8); 
	#OUT + ")";
   end;

   private AM_ROUT_CALL_EXPR_out(a:AM_ROUT_CALL_EXPR,first:INT,indent:INT) is
      #OUT + " fun=" + a.fun.str+"\n";
      prindent(indent+3);
      #OUT + "args=";
      loop i::=a.ind!;
         if i/=0 then prindent(indent+8); end;
         AM_out(a.elt!,0,indent+8);
	 #OUT+"\n";
      end;
   end;
   
   private AM_ITER_CALL_EXPR_out(a:AM_ITER_CALL_EXPR,first:INT,indent:INT) is
      #OUT + "fun=" + a.fun.str+"   init_before_loop="+a.init_before_loop+"\n";
      prindent(indent+3);
      #OUT + "init="; AM_out(a.init,0,indent+8);
      prindent(indent+3);
      #OUT + "args=";
      loop i::=a.ind!;
         if i/=0 then prindent(indent+8); end;
         AM_out(a.elt!,0,indent+8);
	 #OUT+"\n";
      end;
   end;

   private AM_BND_ROUT_CALL_EXPR_out(a:AM_BND_ROUT_CALL_EXPR,first:INT,indent:INT) is
      prindent(indent+3);
      #OUT + "br="; AM_out(a.br); #OUT+"\n";
      prindent(indent+3);
      #OUT + "args=";
      loop i::=a.ind!;
         if i/=0 then prindent(indent+8); end;
         AM_out(a.elt!,0,indent+8);
	 #OUT+"\n";
      end;
   end;
   
   private AM_BND_ITER_CALL_EXPR_out(a:AM_BND_ITER_CALL_EXPR,first:INT,indent:INT) is
      #OUT + "bi="; AM_out(a.bi,0,indent+25);#OUT+"\n";
      prindent(indent+3);
      #OUT + "init="; AM_out(a.init,0,indent+8);   
      prindent(indent+3);
      #OUT + "args=";
      loop i::=a.ind!;
         if i/=0 then prindent(indent+8); end;
         AM_out(a.elt!,0,indent+8);
	 #OUT+"\n";
      end;
   end;
   
   private AM_EXT_CALL_EXPR_out(a:AM_EXT_CALL_EXPR,first:INT,indent:INT) is
      #OUT + "fun=" + a.fun.str+"\n";
      prindent(indent+3);
      #OUT + "args=";
      loop i::=a.ind!;
         if i/=0 then prindent(indent+8); end;
         AM_out(a.elt!,0,indent+8);
	 #OUT+"\n";
      end;
   end;
   
   private AM_VOID_CONST_out(a:AM_VOID_CONST,first:INT,indent:INT) is
      if void(a.tp_at) then #OUT + "void" else 
	 #OUT + a.tp_at.str;  end;  end;
   
   private AM_ARR_CONST_out(a:AM_ARR_CONST,first:INT,indent:INT) is
      #OUT + "elt_tp=" + a.elt_tp.str+"\n";
      prindent(indent+3);
      #OUT + "elts=";
      loop AM_out(a.elts.elt!) end end;                  
   
   private AM_BOOL_CONST_out(a:AM_BOOL_CONST,first:INT,indent:INT) is
      if a.val then #OUT + "val=true" 
      else #OUT + " val=false" end end;
   
   private AM_CHAR_CONST_out(a:AM_CHAR_CONST,first:INT,indent:INT) is
      #OUT + "bval='" + a.bval + "'" end;
   
   private AM_STR_CONST_out(a:AM_STR_CONST,first:INT,indent:INT) is
      #OUT + "bval=" + a.bval end;
   
   private AM_INT_CONST_out(a:AM_INT_CONST,first:INT,indent:INT) is
      #OUT + "val=" + a.val end;
   
   private AM_INTI_CONST_out(a:AM_INTI_CONST,first:INT,indent:INT) is
      #OUT + "val=" +  a.val.str end;
   
   private AM_FLT_CONST_out(a:AM_FLT_CONST,first:INT,indent:INT) is
      #OUT + "val=" + a.val.str end;
   
   private AM_FLTD_CONST_out(a:AM_FLTD_CONST,first:INT,indent:INT) is
      #OUT + "val=" + a.val.str end;
   
   private AM_FLTX_CONST_out(a:AM_FLTX_CONST,first:INT,indent:INT) is
      #OUT + "val=" + a.val.str end;      
   
   private AM_FLTDX_CONST_out(a:AM_FLTDX_CONST,first:INT,indent:INT) is
      #OUT + "val=" + a.val.str end;      
   
   private AM_FLTI_CONST_out(a:AM_FLTI_CONST,first:INT,indent:INT) is
      #OUT + "val=" + a.val.str end;      
   
end; -- class AM_OUT

-------------------------------------------------------------------
-- vim:sw=3:nosmartindent
