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

Issue 11093078: - Add support for binary operators (Closed)

Created:
8 years, 2 months ago by polux
Modified:
8 years, 1 month ago
Reviewers:
karlklose, sra1
CC:
reviews_dartlang.org
Visibility:
Public.

Description

- Add support for binary operators - Add support for ad-hoc hardcoded typing rules - Add rules for int, double and num, for + and * I'd like your opinion on the general strategy before adding dozens of ad-hoc rules. So if you LGTM this CL, I'll add them in a later CL. Note: this is different from trusting the types from the signatures of, say, int's methods because we can overload some methods. Defaulting to trusting the types might be a good replacement for what currently returns Dynamic. Committed: https://code.google.com/p/dart/source/detail?r=14070

Patch Set 1 #

Total comments: 2

Patch Set 2 : Address sra's comments #

Patch Set 3 : sync to head #

Total comments: 16

Patch Set 4 : Address Karl's comments. #

Patch Set 5 : Forgot one comment. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+202 lines, -10 lines) Patch
M lib/compiler/implementation/types/concrete_types_inferrer.dart View 1 2 3 12 chunks +124 lines, -6 lines 0 comments Download
M tests/compiler/dart2js/cpa_inference_test.dart View 1 2 3 4 5 chunks +75 lines, -1 line 0 comments Download
M tests/compiler/dart2js/mock_compiler.dart View 1 2 3 4 1 chunk +3 lines, -3 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
polux
8 years, 2 months ago (2012-10-11 16:19:25 UTC) #1
sra1
https://chromiumcodereview.appspot.com/11093078/diff/1/lib/compiler/implementation/types/concrete_types_inferrer.dart File lib/compiler/implementation/types/concrete_types_inferrer.dart (right): https://chromiumcodereview.appspot.com/11093078/diff/1/lib/compiler/implementation/types/concrete_types_inferrer.dart#newcode498 lib/compiler/implementation/types/concrete_types_inferrer.dart:498: }); Since you are populating a cache, it might ...
8 years, 2 months ago (2012-10-12 05:00:51 UTC) #2
polux
I am now almost convinced this is not the right way to go eventually: I ...
8 years, 2 months ago (2012-10-18 10:30:13 UTC) #3
karlklose
LGTM with a few comments. http://codereview.chromium.org/11093078/diff/7001/lib/compiler/implementation/types/concrete_types_inferrer.dart File lib/compiler/implementation/types/concrete_types_inferrer.dart (right): http://codereview.chromium.org/11093078/diff/7001/lib/compiler/implementation/types/concrete_types_inferrer.dart#newcode434 lib/compiler/implementation/types/concrete_types_inferrer.dart:434: return product.iterator().next(); Can we ...
8 years, 2 months ago (2012-10-23 10:58:15 UTC) #4
polux
8 years, 1 month ago (2012-10-25 12:02:01 UTC) #5
http://codereview.chromium.org/11093078/diff/7001/lib/compiler/implementation...
File lib/compiler/implementation/types/concrete_types_inferrer.dart (right):

http://codereview.chromium.org/11093078/diff/7001/lib/compiler/implementation...
lib/compiler/implementation/types/concrete_types_inferrer.dart:434: return
product.iterator().next();
Absolutely! Done.

On 2012/10/23 10:58:15, karlklose wrote:
> Can we construct this object more directly instead of using the product
> iterator?

http://codereview.chromium.org/11093078/diff/7001/lib/compiler/implementation...
lib/compiler/implementation/types/concrete_types_inferrer.dart:443: if
(receiverType.element.resolutionState == STATE_NOT_STARTED) {
On 2012/10/23 10:58:15, karlklose wrote:
> use ensureResolved?

Done.

http://codereview.chromium.org/11093078/diff/7001/lib/compiler/implementation...
lib/compiler/implementation/types/concrete_types_inferrer.dart:1290: final
Set<SourceString> operators = new Set<SourceString>()
On 2012/10/23 10:58:15, karlklose wrote:
> When all operators are supported, we should be able to share this list with
> other places that work on operators. Can you add a comment (for me)?

Done.

http://codereview.chromium.org/11093078/diff/7001/lib/compiler/implementation...
lib/compiler/implementation/types/concrete_types_inferrer.dart:1323:
SourceString canonicalize(SourceString s) {
On 2012/10/23 10:58:15, karlklose wrote:
> Perhaps 'canonicalMethodName'?

Done.

http://codereview.chromium.org/11093078/diff/7001/lib/compiler/implementation...
lib/compiler/implementation/types/concrete_types_inferrer.dart:1351: if (method
!== null) {
On 2012/10/23 10:58:15, karlklose wrote:
> Use != instead of !==.

Done.

http://codereview.chromium.org/11093078/diff/7001/tests/compiler/dart2js/cpa_...
File tests/compiler/dart2js/cpa_inference_test.dart (right):

http://codereview.chromium.org/11093078/diff/7001/tests/compiler/dart2js/cpa_...
tests/compiler/dart2js/cpa_inference_test.dart:375: testArith() {
On 2012/10/23 10:58:15, karlklose wrote:
> testArith -> testArithmethicOperators.

Done.

http://codereview.chromium.org/11093078/diff/7001/tests/compiler/dart2js/cpa_...
tests/compiler/dart2js/cpa_inference_test.dart:387: a; b; c; d; e; f; g; h;
On 2012/10/23 10:58:15, karlklose wrote:
> Can you add positive nesting tests, like (1 op 2) op 3 (and the same for num)?

Done.

http://codereview.chromium.org/11093078/diff/7001/tests/compiler/dart2js/mock...
File tests/compiler/dart2js/mock_compiler.dart (right):

http://codereview.chromium.org/11093078/diff/7001/tests/compiler/dart2js/mock...
tests/compiler/dart2js/mock_compiler.dart:58: abstract class num { operator
+(x); operator *(x); operator -(x); }
On 2012/10/23 10:58:15, karlklose wrote:
> I am not sure we want to add these operators here. Perhaps we can use a local
> mock core library in the inference test?

Done.

Powered by Google App Engine
This is Rietveld 408576698