(* ----------------------------------------------------------------------------
* $Id: MASmtc.mip,v 1.1 1995/03/06 16:48:45 pesch Exp $
* ----------------------------------------------------------------------------
* This file is part of MAS.
* ----------------------------------------------------------------------------
* Copyright (c) 1989 - 1992 Universitaet Passau
* ----------------------------------------------------------------------------
* $Log: MASmtc.mip,v $
* Revision 1.1 1995/03/06 16:48:45 pesch
* Replaced MASmtc.mi by MASmtc.mip.
* Will now work with both (old and new) reuse libraries.
*
* Revision 1.4 1992/10/16 13:47:56 kredel
* Errors found by Mocka
*
* Revision 1.3 1992/10/15 16:25:00 kredel
* Changed rcsid variable
*
* Revision 1.2 1992/02/12 17:31:59 pesch
* Moved CONST definition to the right place
*
* Revision 1.1 1992/01/22 15:10:42 kredel
* Initial revision
*
* ----------------------------------------------------------------------------
*)
IMPLEMENTATION MODULE MASmtc;
(* MAS mtc [Modula-2 to C] Implementation Module. *)
(* Import lists and declarations. *)
FROM SYSTEM IMPORT ADDRESS, ADR;
#ifdef OLD_MTC
FROM SysCalls IMPORT GetArgCount, GetArgument, GetVariable, System;
#else
FROM System IMPORT GetArgCount, GetArgument, GetVariable, System;
#endif
FROM Strings IMPORT AssignEmpty, tString, ArrayToString, StringToArray,
Concatenate;
(*
FROM StdIO IMPORT WriteS, WriteNl, WriteFlush;
*)
CONST rcsidi = "$Id: MASmtc.mip,v 1.1 1995/03/06 16:48:45 pesch Exp $";
CONST copyrighti = "Copyright (c) 1989 - 1992 Universitaet Passau";
(* stackoff depends on register architecture of maschine *)
(* and on procedure calling sequence. *)
#ifdef __AIX__
CONST stackoff = 80;
#else
#ifdef __NeXT__
CONST stackoff = 12;
#else
CONST stackoff = 0;
#endif
#endif
VAR parmpos: CARDINAL;
toc: INTEGER;
ArgCount: CARDINAL;
PROCEDURE getstck(): ADDRESS;
(*Get contents of stack register. *)
VAR stck: INTEGER;
a: ADDRESS;
BEGIN
(*1*) stck:=0; a:=ADR(stck)+stackoff; stck:=1; RETURN(a);
(*9*) END getstck;
PROCEDURE gettoc(): ADDRESS;
(*Get contents of toc register. *)
VAR a: ADDRESS;
BEGIN
(*1*) toc:=0; a:=ADR(toc); toc:=1; RETURN(a);
(*9*) END gettoc;
PROCEDURE parameter;
(*setup parameter processing. *)
BEGIN
(*1*) ArgCount:=GetArgCount(); parmpos:=0;
(*9*) END parameter;
PROCEDURE NextParm(VAR s: ARRAY OF CHAR): BOOLEAN;
(*Next Parameter. The next parameter from the Unix environement is
placed in string s. If no parameter was found, FALSE is returned
and s is undefined, else TRUE is returned. The separator for the
parameters is the blank character. *)
BEGIN
(*1*) IF parmpos < ArgCount-1 THEN parmpos:=parmpos+1;
GetArgument(parmpos,s);
RETURN(TRUE) END;
RETURN(FALSE);
(*9*) END NextParm;
PROCEDURE DOS(s: ARRAY OF CHAR): INTEGER;
(*Call DOS/UNIX program. *)
VAR i: INTEGER;
BEGIN
(*2*) (*load and execute program. *)
i:=System(s);
RETURN(i)
(*9*) END DOS;
PROCEDURE EDIT(s: ARRAY OF CHAR): INTEGER;
(*Edit file with name s. *)
VAR ep, sp: tString;
e: ARRAY [0..250] OF CHAR;
i: INTEGER;
BEGIN
(*1*) (*prepare parameters. *)
(*GetVariable("EDITOR",e); geht nicht *)
ArrayToString(EditPrg,ep); ArrayToString(EditPrm,sp);
Concatenate(ep,sp); ArrayToString(s,sp);
Concatenate(ep,sp); StringToArray(ep,e);
(*2*) (*load and execute program. *)
i:=System(e);
RETURN(i)
(*9*) END EDIT;
BEGIN
parameter;
EditPrg:="/public/gnu/bin/emacs"; EditPrm:=" ";
END MASmtc.
(* -EOF- *)