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

Issue 24768004: Check types of case expressions (Closed)

Created:
7 years, 2 months ago by hausner
Modified:
7 years, 2 months ago
Reviewers:
srdjan, Ivan Posva
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Visibility:
Public.

Description

Check types of case expressions Implement checks to make sure all case expressions are of the same type and other restrictions. This change assumes that it's ok to use double values in switch expressions. Will verify with those who are in the know. R=srdjan@google.com Committed: https://code.google.com/p/dart/source/detail?r=27968

Patch Set 1 #

Total comments: 2

Patch Set 2 : #

Patch Set 3 : #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+59 lines, -9 lines) Patch
runtime/vm/parser.h View 1 chunk +2 lines, -0 lines 0 comments Download
runtime/vm/parser.cc View 1 5 chunks +57 lines, -3 lines 6 comments Download
tests/co19/co19-runtime.status View 1 chunk +0 lines, -4 lines 0 comments Download
tests/language/language.status View 1 chunk +0 lines, -2 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
hausner
7 years, 2 months ago (2013-09-26 18:12:47 UTC) #1
srdjan
lgtm https://codereview.chromium.org/24768004/diff/1/runtime/vm/parser.cc File runtime/vm/parser.cc (right): https://codereview.chromium.org/24768004/diff/1/runtime/vm/parser.cc#newcode6047 runtime/vm/parser.cc:6047: void Parser::CheckCaseExpressions(const GrowableArray<LiteralNode*>& values) { Add brief comment ...
7 years, 2 months ago (2013-09-26 18:35:42 UTC) #2
hausner
Committed patchset #3 manually as r27968 (presubmit successful).
7 years, 2 months ago (2013-09-26 18:54:19 UTC) #3
hausner
https://codereview.chromium.org/24768004/diff/1/runtime/vm/parser.cc File runtime/vm/parser.cc (right): https://codereview.chromium.org/24768004/diff/1/runtime/vm/parser.cc#newcode6047 runtime/vm/parser.cc:6047: void Parser::CheckCaseExpressions(const GrowableArray<LiteralNode*>& values) { On 2013/09/26 18:35:43, srdjan ...
7 years, 2 months ago (2013-09-26 18:54:58 UTC) #4
Ivan Posva
PCU Thanks, -Ivan https://codereview.chromium.org/24768004/diff/7001/runtime/vm/parser.cc File runtime/vm/parser.cc (right): https://codereview.chromium.org/24768004/diff/7001/runtime/vm/parser.cc#newcode6057 runtime/vm/parser.cc:6057: for (intptr_t i = 0; i ...
7 years, 2 months ago (2013-09-27 00:24:59 UTC) #5
hausner
https://codereview.chromium.org/24768004/diff/7001/runtime/vm/parser.cc File runtime/vm/parser.cc (right): https://codereview.chromium.org/24768004/diff/7001/runtime/vm/parser.cc#newcode6057 runtime/vm/parser.cc:6057: for (intptr_t i = 0; i < num_expressions; i++) ...
7 years, 2 months ago (2013-09-27 00:31:34 UTC) #6
Ivan Posva
https://codereview.chromium.org/24768004/diff/7001/runtime/vm/parser.cc File runtime/vm/parser.cc (right): https://codereview.chromium.org/24768004/diff/7001/runtime/vm/parser.cc#newcode6083 runtime/vm/parser.cc:6083: Resolver::ResolveDynamicAnyArgs(cls, Symbols::EqualOperator())); On 2013/09/27 00:31:34, hausner wrote: > On ...
7 years, 2 months ago (2013-09-27 00:44:43 UTC) #7
hausner
7 years, 2 months ago (2013-09-27 00:49:16 UTC) #8
Message was sent while issue was closed.
https://codereview.chromium.org/24768004/diff/7001/runtime/vm/parser.cc
File runtime/vm/parser.cc (right):

https://codereview.chromium.org/24768004/diff/7001/runtime/vm/parser.cc#newco...
runtime/vm/parser.cc:6083: Resolver::ResolveDynamicAnyArgs(cls,
Symbols::EqualOperator()));
On 2013/09/27 00:44:45, Ivan Posva wrote:
> On 2013/09/27 00:31:34, hausner wrote:
> > On 2013/09/27 00:24:59, Ivan Posva wrote:
> > > Can't you hoist this check out of the loop? Once you have determined that
> the
> > > non-special class does not implement the operator == it should be fine for
> all
> > > of them.
> > 
> > Good point. If I hoist it out I have to duplicate the int/String/double
> checks,
> > but I can skip this on subsequent iterations after it's checked once.
> > 
> > Will do in a separate checkin.
> 
> You can hoist the whole testing out. Most of the time the val.clazz() will be
> first_value.clazz() even for int, strings and doubles. If for some reason that
> is not the case (e.g. mixing one and two byte strings) it can be easily
checked
> in a slow case.

The whole reason why int and String are handled separately is because there are
several implentation classes: Smi, Mint, Integer, one-, two- and four-byte
Strings... Also, I think the way I check makes the error messages quite clear
(int expected, String expected, etc).

I think it's cleaner this way :)

Powered by Google App Engine
This is Rietveld 408576698