-static char Version[] = "ACK Modula-2 compiler Version 0.22";
+static char Version[] = "ACK Modula-2 compiler Version 0.23";
{
/* Add case labels to the case label list
*/
- register arith v1, v2;
if (node->nd_class == Link) {
if (node->nd_symb == UPTO) {
assert(node->nd_left->nd_class == Value);
assert(node->nd_right->nd_class == Value);
- v2 = node->nd_right->nd_INT;
node->nd_type = node->nd_left->nd_type;
- for (v1 = node->nd_left->nd_INT; v1 <= v2; v1++) {
- node->nd_INT = v1;
+ for (node->nd_INT = node->nd_left->nd_INT;
+ node->nd_INT != node->nd_right->nd_INT;
+ node->nd_INT++) {
if (! AddOneCase(sh, node, lbl)) return 0;
}
return 1;
size = left->nd_type->tp_size;
if (size < word_size) size = word_size;
CodePExpr(left);
+ CodeCoercion(left->nd_type, tp);
if (arg) {
CodePExpr(arg->nd_left);
CodeCoercion(arg->nd_left->nd_type, tp);
nd = *pnd;
}
[
- UPTO { *pnd = dot2node(Link,nd,NULLNODE); }
+ UPTO { *pnd = nd = dot2node(Link,nd,NULLNODE);
+ nd->nd_type = nd->nd_left->nd_type;
+ }
ConstExpression(&(*pnd)->nd_right)
{ if (!ChkCompat(&((*pnd)->nd_right), nd->nd_type,
"case label")) {
nd->nd_type = error_type;
}
+ else if (! chk_bounds(nd->nd_left->nd_INT,
+ nd->nd_right->nd_INT,
+ BaseType(nd->nd_type)->tp_fund)) {
+ node_error(nd,
+ "lower bound exceeds upper bound in case label range");
+ }
+
}
]?
{
#define D_ERROR 0x4000 /* a compiler generated definition for an
undefined variable
*/
-#define D_IMP_BY_EXP 0x8000 /* imported definition by export */
#define D_VALUE (D_PROCEDURE|D_VARIABLE|D_FIELD|D_ENUM|D_CONST|D_PROCHEAD)
#define D_ISTYPE (D_HIDDEN|D_TYPE|D_FTYPE)
-#define D_IMPORTED (D_IMPORT|D_IMP_BY_EXP)
+#define D_IMPORTED (D_IMPORT)
#define is_type(dfx) ((dfx)->df_kind & D_ISTYPE)
unsigned short df_flags;
#define D_NOREG 0x01 /* set if it may not reside in a register */
#define D_FOREIGN 0x100 /* set for foreign language modules */
#define D_ADDRGIVEN 0x200 /* set if address given for variable */
#define D_FORLOOP 0x400 /* set if busy in for-loop */
+#define D_IMP_BY_EXP 0x800 /* imported definition by export */
struct type *df_type;
union {
struct module df_module;
FreeNode(Idlist);
}
-STATIC
-DoImport(df, scope, kind)
+STATIC t_def *
+DoImport(df, scope)
register t_def *df;
t_scope *scope;
{
/* Definition "df" is imported to scope "scope".
Handle the case that it is an enumeration type or a module.
*/
- register t_def *idef = define(df->df_idf, scope, kind);
+ register t_def *idef = define(df->df_idf, scope, D_IMPORT);
idef->imp_def = df;
/* Also import all enumeration literals
*/
for (df = df->df_type->enm_enums; df; df = df->enm_next) {
- register t_def *df1 = define(df->df_idf, scope, kind);
+ register t_def *df1 = define(df->df_idf, scope, D_IMPORT);
df1->imp_def = df;
df1->df_flags |= D_USED;/* don't complain when these
if (df->mod_vis == CurrVis) {
error("cannot import current module \"%s\"",
df->df_idf->id_text);
- return;
+ return idef;
}
for (df = df->mod_vis->sc_scope->sc_def;
df;
df = df->df_nextinscope) {
if (df->df_flags & D_EXPORTED) {
register t_def *df1 =
- define(df->df_idf, scope, kind);
+ define(df->df_idf, scope, D_IMPORT);
df1->imp_def = df;
df1->df_flags |= D_USED;
}
idef->df_flags |= D_USED; /* don't complain ... */
}
+ return idef;
}
STATIC t_scopelist *
while (df1) {
if ((df1->df_kind & D_IMPORTED) &&
df1->imp_def == CurrentScope->sc_definedby) {
- DoImport(df, df1->df_scope, D_IMP_BY_EXP);
+ DoImport(df, df1->df_scope)->df_flags |=
+ D_IMP_BY_EXP;
}
df1 = df1->df_next;
}
}
if (df1->df_kind == D_PROCHEAD &&
df2->df_kind == D_PROCEDURE) {
- df1->df_kind = D_IMP_BY_EXP;
+ df1->df_kind = D_IMPORT;
+ df1->df_flags |= D_IMP_BY_EXP;
df1->imp_def = df;
continue;
}
}
}
- DoImport(df, enclosing(CurrVis)->sc_scope, D_IMP_BY_EXP);
+ DoImport(df, enclosing(CurrVis)->sc_scope)->df_flags |=
+ D_IMP_BY_EXP;
}
}
FreeNode(Idlist);
module_name);
df->df_flags |= D_QEXPORTED;
}
- DoImport(df, CurrentScope, D_IMPORT);
+ DoImport(df, CurrentScope);
}
if (!forwflag) FreeNode(FromId);
f = file_info;
for (; idlist; idlist = idlist->nd_left) {
- DoImport(GetDefinitionModule(idlist->nd_IDF, 1), CurrentScope, D_IMPORT);
+ DoImport(GetDefinitionModule(idlist->nd_IDF, 1), CurrentScope);
file_info = f;
}
}
t_scope *sc = enclosing(CurrVis)->sc_scope;
for (; idlist; idlist = idlist->nd_left) {
- DoImport(ForwDef(idlist, sc), CurrentScope, D_IMPORT);
+ DoImport(ForwDef(idlist, sc), CurrentScope);
}
}
*/
arith lb, ub;
register label ol;
+ arith size = tp->tp_size;
+ extern char *long2str();
+ register t_type *btp = BaseType(tp);
+ if (size < word_size) size = word_size;
getbounds(tp, &lb, &ub);
if (tp->tp_fund == T_SUBRANGE) {
}
if (!ol) {
C_df_dlb(ol = data_label);
- C_rom_cst(lb);
- C_rom_cst(ub);
+ C_rom_icon(long2str((long)lb,10), size);
+ C_rom_icon(long2str((long)ub,10), size);
}
c_lae_dlb(ol);
- C_rck(word_size);
+ if (size <= word_size) {
+ C_cal(btp->tp_fund == T_INTEGER ? "rcki" : "rcku");
+ }
+ else {
+ C_cal(btp->tp_fund == T_INTEGER ? "rckil" : "rckul");
+ }
+ C_asp(pointer_size);
}
getbounds(tp, plo, phi)
register t_def *df1 = df->imp_def;
df1->df_flags |= df->df_flags & (D_USED|D_DEFINED);
- if (df->df_kind == D_IMPORT) {
+ if (df->df_kind == D_IMPORT &&
+ !(df->df_flags & D_IMP_BY_EXP)) {
if (! (df->df_flags & (D_USED | D_DEFINED))) {
node_warning(
df->df_scope->sc_end,