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

Issue 8231031: Check for compile-time constants in DartCompiler (Closed)

Created:
9 years, 2 months ago by zundel
Modified:
9 years, 1 month ago
CC:
reviews_dartlang.org, mmendez
Visibility:
Public.

Description

This adds checks for compile-time constants in places where the spec demands it: - initializing toplevel finals - initializing static final class members - initializing named parameters to functions Committed: https://code.google.com/p/dart/source/detail?r=468

Patch Set 1 : All tests pass but one junit test #

Total comments: 1

Patch Set 2 : Renamed CompileTimeConstTest to CTConst2Test #

Total comments: 62

Patch Set 3 : Incorporated feedback. #

Total comments: 22

Patch Set 4 : language.status should be updated #

Patch Set 5 : Feedback from floitsch #

Total comments: 18
Unified diffs Side-by-side diffs Delta from patch set Stats (+1170 lines, -161 lines) Patch
M client/samples/spirodraw/ColorPicker.dart View 1 chunk +1 line, -1 line 0 comments Download
M client/samples/sunflower/Sunflower.dart View 1 2 4 chunks +5 lines, -4 lines 0 comments Download
M client/samples/total/src/ClientChart.dart View 1 chunk +1 line, -1 line 0 comments Download
M compiler/java/com/google/dart/compiler/DartCompilerErrorCode.java View 1 2 2 chunks +7 lines, -1 line 0 comments Download
M compiler/java/com/google/dart/compiler/UnitTestBatchRunner.java View 1 2 1 chunk +4 lines, -1 line 0 comments Download
M compiler/java/com/google/dart/compiler/ast/DartExpression.java View 2 chunks +13 lines, -0 lines 4 comments Download
M compiler/java/com/google/dart/compiler/ast/DartIdentifier.java View 1 2 1 chunk +4 lines, -0 lines 0 comments Download
M compiler/java/com/google/dart/compiler/ast/DartNodeTraverser.java View 1 2 1 chunk +2 lines, -1 line 0 comments Download
A compiler/java/com/google/dart/compiler/resolver/CompileTimeConstVisitor.java View 1 2 3 4 1 chunk +393 lines, -0 lines 4 comments Download
M compiler/java/com/google/dart/compiler/resolver/MemberBuilder.java View 1 2 1 chunk +9 lines, -1 line 2 comments Download
M compiler/java/com/google/dart/compiler/resolver/Resolver.java View 1 2 3 4 6 chunks +31 lines, -24 lines 1 comment Download
M compiler/java/com/google/dart/compiler/resolver/TopLevelElementBuilder.java View 2 chunks +7 lines, -1 line 1 comment Download
M compiler/javatests/com/google/dart/compiler/backend/js/testFieldAccessExprOpt.dart View 1 2 3 1 chunk +2 lines, -2 lines 1 comment Download
M compiler/javatests/com/google/dart/compiler/end2end/inc/myother1.dart View 1 2 3 1 chunk +9 lines, -3 lines 0 comments Download
M compiler/javatests/com/google/dart/compiler/end2end/inc/myother1.change.dart View 1 2 3 1 chunk +2 lines, -3 lines 0 comments Download
M compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java View 1 2 chunks +2 lines, -2 lines 0 comments Download
A compiler/javatests/com/google/dart/compiler/resolver/CompileTimeConstantTest.java View 1 2 3 4 1 chunk +423 lines, -0 lines 0 comments Download
M compiler/javatests/com/google/dart/compiler/resolver/ResolverTestCase.java View 5 chunks +27 lines, -12 lines 0 comments Download
M compiler/javatests/com/google/dart/compiler/resolver/ResolverTests.java View 1 chunk +1 line, -1 line 0 comments Download
M compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerTest.java View 1 1 chunk +4 lines, -4 lines 0 comments Download
M samples/clock/Balls.dart View 1 chunk +1 line, -1 line 0 comments Download
M samples/clock/ClockNumbers.dart View 1 chunk +82 lines, -81 lines 0 comments Download
M tests/language/language.status View 1 2 3 4 5 chunks +5 lines, -5 lines 0 comments Download
A tests/language/src/CTConst2Test.dart View 1 2 1 chunk +106 lines, -0 lines 0 comments Download
M tests/language/src/ConstInitTest.dart View 1 1 chunk +2 lines, -0 lines 4 comments Download
M tests/language/src/ListLiteralTest.dart View 1 chunk +6 lines, -0 lines 0 comments Download
M tests/language/src/StaticFinalFieldTest.dart View 1 2 2 chunks +0 lines, -2 lines 0 comments Download
M tests/language/src/StringInterpolate2Test.dart View 1 2 3 4 2 chunks +8 lines, -3 lines 1 comment Download
M tests/language/src/StringInterpolateTest.dart View 1 2 1 chunk +5 lines, -2 lines 0 comments Download
A + tests/language/src/StringInterpolation7NegativeTest.dart View 1 2 3 4 1 chunk +8 lines, -5 lines 0 comments Download

Messages

Total messages: 18 (0 generated)
zundel
After a week long hiatus, I'm bringing back this patch, re-written to use the visitor ...
9 years, 2 months ago (2011-10-14 01:54:28 UTC) #1
ngeoffray
Initial comments. http://codereview.chromium.org/8231031/diff/11001/client/samples/sunflower/Sunflower.dart File client/samples/sunflower/Sunflower.dart (right): http://codereview.chromium.org/8231031/diff/11001/client/samples/sunflower/Sunflower.dart#newcode18 client/samples/sunflower/Sunflower.dart:18: PHI = (Math.sqrt(5)+1) / 2; Nit: spaces ...
9 years, 2 months ago (2011-10-14 09:26:56 UTC) #2
zundel
Thanks for slogging through it once. I'll put up another patch later. http://codereview.chromium.org/8231031/diff/11001/compiler/java/com/google/dart/compiler/resolver/Resolver.java File compiler/java/com/google/dart/compiler/resolver/Resolver.java ...
9 years, 2 months ago (2011-10-14 10:04:21 UTC) #3
ngeoffray
http://codereview.chromium.org/8231031/diff/11001/compiler/java/com/google/dart/compiler/resolver/Resolver.java File compiler/java/com/google/dart/compiler/resolver/Resolver.java (right): http://codereview.chromium.org/8231031/diff/11001/compiler/java/com/google/dart/compiler/resolver/Resolver.java#newcode390 compiler/java/com/google/dart/compiler/resolver/Resolver.java:390: checkConstantLiteral(expression); On 2011/10/14 10:04:21, zundel wrote: > On 2011/10/14 ...
9 years, 2 months ago (2011-10-14 10:33:42 UTC) #4
floitsch
FYI. http://codereview.chromium.org/8231031/diff/11001/compiler/java/com/google/dart/compiler/DartCompilerErrorCode.java File compiler/java/com/google/dart/compiler/DartCompilerErrorCode.java (right): http://codereview.chromium.org/8231031/diff/11001/compiler/java/com/google/dart/compiler/DartCompilerErrorCode.java#newcode64 compiler/java/com/google/dart/compiler/DartCompilerErrorCode.java:64: EXPECTED_CONSTANT_EXPRESSION_BOOLEAN("Expected constant expression of type boolean, got %s"), ...
9 years, 2 months ago (2011-10-14 14:36:58 UTC) #5
zundel
PTAL http://codereview.chromium.org/8231031/diff/11001/client/samples/sunflower/Sunflower.dart File client/samples/sunflower/Sunflower.dart (right): http://codereview.chromium.org/8231031/diff/11001/client/samples/sunflower/Sunflower.dart#newcode18 client/samples/sunflower/Sunflower.dart:18: PHI = (Math.sqrt(5)+1) / 2; On 2011/10/14 09:26:56, ...
9 years, 2 months ago (2011-10-14 20:59:51 UTC) #6
hausner
http://codereview.chromium.org/8231031/diff/11001/tests/language/src/StaticFinalFieldTest.dart File tests/language/src/StaticFinalFieldTest.dart (right): http://codereview.chromium.org/8231031/diff/11001/tests/language/src/StaticFinalFieldTest.dart#newcode32 tests/language/src/StaticFinalFieldTest.dart:32: // Compile time constants don't allow string interpolation. I ...
9 years, 2 months ago (2011-10-14 22:20:24 UTC) #7
floitsch
On 2011/10/14 20:59:51, zundel wrote: > Question: is it legal to have both a constant ...
9 years, 2 months ago (2011-10-14 22:42:08 UTC) #8
floitsch
Much better. Thanks. There is still the bug that fields must be written in the ...
9 years, 2 months ago (2011-10-14 22:46:15 UTC) #9
John Lenz
http://codereview.chromium.org/8231031/diff/16001/tests/language/language.status File tests/language/language.status (right): http://codereview.chromium.org/8231031/diff/16001/tests/language/language.status#newcode40 tests/language/language.status:40: StringInterpolationNegativeTest: Fail # Bug ??? Are you filing a ...
9 years, 2 months ago (2011-10-15 00:55:56 UTC) #10
zundel
Incorporated feedback. I'd like to defer the recursive evaluation of compile time constants for looking ...
9 years, 2 months ago (2011-10-17 02:56:02 UTC) #11
floitsch
http://codereview.chromium.org/8231031/diff/16001/tests/language/src/StringInterpolate2Test.dart File tests/language/src/StringInterpolate2Test.dart (right): http://codereview.chromium.org/8231031/diff/16001/tests/language/src/StringInterpolate2Test.dart#newcode31 tests/language/src/StringInterpolate2Test.dart:31: Expect.equals("8", '${fib.length}'); On 2011/10/17 02:56:02, zundel wrote: > On ...
9 years, 2 months ago (2011-10-17 07:28:34 UTC) #12
zundel
http://codereview.chromium.org/8231031/diff/28002/tests/language/src/StringInterpolate2Test.dart File tests/language/src/StringInterpolate2Test.dart (right): http://codereview.chromium.org/8231031/diff/28002/tests/language/src/StringInterpolate2Test.dart#newcode35 tests/language/src/StringInterpolate2Test.dart:35: length}'); (here's what I did with the test in ...
9 years, 2 months ago (2011-10-17 10:43:49 UTC) #13
floitsch
Please move failing tests into a separate file and mark them in the status-file instead. ...
9 years, 2 months ago (2011-10-17 10:50:39 UTC) #14
ngeoffray
LGTM! modulo the modifiers changes. Code looks good, and hopefully the tests cover most cases. ...
9 years, 2 months ago (2011-10-17 10:59:38 UTC) #15
zundel
Thanks for the review, committed as r468 I'll start looking at the problems with field ...
9 years, 2 months ago (2011-10-17 14:14:26 UTC) #16
mmendez
I came across the following issues while reviewing the latest compile-time constant patch, http://codereview.chromium.org/8523034. http://codereview.chromium.org/8231031/diff/28002/compiler/java/com/google/dart/compiler/ast/DartExpression.java ...
9 years, 1 month ago (2011-11-16 21:03:10 UTC) #17
zundel
9 years, 1 month ago (2011-11-16 21:38:24 UTC) #18
http://codereview.chromium.org/8231031/diff/28002/compiler/java/com/google/da...
File compiler/java/com/google/dart/compiler/ast/DartExpression.java (right):

http://codereview.chromium.org/8231031/diff/28002/compiler/java/com/google/da...
compiler/java/com/google/dart/compiler/ast/DartExpression.java:13: Type type;
On 2011/11/16 21:03:10, mmendez wrote:
> Nit: Should this be private?

Removed - see http://codereview.chromium.org/8523034

http://codereview.chromium.org/8231031/diff/28002/compiler/java/com/google/da...
compiler/java/com/google/dart/compiler/ast/DartExpression.java:25: @Override
On 2011/11/16 21:03:10, mmendez wrote:
> Nit: Since you added [set|get]Type here you might want to remove them from the
> DartLiteral node subtype.

Removed - see http://codereview.chromium.org/8523034

Powered by Google App Engine
This is Rietveld 408576698