From: Ben S. <pow...@16...> - 2014-01-19 03:52:20
Attachments:
aaaa.dumpraw0
|
int ss(int a) { switch (a / 3) { case 23: return a + 2; case 245: return a - 32; default: return a; } } |
From: Erik P. <epe...@iv...> - 2014-01-20 07:04:59
|
On Sun, 19 Jan 2014, Ben Shi wrote: > Hello, > > 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. Erik |