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 | 2 |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 import 'dart:collection' show HashMap, HashSet; | 6 import 'dart:collection' show HashMap, HashSet; |
7 import 'dart:math' show min, max; | 7 import 'dart:math' show min, max; |
8 | 8 |
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 List<JS.Method> _emitVirtualFieldAccessor(VariableDeclaration field, | 1481 List<JS.Method> _emitVirtualFieldAccessor(VariableDeclaration field, |
1482 Map<FieldElement, JS.TemporaryId> virtualFields) { | 1482 Map<FieldElement, JS.TemporaryId> virtualFields) { |
1483 var virtualField = virtualFields[field.element]; | 1483 var virtualField = virtualFields[field.element]; |
1484 var result = <JS.Method>[]; | 1484 var result = <JS.Method>[]; |
1485 var name = _emitMemberName(field.element.name, | 1485 var name = _emitMemberName(field.element.name, |
1486 type: (field.element.enclosingElement as ClassElement).type); | 1486 type: (field.element.enclosingElement as ClassElement).type); |
1487 var getter = js.call('function() { return this[#]; }', [virtualField]); | 1487 var getter = js.call('function() { return this[#]; }', [virtualField]); |
1488 result.add(new JS.Method(name, getter, isGetter: true)); | 1488 result.add(new JS.Method(name, getter, isGetter: true)); |
1489 | 1489 |
1490 if (field.isFinal) { | 1490 if (field.isFinal) { |
| 1491 // TODO(jmesserly): vsm@ commented that this seems unnecessary if we |
| 1492 // don't have a super setter. I'm not sure either why this code was |
| 1493 // introduced. |
1491 var setter = js.call('function(value) { super[#] = value; }', [name]); | 1494 var setter = js.call('function(value) { super[#] = value; }', [name]); |
1492 result.add(new JS.Method(name, setter, isSetter: true)); | 1495 result.add(new JS.Method(name, setter, isSetter: true)); |
1493 } else { | 1496 } else { |
1494 var setter = | 1497 var setter = |
1495 js.call('function(value) { this[#] = value; }', [virtualField]); | 1498 js.call('function(value) { this[#] = value; }', [virtualField]); |
1496 result.add(new JS.Method(name, setter, isSetter: true)); | 1499 result.add(new JS.Method(name, setter, isSetter: true)); |
1497 } | 1500 } |
1498 | 1501 |
1499 return result; | 1502 return result; |
1500 } | 1503 } |
(...skipping 4022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5523 } | 5526 } |
5524 | 5527 |
5525 bool isLibraryPrefix(Expression node) => | 5528 bool isLibraryPrefix(Expression node) => |
5526 node is SimpleIdentifier && node.staticElement is PrefixElement; | 5529 node is SimpleIdentifier && node.staticElement is PrefixElement; |
5527 | 5530 |
5528 LibraryElement _getLibrary(AnalysisContext c, String uri) => | 5531 LibraryElement _getLibrary(AnalysisContext c, String uri) => |
5529 c.computeLibraryElement(c.sourceFactory.forUri(uri)); | 5532 c.computeLibraryElement(c.sourceFactory.forUri(uri)); |
5530 | 5533 |
5531 bool _isDartRuntime(LibraryElement l) => | 5534 bool _isDartRuntime(LibraryElement l) => |
5532 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; | 5535 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; |
OLD | NEW |