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".
|
|
|
|
*/
|
1994-06-27 08:03:14 +00:00
|
|
|
/* $Id$ */
|
1989-02-07 11:04:05 +00:00
|
|
|
/* L A B E L H A N D L I N G */
|
|
|
|
|
2013-05-12 19:45:55 +00:00
|
|
|
#include "parameters.h"
|
|
|
|
#include "idf.h"
|
1989-02-07 11:04:05 +00:00
|
|
|
#include "Lpars.h"
|
|
|
|
#include "level.h"
|
|
|
|
#include "label.h"
|
|
|
|
#include "arith.h"
|
|
|
|
#include "def.h"
|
|
|
|
#include "type.h"
|
1993-02-03 13:28:14 +00:00
|
|
|
#include "stack.h"
|
2019-02-18 16:42:15 +00:00
|
|
|
#include "error.h"
|
|
|
|
|
1989-02-07 11:04:05 +00:00
|
|
|
|
|
|
|
extern char options[];
|
|
|
|
|
2019-02-18 16:42:15 +00:00
|
|
|
void enter_label(register struct idf *idf, int defining)
|
1989-02-07 11:04:05 +00:00
|
|
|
{
|
|
|
|
/* 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.
|
|
|
|
*/
|
1991-06-19 16:12:56 +00:00
|
|
|
register struct def *def = idf->id_label;
|
1990-07-19 17:16:36 +00:00
|
|
|
|
|
|
|
if (def) {
|
1991-06-19 16:12:56 +00:00
|
|
|
if (defining && def->df_initialized)
|
|
|
|
error("redeclaration of label %s", idf->id_text);
|
1989-02-07 11:04:05 +00:00
|
|
|
}
|
|
|
|
else {
|
1991-06-20 10:17:36 +00:00
|
|
|
stack_idf(idf, stack_level_of(L_LOCAL));
|
1991-06-19 16:12:56 +00:00
|
|
|
def = new_def();
|
|
|
|
def->df_sc = LABEL;
|
|
|
|
idf->id_label = def;
|
|
|
|
def->df_file = idf->id_file;
|
|
|
|
def->df_line = idf->id_line;
|
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
|
|
|
}
|
|
|
|
|
2019-02-18 16:42:15 +00:00
|
|
|
void unstack_label(register struct idf *idf)
|
1989-02-07 11:04:05 +00:00
|
|
|
{
|
|
|
|
/* The scope in which the label idf occurred is left.
|
|
|
|
*/
|
1991-06-19 16:12:56 +00:00
|
|
|
if (!idf->id_label->df_initialized && !is_anon_idf(idf))
|
1989-02-07 11:04:05 +00:00
|
|
|
error("label %s not defined", idf->id_text);
|
|
|
|
}
|