| 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 library ddc.src.codegen.js_codegen; | 5 library ddc.src.codegen.js_codegen; |
| 6 | 6 |
| 7 import 'dart:io' show Directory, File; | 7 import 'dart:io' show Directory, File; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; | 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; |
| 10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; | 10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; |
| (...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 var methods = []; | 966 var methods = []; |
| 967 for (var node in fields) { | 967 for (var node in fields) { |
| 968 var name = node.name.name; | 968 var name = node.name.name; |
| 969 methods.add(new JS.Method(new JS.PropertyName(name), | 969 methods.add(new JS.Method(new JS.PropertyName(name), |
| 970 js.call('function() { return #; }', _visit(node.initializer)), | 970 js.call('function() { return #; }', _visit(node.initializer)), |
| 971 isGetter: true)); | 971 isGetter: true)); |
| 972 | 972 |
| 973 // TODO(jmesserly): use a dummy setter to indicate writable. | 973 // TODO(jmesserly): use a dummy setter to indicate writable. |
| 974 if (!node.isFinal) { | 974 if (!node.isFinal) { |
| 975 methods.add(new JS.Method( | 975 methods.add(new JS.Method( |
| 976 new JS.PropertyName(name), js.call('function() {}'), | 976 new JS.PropertyName(name), js.call('function(_) {}'), |
| 977 isSetter: true)); | 977 isSetter: true)); |
| 978 } | 978 } |
| 979 } | 979 } |
| 980 | 980 |
| 981 return js.statement( | 981 return js.statement( |
| 982 'dart.defineLazyProperties(#, { # })', [objExpr, methods]); | 982 'dart.defineLazyProperties(#, { # })', [objExpr, methods]); |
| 983 } | 983 } |
| 984 | 984 |
| 985 void _flushLibraryProperties(List<JS.Statement> body) { | 985 void _flushLibraryProperties(List<JS.Statement> body) { |
| 986 if (_properties.isEmpty) return; | 986 if (_properties.isEmpty) return; |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1852 | 1852 |
| 1853 // TODO(jmesserly): in many cases marking the end will be unncessary. | 1853 // TODO(jmesserly): in many cases marking the end will be unncessary. |
| 1854 printer.mark(_location(node.end)); | 1854 printer.mark(_location(node.end)); |
| 1855 } | 1855 } |
| 1856 | 1856 |
| 1857 String _getIdentifier(AstNode node) { | 1857 String _getIdentifier(AstNode node) { |
| 1858 if (node is SimpleIdentifier) return node.name; | 1858 if (node is SimpleIdentifier) return node.name; |
| 1859 return null; | 1859 return null; |
| 1860 } | 1860 } |
| 1861 } | 1861 } |
| OLD | NEW |