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

-- tp.sa: Classes relating to modes in the Sather compiler.

-- $MODE: Abstract interface to Sather modes; -- IN_MODE: Mode of in arguments -- OUT_MODE: Mode of our arguments -- INOUT_MODE: Mode of inout arguments -- ONCE_MODE: Mode for once arguments -- MODES: Defines unique copies of different modes used all over

abstract class $MODE < $STR

abstract class $MODE < $STR is -- Abstract interface to classes representing Sather modes -- Decsendants are IN_MODE, OUT_MODE, INOUT_MODE, and ONCE_MODE str:STR; -- The string representation of self. -- Uses no whitespace, eg: "inout" is_eq(m:$OB):BOOL; -- Equality test. is_neq(m:$OB):BOOL; -- Inequality test. is_eq(m:$MODE):BOOL; -- Equality test. is_neq(m:$MODE):BOOL; -- Inequality test. end;

class MODE

class MODE is -- Implementation to be included by $MODE objects is_eq(ob: $OB): BOOL is typecase ob when $MODE then return is_eq(ob)-- INOUT_MODE::is_eq else return false end; end; is_neq(ob: $OB): BOOL is return ~is_eq(ob) end; is_eq(m:$MODE): BOOL is return SYS::ob_eq(self, m);-- SYS::ob_eq end; is_neq(m:$MODE): BOOL is return ~SYS::ob_eq(self, m); end; create:SAME is res ::= new; return res; end; create_from_as(as_mode: AS_ARG_MODE): $MODE is case as_mode.mod-- AS_ARG_MODE::mod when AS_ARG_MODE::in_mode then-- AS_ARG_MODE::in_mode return MODES::in_mode-- MODES::in_mode when AS_ARG_MODE::out_mode then-- AS_ARG_MODE::out_mode return MODES::out_mode-- MODES::out_mode when AS_ARG_MODE::inout_mode then-- AS_ARG_MODE::inout_mode return MODES::inout_mode-- MODES::inout_mode when AS_ARG_MODE::once_mode then-- AS_ARG_MODE::once_mode return MODES::once_mode-- MODES::once_mode end; end; end;

class IN_MODE < $MODE

class IN_MODE < $MODE is -- Implementation of in argument mode include MODE; create: SAME is if void(MODES::in_mode) then-- MODES::in_mode res ::= new; return res; else return MODES::in_mode;-- MODES::in_mode end; end; str:STR is return ""; end; end;

class INOUT_MODE < $MODE

class INOUT_MODE < $MODE is -- Implementation of in argument mode include MODE; create: SAME is if void(MODES::inout_mode) then-- MODES::inout_mode res ::= new; return res; else return MODES::inout_mode;-- MODES::inout_mode end; end; str:STR is return "inout"; end; end;

class OUT_MODE < $MODE

class OUT_MODE < $MODE is -- Implementation of in argument mode include MODE; create: SAME is if void(MODES::out_mode) then-- MODES::out_mode res ::= new; return res; else return MODES::out_mode;-- MODES::out_mode end; end; str:STR is return "out"; end; end;

class ONCE_MODE < $MODE

class ONCE_MODE < $MODE is -- Implementation of in argument mode include MODE; create: SAME is if void(MODES::once_mode) then-- MODES::once_mode res ::= new; return res; else return MODES::once_mode;-- MODES::once_mode end; end; str:STR is return "once"; end; end; -- Only 4 distinct immutable objects are used to facilitate -- fast pointer comparison and reduce memory consumption

class MODES

class MODES is readonly shared in_mode:IN_MODE := IN_MODE::create;-- IN_MODE::create readonly shared out_mode:OUT_MODE := OUT_MODE::create;-- OUT_MODE::create readonly shared inout_mode:INOUT_MODE := INOUT_MODE::create;-- INOUT_MODE::create readonly shared once_mode:ONCE_MODE := ONCE_MODE::create;-- ONCE_MODE::create end;