m3tk/src/ast/seq.tmpl


%************************************************************************
%		                                                        *
%*                                                                      *
%*         Copyright 1994 Sun Microsystems, Inc. All Rights Reserved.   *
%*                                                                      *
%*      Permission to use, copy, modify, and distribute this software   *
%*      and its documentation for any purpose and without fee is hereby *
%*      granted, provided that the above copyright notice appear in all *
%*      copies and that both that copyright notice and this permission  *
%*      notice appear in supporting documentation, and that the name of *
%*      Sun Microsystems, Inc. (SMI) not be used in advertising or      *
%*      publicity pertaining to distribution of the software without    *
%*      specific, written prior permission.                             *
%*                                                                      *
%*                                                                      *
%*      SMI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,      *
%*      INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY,	        *
%*      FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.           *
%*      IN NO EVENT SHALL SMI BE LIABLE FOR ANY SPECIAL, INCIDENTAL,    *
%*	INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER     *
%*      RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN      *
%*      ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,        *
%*      ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE     *
%*      OF THIS SOFTWARE.                                               *
%*                                                                      *
%***********************************************************************)

% quake functions to instantiate am AST sequence

readonly proc Seq (view, nm) is
  local elt = "M3AST_" & view & "_" & nm
  local seq = "Seq" & elt
  build_generic_intf (seq, "SeqElem", [elt], VISIBLE)
  ex_build_generic_impl (seq, "SeqElem", [elt])
  build_generic_intf (seq & "_rep", "SeqElem_rep", [seq, elt], VISIBLE)
  build_T_interface(view, nm, VISIBLE)
end

readonly proc seq (view, nm) is
  local elt = "M3AST_" & view & "_" & nm
  local seq = "Seq" & elt
  build_generic_intf (seq, "SeqElem", [elt], HIDDEN)
  ex_build_generic_impl (seq, "SeqElem", [elt])
  build_generic_intf (seq & "_rep", "SeqElem_rep", [seq, elt], HIDDEN)
  build_T_interface(view, nm, HIDDEN)
end

readonly proc ex_build_generic_impl (nm, generic, args) is
  local file = nm & ".m3"
  local tmp  = ".generic.tmp"
  local sep  = ""
  if defined ("_all")
    > tmp in
      write ("(*generated by m3build*)", CR, CR)
      write ("MODULE ", nm, " EXPORTS ", nm, ", ", nm & "_rep", CR,
             "     = ", generic, " (")
      foreach f in args
        write (sep, f)
        sep = ", "
      end
      write (") END ", nm , ".", CR)
    end
    cp_if (tmp, file)
    delete_file (tmp)
  end
  derived_implementation (nm)
end

readonly proc build_T_interface(v, nm, vis) is
  local view = "M3AST_" & v
  local unit = view & "_" & nm
  local tmp  = ".generic.tmp"
  if defined("_all")
    > tmp in
      write ("(*generated by m3build*)", CR, CR)
      write ("INTERFACE ", unit, ";", CR)
      write ("IMPORT ", view, ";", CR)
      write ("TYPE T = ", view, ".", nm, ";", CR)
      write ("END ", unit, ".", CR)
    end
    cp_if(tmp, unit & ".i3")
    delete_file(tmp)
  end
  derived_interface (unit, vis)
end