1.8.7. ex_PushWaitingLabel()

[<<<] [>>>]

This function is used to define a label.

int ex_PushWaitingLabel(peXobject pEx,
                         pSymbolLABEL pLbl

When a label is defined the eNode_l that the label is going to belong still does not exists, and therefore the NodeId of that eNode_l is not known. This function together with ex_PopWaitingLabel() maintains a stack that can store labels which are currently defined and still need a line to be assigned to them. These labels all point to the same line. Altough it is very rare that many labels point to the same line, it is possible. The number of labels that can point the same line is defined by the constant MAX_SAME_LABELS defined in expression.c

To make it clear see the following BASIC code:

this_is_a_label: REM this is a comment PRINT "hello word!!"

The label is defined on the first line of the example. However the label belongs to the third line containing the statement PRINT. When the label is processed the compiler does not know the node number of the code segment which is generated from the third line. Therefore this function maintains a label-stack to store all labels that need a line. Whenever a line is compiled so that a label can be assigned to that very line the stack is emptied and all labels waiting on the stack are assigned to the line just built up. (Or the line is assigned to the labels if you like the sentence the other way around.)

Note that not only labels given by a label defining statement are pushed on this stack, but also labels generated by commands like 'while/wend' of 'if/else/endif'.

[<<<] [>>>]