
% Definition of data types

% -------------------------------------------------------------------

% $Id: struct.pl,v 2.4 1994/05/05 16:20:27 dbc Exp dbc $

% $Log: struct.pl,v $
% Revision 2.4  1994/05/05  16:20:27  dbc
% Add `mapDesc' field to `varAtr' record.
% Add `dumMaps' and `resMap' fields to `funAtr' record.
% Remove `extShape' field from `varAtr' record.
% Add `ishape' and `varref' fields to `varAtr' record.
%
% Revision 2.3  1994/04/26  15:50:39  dbc
% Add `iSet' and `linSet' to expression attributes
%
% Revision 1.2  1994/04/15  13:44:15  dbc
% Support revision 2.2 of type-checker.
%
% Revision 1.1  1994/04/11  10:40:48  dbc
% Initial revision
%

% -------------------------------------------------------------------

?- op(800, xfx, :=).
?- op(700, yfx, ->).


X := Y        :-   var(Y), !, X = Y.
X := E -> S   :-   !, P := E, select(P, S, F), X := F.
X := X.


select(X, S, _) :- var(X), printString("Uninstantiated record.  Selector = "),
                   print(S), abort.
select(_, X, _) :- var(X), error("Uninstantiated selector").

% User type selectors


varAtr(mkVarAtr(_, _, _, _, _, _, _, _, _)).

select(mkVarAtr(A, _, _, _, _, _, _, _, _), indices,  A) :- !.
select(mkVarAtr(_, A, _, _, _, _, _, _, _), abbrevs,  A) :- !.
select(mkVarAtr(_, _, A, _, _, _, _, _, _), mapping,  A) :- !.
select(mkVarAtr(_, _, _, A, _, _, _, _, _), binding,  A) :- !.
select(mkVarAtr(_, _, _, _, A, _, _, _, _), shape,    A) :- !.
select(mkVarAtr(_, _, _, _, _, A, _, _, _), ishape,   A) :- !.
select(mkVarAtr(_, _, _, _, _, _, A, _, _), mapDesc,  A) :- !.
select(mkVarAtr(_, _, _, _, _, _, _, A, _), imapDesc, A) :- !.
select(mkVarAtr(_, _, _, _, _, _, _, _, A), varref,   A) :- !.



funAtr(mkFunAtr(_, _, _, _, _, _, _, _, _, _, _, _)).

select(mkFunAtr(A, _, _, _, _, _, _, _, _, _, _, _), syms,         A) :- !.
select(mkFunAtr(_, A, _, _, _, _, _, _, _, _, _, _), dummies,      A) :- !.
select(mkFunAtr(_, _, A, _, _, _, _, _, _, _, _, _), result,       A) :- !.
select(mkFunAtr(_, _, _, A, _, _, _, _, _, _, _, _), declarations, A) :- !.
select(mkFunAtr(_, _, _, _, A, _, _, _, _, _, _, _), statements,   A) :- !.
select(mkFunAtr(_, _, _, _, _, A, _, _, _, _, _, _), class,        A) :- !.
select(mkFunAtr(_, _, _, _, _, _, A, _, _, _, _, _), dumShps,      A) :- !.
select(mkFunAtr(_, _, _, _, _, _, _, A, _, _, _, _), resShp,       A) :- !.
select(mkFunAtr(_, _, _, _, _, _, _, _, A, _, _, _), dumMaps,      A) :- !.
select(mkFunAtr(_, _, _, _, _, _, _, _, _, A, _, _), resMap,       A) :- !.
select(mkFunAtr(_, _, _, _, _, _, _, _, _, _, A, _), dumAlnGrps,   A) :- !.
select(mkFunAtr(_, _, _, _, _, _, _, _, _, _, _, A), resAlnGrp,    A) :- !.


expAtr(mkExpAtr(_, _, _, _, _, _, _, _, _)).

select(mkExpAtr(A, _, _, _, _, _, _, _, _), assertions, A) :- !.
select(mkExpAtr(_, A, _, _, _, _, _, _, _), shape,      A) :- !.
select(mkExpAtr(_, _, A, _, _, _, _, _, _), acts,       A) :- !.
select(mkExpAtr(_, _, _, A, _, _, _, _, _), iSet,       A) :- !.
select(mkExpAtr(_, _, _, _, A, _, _, _, _), linSet,     A) :- !.
select(mkExpAtr(_, _, _, _, _, A, _, _, _), ctxMap,     A) :- !.
select(mkExpAtr(_, _, _, _, _, _, A, _, _), locMap,     A) :- !.
select(mkExpAtr(_, _, _, _, _, _, _, A, _), mapDaughts, A) :- !.
select(mkExpAtr(_, _, _, _, _, _, _, _, A), mapDomains, A) :- !.


% End of user type selectors

select(R, S, _) :- printString("Invalid selector: "),
                   print(S), printString(".  Record = "), print(R), abort.

error(S) :- printString(S), abort.

