Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1370)

Issue 9753005: Change visitLoop to handleLoop that takes closures as arguments. (Closed)

Created:
8 years, 9 months ago by Lasse Reichstein Nielsen
Modified:
8 years, 9 months ago
Reviewers:
ngeoffray
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Change visitLoop to handleLoop that takes closures as arguments. This allows easy reuse in for-in loops. Committed: https://code.google.com/p/dart/source/detail?r=5707

Patch Set 1 #

Total comments: 10

Patch Set 2 : Address review comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+97 lines, -116 lines) Patch
M frog/leg/ssa/builder.dart View 1 12 chunks +96 lines, -110 lines 0 comments Download
M tests/co19/co19-leg.status View 3 chunks +1 line, -6 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
Lasse Reichstein Nielsen
8 years, 9 months ago (2012-03-20 13:14:17 UTC) #1
ngeoffray
LGTM! https://chromiumcodereview.appspot.com/9753005/diff/1/frog/leg/ssa/builder.dart File frog/leg/ssa/builder.dart (right): https://chromiumcodereview.appspot.com/9753005/diff/1/frog/leg/ssa/builder.dart#newcode1099 frog/leg/ssa/builder.dart:1099: // The condition function must return a boolean ...
8 years, 9 months ago (2012-03-21 07:58:47 UTC) #2
Lasse Reichstein Nielsen
8 years, 9 months ago (2012-03-21 09:00:15 UTC) #3
https://chromiumcodereview.appspot.com/9753005/diff/1/frog/leg/ssa/builder.dart
File frog/leg/ssa/builder.dart (right):

https://chromiumcodereview.appspot.com/9753005/diff/1/frog/leg/ssa/builder.da...
frog/leg/ssa/builder.dart:1099: // The condition function must return a boolean
result.
I expect to use this one in switch-with-continue, where the condition will be
"true". I.e., it won't need the boolify.
For that reason I don't want the handleLoop to always add a boolify.

I could make it pass the condition instruction on the stack instead of as a
result, but I actually find this more readable.

https://chromiumcodereview.appspot.com/9753005/diff/1/frog/leg/ssa/builder.da...
frog/leg/ssa/builder.dart:1216: node.initializer === null ? null :
buildInitializer,
In this case, I could just put the test into the buildInitializer, etc.,
functions and pass them unconditionally.

This is really the only case where parts can be missing, so it's the only case
where we might pass null. As such, it makes sense that this is the place where
we handle that case.

On the other hand, the difference between a while and a for loop is that the for
loop is the only one with an update block. I might want to be able to record
this in the LoopInformation (at some point). But that's being speculative, and
it's easily changable. I'll make the functions all non-null.

https://chromiumcodereview.appspot.com/9753005/diff/1/frog/leg/ssa/builder.da...
frog/leg/ssa/builder.dart:1223: handleLoop(node, null, HInstruction condition()
{ visit(node.condition);
Done.

https://chromiumcodereview.appspot.com/9753005/diff/1/frog/leg/ssa/builder.da...
frog/leg/ssa/builder.dart:2311: void buildInitialize() {
On 2012/03/21 07:58:47, ngeoffray wrote:
> buildInitializer?

Done.

https://chromiumcodereview.appspot.com/9753005/diff/1/frog/leg/ssa/builder.da...
frog/leg/ssa/builder.dart:2324: selector, const SourceString('hasNext'),
[iterator]));
On 2012/03/21 07:58:47, ngeoffray wrote:
> <Instruction>[iterator]

Done.

Powered by Google App Engine
This is Rietveld 408576698