From: Erik Petrich <epetrich@iv...> - 2014-01-20 07:04:59
On Sun, 19 Jan 2014, Ben Shi wrote:
> With the attached aaaa.c -> aaaa.dumpraw0, the labels (_case_0_23,
> _case_0_245) for case branches are generated in line 1807 - 1812, SDCC.y,
> not in "void geniCodeSwitch (ast * tree, int lvl)", SDCCicode.c ?
No, the labels are generated by createCase() and createDefault(). The
label created in line 1810 is the label needed in case there was a break
statement used inside the switch. But you are correct in that
geniCodeSwitch() does not create any labels (all of the labels are in
place by the time the AST is complete).
> And geniCodeSwitch generates the correspondant gotos according to some
> naming rules?
> Is that right?
Partially. The label names are generated in createCase() and
createDefault(). The AST node for the switch has a linked list of the case
values and associated labels, so the code in geniCodeSwitch can reference
the previously generated label names as needed.