return tk->tk_symb = INTEGER;
}
if (ch == 'D' && base == 10) {
+ if (options['l']) {
+ /* Local extension: LONGCARD exists,
+ so internally also longintorcard_type
+ exists.
+ */
+ toktype = longcard_type;
+ if (ovfl == 0 && tk->TOK_INT >= 0 &&
+ tk->TOK_INT<=max_int[(int)long_size]) {
+ toktype = longintorcard_type;
+ }
+ else if (! chk_bounds(tk->TOK_INT,
+ full_mask[(int)long_size],
+ T_CARDINAL)) {
+ ovfl = 1;
+ }
+ }
+ else {
if (ovfl != 0 ||
tk->TOK_INT > max_int[(int)long_size] ||
tk->TOK_INT < 0) {
ovfl = 1;
}
toktype = longint_type;
+ }
}
else if (ovfl == 0 && tk->TOK_INT >= 0 &&
tk->TOK_INT<=max_int[(int)int_size]) {
else if (! chk_bounds(tk->TOK_INT,
full_mask[(int)int_size],
T_CARDINAL)) {
- ovfl = 1;
+ ovfl = 1;
}
if (ovfl)
lexwarning(W_ORDINARY, "overflow in constant");
tpr = BaseType(exp->nd_RIGHT->nd_type);
if (intorcard(tpl, tpr) != 0) {
- if (tpl == intorcard_type) {
+ if (tpl->tp_fund == T_INTORCARD) {
exp->nd_LEFT->nd_type = tpl = tpr;
}
- if (tpr == intorcard_type) {
+ if (tpr->tp_fund == T_INTORCARD) {
exp->nd_RIGHT->nd_type = tpr = tpl;
}
}
if (tpr == intorcard_type) {
exp->nd_type = int_type;
}
+ else if (tpr == longintorcard_type) {
+ exp->nd_type = longint_type;
+ }
if (right->nd_class == Value) {
cstunary(expp);
}
case S_SHORT:
case S_LONG: {
t_type *tp;
- t_type *s1, *s2, *d1, *d2;
+ t_type *s1, *s2, *s3, *d1, *d2, *d3;
if (!(arg = getarg(&arglink, 0, 0, edf))) {
return 0;
d1 = int_type;
s2 = longreal_type;
d2 = real_type;
+ s3 = longcard_type;
+ d3 = card_type;
}
else {
d1 = longint_type;
s1 = int_type;
d2 = longreal_type;
s2 = real_type;
+ d3 = longcard_type;
+ s3 = card_type;
}
if (tp == s1) {
else if (tp == s2) {
MkCoercion(&(arglink->nd_LEFT), d2);
}
+ else if (options['l'] && tp == s3) {
+ MkCoercion(&(arglink->nd_LEFT), d3);
+ }
else {
df_error(arg, "unexpected parameter type", edf);
break;
if (! getarg(&arglink, T_REAL, 0, edf)) return 0;
MkCoercion(&(arglink->nd_LEFT),
edf->df_value.df_stdname == S_TRUNCD ?
- longint_type : card_type);
+ options['l'] ? longcard_type : longint_type
+ : card_type);
free_it = 1;
break;
return;
}
tpr = BaseType(tpr);
- if ((tpl->tp_fund == T_INTEGER && tpr == card_type) ||
- (tpr->tp_fund == T_INTEGER && tpl == card_type)) {
+ if ((tpl->tp_fund == T_INTEGER && tpr->tp_fund == T_CARDINAL) ||
+ (tpr->tp_fund == T_INTEGER && tpl->tp_fund == T_CARDINAL)) {
label lb = ++text_label;
C_dup(tpr->tp_size);
Operands(expr);
tp = BaseType(leftop->nd_type);
- if (tp == intorcard_type) tp = BaseType(rightop->nd_type);
+ if (tp->tp_fund == T_INTORCARD) tp = BaseType(rightop->nd_type);
size = tp->tp_size;
switch (tp->tp_fund) {
case T_INTEGER:
if (tp->tp_fund == T_INTEGER) {
expr->nd_INT = max_int[(int)(tp->tp_size)];
}
- else if (tp == card_type) {
- expr->nd_INT = full_mask[(int)(int_size)];
+ else if (tp->tp_fund == T_CARDINAL) {
+ expr->nd_INT = full_mask[(int)(tp->tp_size)];
}
else if (tp->tp_fund == T_SUBRANGE) {
expr->nd_INT = tp->sub_ub;
.IP \fB\-g\fR
produce a DBX-style symbol table.
.IP \fB\-l\fR
-enable local extensions. Currently, the only local extension consists of
-procedure constants.
+enable local extensions. Currently, there are two local extensions:
+procedure constants, and the type LONGCARD.
.IP \fB\-s\fR
make INTEGER ranges symmetric, t.i., MIN(INTEGER) = - MAX(INTEGER).
This is useful for interpreters that use the "real" MIN(INTEGER) to
EnterType("REAL", real_type);
EnterType("LONGREAL", longreal_type);
EnterType("CARDINAL", card_type);
+ if (options['l']) {
+ /* local extension: LONGCARD. */
+ EnterType("LONGCARD", longcard_type);
+ }
EnterType("(void)", void_type);
df = Enter("NIL", D_CONST, address_type, 0);
df->con_const = nilconst;
*byte_type,
*address_type,
*intorcard_type,
+ *longintorcard_type,
*bitset_type,
*void_type,
*std_type,
*byte_type,
*address_type,
*intorcard_type,
+ *longintorcard_type,
*bitset_type,
*void_type,
*std_type,
longcard_type = standard_type(T_CARDINAL, long_align, long_size);
card_type = standard_type(T_CARDINAL, int_align, int_size);
intorcard_type = standard_type(T_INTORCARD, int_align, int_size);
+ longintorcard_type = standard_type(T_INTORCARD, long_align, long_size);
/* floating types
*/
intorcard(left, right)
register t_type *left, *right;
{
- if (left == intorcard_type) {
+ if (left->tp_fund == T_INTORCARD) {
t_type *tmp = left;
left = right;
right = tmp;
}
- if (right == intorcard_type) {
- if (left == int_type || left == card_type) {
+ if (right->tp_fund == T_INTORCARD) {
+ if (left->tp_fund == T_INTEGER || left->tp_fund == T_CARDINAL) {
return left;
}
}
tp1 = BaseType(tp1);
tp2 = BaseType(tp2);
- if (tp2 != intorcard_type &&
- (tp1 == intorcard_type || tp1 == address_type)) {
+ if (tp2->tp_fund != T_INTORCARD &&
+ (tp1->tp_fund == T_INTORCARD || tp1 == address_type)) {
t_type *tmp = tp2;
tp2 = tp1;
&&
(tp1 == int_type || tp1 == card_type || tp1 == address_type)
)
+ ||
+ ( tp2 == longintorcard_type
+ &&
+ (tp1 == longint_type || tp1 == longcard_type || tp1 == address_type)
+ )
||
( tp2 == address_type
&&
- ( tp1 == card_type || tp1->tp_fund == T_POINTER)
+ ( tp1->tp_fund == T_CARDINAL || tp1->tp_fund == T_POINTER)
)
;
}