reference.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
-------------------------> GNU Sather - sourcefile <-------------------------
-- Copyright (C) 2000 by K Hopper, University of Waikato, New Zealand --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute and/or modify it under the terms of the GNU Library General --
-- Public License (LGPL) as published by the Free Software Foundation; --
-- either version 2 of the license, or (at your option) any later version. --
-- This library 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/LGPL 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> <--------------
class REFERENCE < $REFERENCE
class REFERENCE < $REFERENCE is
-- This class is the one used to hold references to external objects.
-- Version 1.2 Mar 00. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 3 Jan 97 kh Original from standard Sather dist.
-- 17 Feb 99 kh Added sub-typing clause
-- 23 Mar 00 kh Now has methods!
const asize : CARD := 32 ;
create_from_value(
obj : $OB
) : SAME
pre ~void(obj)
post true -- could be any 'number'/code
is
-- This routine returns the value of obj as though it were an external
-- REFERENCE provided that it is a value class which is of a size less than
-- or equal to the size of a reference as implemented by the compiler.
-- Built-in to this implementation.
builtin SYS_REF_VAL
end ;
create_from_object(
obj : $OB
) : SAME
pre ~void(obj)
post true
is
-- This routine corresponds to the one above in respect of any reference
-- class object, returning a REFERENCE which is the pointer to the data
-- taken from the object header, rather than the data value. Built-in to
-- this implementation.
builtin SYS_REF_PTR
end ;
is_immutable(
obj : $OB
) : BOOL is
-- This predicate returns true if and only if obj is of an immutable
-- class. Built-in to this implementation.
builtin SYS_IMMUTABLE
end ;
is_same(
other : SAME
) : BOOL is
-- This predicate returns true if and only if the bit-pattern contents
-- of self and other are the same. Note that this does NOT ensure that they
-- necessarily refer to the same object. If the context of the values of
-- self and other are the same then under most circumstances they may be
-- considered to be the same reference.
return to_card = other.to_card
end ;
array_object(
size : CARD,
type_tag : CARD
) : $OB is
-- This feature enables a Sather program to create an object from the
-- given reference provided that it is an AREF of OCTET, HEXTET or QUADBITS
-- - ie treats the area referred to by the external reference as an array of
-- elements. The size argument is the count of octets, while the type_tag
-- argument is the value returned by a call to SYS::tp for the object type.
builtin SYS_REF_A_OB
end ;
to_card : CARD is
-- This routine returns the cardinal number expressed by the reference
-- 'pointer' for use where low-level objects may be either a reference or
-- a numeric value, dependent on operating system usage. Built-in to this
-- implementation.
builtin BIN_CARD
end ;
to_int : INT is
-- This routine returns the cardinal number expressed by the reference
-- 'pointer' for use where low-level objects may be either a reference or
-- a numeric value, dependent on usage. Built-in to this implementation.
builtin BIN_INT
end ;
end ; -- REFERENCE
partial class FOB
partial class FOB is
-- This class implements the special aget and aset operations for
-- foreign objects on top of the constructor class AREF - for octets,
-- hextets, quadbits, etc.
-- NOTE THIS VERSION APPLIES WHERE SUCCESSIVE OCTETS ARE IN LSB FIRST ORDER!!!
-- Version 1.0 May 2001. Copyright K Hopper, U of Waikato
-- Development History
-- -------------------
-- Date Who By Detail
-- ---- ------ ------
-- 16 May 01 kh Original
private include AREF{QUADBITS} ;
create_object(
size : CARD,
ref : REFERENCE
) : $OB is
-- This feature enables a Sather program to create an object from the
-- given reference provided that it is an AREF{xxx} - ie treats the area
-- referred to by the external reference as an array. The size argument is
-- the count of array elements, while the type_id argument is the value
-- returned by a call to SYS::tp for the object type.
return ref.array_object(size,SYS::tp(self))
end ;
private aget(
index : CARD
) : QUADBITS is
-- This routine implements aget for foreign objects with an extra
-- indirection.
builtin SYS_FOB_AGET
end ;
private aset(
index : CARD,
arg : QUADBITS
) is
-- This routine implements aset for foreign objects with an extra
-- indirection.
builtin SYS_FOB_ASET
end ;
end ; -- FOB