1989-02-07 11:04:05 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
|
|
|
/* $Header$ */
|
|
|
|
/* L A B E L H A N D L I N G */
|
|
|
|
|
|
|
|
#include "Lpars.h"
|
|
|
|
#include "level.h"
|
|
|
|
#include "idf.h"
|
|
|
|
#include "label.h"
|
|
|
|
#include "arith.h"
|
|
|
|
#include "def.h"
|
|
|
|
#include "type.h"
|
|
|
|
|
|
|
|
extern char options[];
|
|
|
|
|
|
|
|
enter_label(idf, defining)
|
|
|
|
register struct idf *idf;
|
|
|
|
{
|
|
|
|
/* The identifier idf is entered as a label. If it is new,
|
|
|
|
it is entered into the idf list with the largest possible
|
|
|
|
scope, i.e., on the lowest possible level.
|
|
|
|
If defining, the label comes from a label statement.
|
|
|
|
*/
|
1990-07-19 17:16:36 +00:00
|
|
|
register struct def *def = idf->id_def;
|
|
|
|
|
|
|
|
if (def) {
|
1989-02-07 11:04:05 +00:00
|
|
|
if (def->df_sc == LABEL) {
|
|
|
|
if (defining && def->df_initialized)
|
|
|
|
error("redeclaration of label %s",
|
|
|
|
idf->id_text);
|
|
|
|
}
|
|
|
|
else { /* there may still be room for it */
|
|
|
|
if (def->df_level == level) /* but alas, no */
|
|
|
|
error("%s is not a label", idf->id_text);
|
|
|
|
else {
|
1989-09-19 16:13:23 +00:00
|
|
|
add_def(idf, LABEL, label_type, L_LOCAL);
|
1989-02-07 11:04:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
add_def(idf, LABEL, label_type, L_LOCAL);
|
1990-07-19 17:16:36 +00:00
|
|
|
def = idf->id_def;
|
1989-02-07 11:04:05 +00:00
|
|
|
}
|
1990-07-19 17:16:36 +00:00
|
|
|
if (def->df_address == 0)
|
|
|
|
def->df_address = (arith) text_label();
|
1989-02-07 11:04:05 +00:00
|
|
|
if (defining)
|
1990-07-19 17:16:36 +00:00
|
|
|
def->df_initialized = 1;
|
1989-02-07 11:04:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unstack_label(idf)
|
|
|
|
register struct idf *idf;
|
|
|
|
{
|
|
|
|
/* The scope in which the label idf occurred is left.
|
|
|
|
*/
|
|
|
|
if (!idf->id_def->df_initialized && !is_anon_idf(idf))
|
|
|
|
error("label %s not defined", idf->id_text);
|
|
|
|
}
|