/* Copyright (c) 1979 Regents of the University of California */
* pi - Pascal interpreter code translator
* Charles Haley, Bill Joy UCB
* Version 1.2 January 1979
* Label enters the definitions
* of the label declaration part
register struct nl
*p
, *lp
;
if (parts
& (CPRT
|TPRT
|VPRT
))
error("Label declarations must precede const, type and var declarations");
error("All labels must be declared in one label part");
for (ll
= r
; ll
!= NIL
; ll
= ll
[2]) {
p
= enter(defnl(ll
[1], LABEL
, 0, l
));
* Get the label for the eventual target
p
->nl_flags
=| (NFORWD
|NMOD
);
p
->value
[NL_GOLEV
] = NOTYET
;
* This operator is between
* the bodies of two procedures
* and provides a target for
* gotos for this label via TRA.
put2(O_GOTO
| cbn
<<9, p
->value
[1]);
* we get a statement "goto label"
* and generates the needed tra.
put2(O_TRA
, p
->value
[0]);
if (p
->nl_flags
& NFORWD
) {
if (p
->value
[NL_GOLEV
] == NOTYET
) {
p
->value
[NL_GOLEV
] = level
;
p
->value
[NL_GOLINE
] = line
;
if (p
->value
[NL_GOLEV
] == DEAD
) {
error("Goto %s is into a structured statement", p
->symbol
);
* Labeled is called when a label
* definition is encountered, and
* marks that it has been found and
* patches the associated GOTO generated
error("Label %s not defined in correct block", s
);
if ((p
->nl_flags
& NFORWD
) == 0) {
error("Label %s redefined", s
);
if (p
->value
[NL_GOLEV
] != NOTYET
)
if (p
->value
[NL_GOLEV
] < level
) {
error("Goto %s from line %d is into a structured statement", s
, p
->value
[NL_GOLINE
]);
p
->value
[NL_GOLEV
] = level
;