/* Copyright (c) 1979 Regents of the University of California */
* pi - Pascal interpreter code translator
* Charles Haley, Bill Joy UCB
* Version 1.2 November 1978
* Constant set constructor.
* settype is the type of the
* set if we think that we know it
* if not we try our damndest to figure
* out what the type should be.
register struct nl
*t
, *exptype
;
* So far we have no indication
* of what the set type should be.
* We "look ahead" and try to infer
* The type of the constant set
* by evaluating one of its members.
return (nl
+TSET
); /* tenative for [] */
* The type of the set, settype, is
* deemed to be a set of the base type
* of t, which we call exptype. If,
* however, this would involve a
* "set of integer", we cop out
* and use "intset"'s current scoped
error("Sets may not have 'real' elements");
error("Set elements must be scalars, not %ss", nameof(t
));
settype
= lookup(intset
);
if (isnta(settype
, "t")) {
error("Set default type \"intset\" is not a set");
if (exptype
->class != RANGE
)
settype
= defnl(0, SET
, exptype
, 0);
if (settype
->class != SET
) {
* e.g string context [1,2] = 'abc'
error("Constant set involved in non set context");
put2(O_PUSH
, -width(settype
));
for (el
=r
[2]; el
; el
=el
[2]) {
if (incompat(t
, exptype
, e
[2]))
cerror("Upper bound of element type clashed with set type in constant set");
if (incompat(t
, exptype
, e
[1]))
cerror("Lower bound of element type clashed with set type in constant set");
t
= rvalue((int *) e
, NLNIL
);
if (incompat(t
, exptype
, e
))
cerror("Element type clashed with set type in constant set");
put(4, O_CTTOT
, n
, set
.lwrb
, set
.uprbp
);