Question: At CodeGenerator#780, you are making a new context, but sharing the parent labelSet. It seems when when you exit that context, you will leave the (now no longer in scope) label in the parent label set. That doesn't seem right to me.
On 2010-08-06, at 12:20, André Bargull wrote: > Change 20100806-bargull-8dg by barg...@bargull02 on 2010-08-06 14:49:37 > in /home/anba/src/svn/openlaszlo/trunk > for http://svn.openlaszlo.org/openlaszlo/trunk > > Summary: fix break and continue bugs in sc.CodeGenerator > > Bugs Fixed: LPP-8340 (cannot use 'continue' in 'switch' block), LPP-8493 > (do/while loop and continue in flash runtimes) > > Technical Reviewer: ptw > QA Reviewer: henry > > Details: > The CodeGenerator used only the context-variable to detect contiguous > statements for the label set (cf. ECMAScript 3rd edt., chapter 12 Statements). > This doesn't work because that way you cannot differentiate between "LBL: { > while (1) {} }" and "LBL: while (1) {}". For both code snippets, the same > context tree is generated. I didn't want to introduce more contexts to detect > this case, because context is also used for other purposes. > Therefore label sets are now handled this way: > - TranslationContext gets a labelSet object, initially the labelSet is null > - when visiting a labelled statement a new context is created, this context > initializes labelSet to a new HashSet, except if the parent statement is also > a labelled statement, in that case the labelSet is shared among both contexts > - when visiting an iteration or switch statement a new context is created, if > the statement is enclosed by a labelled statement, the labelSet is shared > among both contexts > - and TranslationContext#findLabeledContext() respects now the ECMAScript > semantics where break and continue statements may appear > > Also changed visitDoWhileStatement() to use different labels for continue and > the loop-start, so executing a continue statement still tests the loop > condition. > > > Tests: > smokecheck in all runtimes > > Files: > A test/smoke/ecmaContinueBreak.lzl > M test/smoke/smokecheck.lzx > M WEB-INF/lps/server/src/org/openlaszlo/sc/TranslationContext.java > M WEB-INF/lps/server/src/org/openlaszlo/sc/CodeGenerator.java > > Changeset: > http://svn.openlaszlo.org/openlaszlo/patches/20100806-bargull-8dg.tar >
