Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:collection' show HashMap, HashSet; | 5 import 'dart:collection' show HashMap, HashSet; |
| 6 import 'dart:math' show min, max; | 6 import 'dart:math' show min, max; |
| 7 | 7 |
| 8 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 8 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType; | 10 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType; |
| (...skipping 3387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3398 | 3398 |
| 3399 _loader.startCheckingReferences(); | 3399 _loader.startCheckingReferences(); |
| 3400 JS.Expression jsInit = _visitInitializer(field); | 3400 JS.Expression jsInit = _visitInitializer(field); |
| 3401 bool isLoaded = _loader.finishCheckingReferences(); | 3401 bool isLoaded = _loader.finishCheckingReferences(); |
| 3402 | 3402 |
| 3403 bool eagerInit = | 3403 bool eagerInit = |
| 3404 isLoaded && (field.isConst || _constField.isFieldInitConstant(field)); | 3404 isLoaded && (field.isConst || _constField.isFieldInitConstant(field)); |
| 3405 | 3405 |
| 3406 var fieldName = field.name.name; | 3406 var fieldName = field.name.name; |
| 3407 if (eagerInit && | 3407 if (eagerInit && |
| 3408 !JS.invalidStaticFieldName(fieldName) && | 3408 !JS.invalidStaticFieldName(fieldName) && |
|
Jennifer Messerly
2016/06/15 20:28:53
So this check above was supposed to handle the inv
stanm
2016/06/15 20:51:05
Done.
| |
| 3409 !staticFieldOverrides.contains(element)) { | 3409 !staticFieldOverrides.contains(element)) { |
| 3410 return annotate( | 3410 return annotate( |
| 3411 js.statement('#.# = #;', [ | 3411 js.statement('Object.defineProperty(#, #, { value: # });', [ |
|
stanm
2016/06/15 20:51:40
Reverted in second patch set.
| |
| 3412 _emitTopLevelName(classElem), | 3412 _emitTopLevelName(classElem), |
| 3413 _emitMemberName(fieldName, isStatic: true), | 3413 _emitMemberName(fieldName, isStatic: true), |
| 3414 jsInit | 3414 jsInit |
| 3415 ]), | 3415 ]), |
| 3416 field, | 3416 field, |
| 3417 field.element); | 3417 field.element); |
| 3418 } | 3418 } |
| 3419 | 3419 |
| 3420 // This means it should be treated as a lazy field. | 3420 // This means it should be treated as a lazy field. |
| 3421 // TODO(jmesserly): we're throwing away the initializer expression, | 3421 // TODO(jmesserly): we're throwing away the initializer expression, |
| (...skipping 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5132 } | 5132 } |
| 5133 | 5133 |
| 5134 bool isLibraryPrefix(Expression node) => | 5134 bool isLibraryPrefix(Expression node) => |
| 5135 node is SimpleIdentifier && node.staticElement is PrefixElement; | 5135 node is SimpleIdentifier && node.staticElement is PrefixElement; |
| 5136 | 5136 |
| 5137 LibraryElement _getLibrary(AnalysisContext c, String uri) => | 5137 LibraryElement _getLibrary(AnalysisContext c, String uri) => |
| 5138 c.computeLibraryElement(c.sourceFactory.forUri(uri)); | 5138 c.computeLibraryElement(c.sourceFactory.forUri(uri)); |
| 5139 | 5139 |
| 5140 bool _isDartRuntime(LibraryElement l) => | 5140 bool _isDartRuntime(LibraryElement l) => |
| 5141 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; | 5141 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; |
| OLD | NEW |