home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************
- * *
- * The SB-Prolog System *
- * Copyright SUNY at Stony Brook, 1986; University of Arizona, 1987 *
- * *
- ************************************************************************/
-
- /*-----------------------------------------------------------------
- SB-Prolog is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY. No author or distributor
- accepts responsibility to anyone for the consequences of using it
- or for whether it serves any particular purpose or works at all,
- unless he says so in writing. Refer to the SB-Prolog General Public
- License for full details.
-
- Everyone is granted permission to copy, modify and redistribute
- SB-Prolog, but only under the conditions described in the
- SB-Prolog General Public License. A copy of this license is
- supposed to have been given to you along with SB-Prolog so you
- can know your rights and responsibilities. It should be in a
- file named COPYING. Among other things, the copyright notice
- and this notice must be preserved on all copies.
- ------------------------------------------------------------------ */
-
- /****************************************************************************
- * *
- * This file has been changed by to include Modules Extensions *
- * Changes by : Brian Paxton 1991/92 *
- * Last update : June 1992 *
- * *
- * Organisation : University of Edinburgh. *
- * For : Departments of Computer Science and Artificial Intelligence *
- * Fourth Year Project. *
- * *
- ****************************************************************************/
-
- /* $bmeta.P */
-
- $bmeta_export([$atom/1,$atomic/1,$integer/1,$number/1,$structure/1,
- $functor0/2,$bldstr/3,$arg/3,$arity/2,$real/1,$float/1,$mkstr/3,
- $is_buffer/1,$bldstr/4,$functor0/2,$functor0/3,
- $function/1,$predicate/1]).
-
- % $function/1 succeeds if its argument is a function (not a predicate or
- % a buffer).
- % At the user level, this is called function/1.
-
- $function(X) :-
- ( $atom(X) -> true ; $structure(X) ),
- $symtype(X, 0).
-
- % $predicate/1 succeeds if its argument is a predicate (not a function or
- % a buffer).
- % At the user level, this is called predicate/1.
-
- $predicate(X) :-
- ( $atom(X) -> true ; $structure(X) ),
- ( $symtype(X, 1) -> true ; $symtype(X, 2) ).
-
- $atom(X) :- '_$builtin'(66).
-
- $atomic(X) :- '_$builtin'(68).
-
- $integer(X) :- '_$builtin'(67).
-
- $number(X) :- integer(X) -> true ; real(X).
-
- $structure(X) :- '_$builtin'(129).
-
- $functor0(T, F) :- '_$builtin'(81).
-
- % $functor0/3 does basically the same jobs as $functor0, but takes into
- % account functions declared as 'fun X = Y'.
- % Requires the current structure tag to operate.
-
- $functor0(X,Y,perv) :- !,
- $functor0(X,Y).
-
- $functor0(Structure,Name,Tag) :-
- $isa_structuretag(Tag),
- $functor0(Structure,Internal),
- $arity(Structure,Arity),
- $symtype($mapped_function(_,_,_,_),Type),
- ( ( Type > 0 ,
- $mapped_function(Name0, Arity, Internal, Tag) ) -> true ;
- Name0 = Internal ),
- ( $dismantle_name(Name0,Name1,perv) ->
- $dismantle_name(Name2,Name1,Tag) ;
- Name2 = Name0 ),
- $dismantle_name(Name2,Intname,_),
- ( $pervasive0(Intname) ->
- Name = Intname ;
- ( ( Type > 0,
- $mapped_function(Name2, 0, Name, Tag) ) -> true ;
- Name = Name2 ) ).
-
- $bldstr(F, N, T) :-
- '_$builtin'(84).
-
- % $bldstr/4 does basically the same jobs as $bldstr/3, but takes into
- % account functions declared as 'fun X = Y'.
- % Requires the current structure tag to operate.
- % At the user level, this predicate is called bldstr/4.
-
- $bldstr(Atom,Arity,Structure,Currenttag) :-
- $isa_structuretag(Currenttag),
- $symtype($mapped_function(_,_,_,_),Type),
- ( ( Type > 0,
- $mapped_function(Atom1,0,Atom,Currenttag) ) -> true ;
- Atom1 = Atom ),
- ( $dismantle_name(Atom1,Atom2,perv) ->
- $dismantle_name(Atom3,Atom2,Currenttag) ;
- Atom3 = Atom1 ),
- $dismantle_name(Atom3,Atom4,_),
- ( $pervasive(Atom4/Arity) ->
- Internal = Atom4 ;
- ( ( Type > 0,
- $mapped_function(Atom3,Arity,Internal,_) ) -> true ;
- Internal = Atom3 ) ),
- $bldstr0(Internal,Arity,Structure).
-
- $bldstr0(F,N,T) :- '_$builtin'(84).
-
- $arg(I, T, X) :- '_$builtin'( 80 ).
-
- $arity(X, A) :- '_$builtin'(69).
-
- $real(X) :- '_$builtin'(62).
-
- $float(X) :- '_$builtin'(62).
-
- $mkstr(X,Y,Z) :- '_$builtin'(85).
-
- $is_buffer(X) :- '_$builtin'(72).
-
-