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 dev_compiler.src.codegen.js_codegen; | 5 library dev_compiler.src.codegen.js_codegen; |
6 | 6 |
7 import 'dart:collection' show HashSet, HashMap; | 7 import 'dart:collection' show HashSet, HashMap; |
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 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2154 visitRethrowExpression(RethrowExpression node) { | 2154 visitRethrowExpression(RethrowExpression node) { |
2155 if (node.parent is ExpressionStatement) { | 2155 if (node.parent is ExpressionStatement) { |
2156 return js.statement('throw #;', _visit(_catchParameter)); | 2156 return js.statement('throw #;', _visit(_catchParameter)); |
2157 } else { | 2157 } else { |
2158 return js.call('dart.throw_(#)', _visit(_catchParameter)); | 2158 return js.call('dart.throw_(#)', _visit(_catchParameter)); |
2159 } | 2159 } |
2160 } | 2160 } |
2161 | 2161 |
2162 @override | 2162 @override |
2163 JS.If visitIfStatement(IfStatement node) { | 2163 JS.If visitIfStatement(IfStatement node) { |
2164 return new JS.If(_visit(node.condition), _visit(node.thenStatement), | 2164 return new JS.If(_visit(node.condition), _visit(node.thenStatement), |
vsm
2015/06/04 17:07:32
E.g., s/_visit(node.condition)/notNull(node.condit
Jennifer Messerly
2015/06/04 21:54:18
Done.
| |
2165 _visit(node.elseStatement)); | 2165 _visit(node.elseStatement)); |
2166 } | 2166 } |
2167 | 2167 |
2168 @override | 2168 @override |
2169 JS.For visitForStatement(ForStatement node) { | 2169 JS.For visitForStatement(ForStatement node) { |
2170 var init = _visit(node.initialization); | 2170 var init = _visit(node.initialization); |
2171 if (init == null) init = _visit(node.variables); | 2171 if (init == null) init = _visit(node.variables); |
2172 var update = _visitListToBinary(node.updaters, ','); | 2172 var update = _visitListToBinary(node.updaters, ','); |
2173 if (update != null) update = update.toVoidExpression(); | 2173 if (update != null) update = update.toVoidExpression(); |
2174 return new JS.For(init, _visit(node.condition), update, _visit(node.body)); | 2174 return new JS.For(init, _visit(node.condition), update, _visit(node.body)); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2464 /// Point(x, y) { | 2464 /// Point(x, y) { |
2465 /// this[_x] = x; | 2465 /// this[_x] = x; |
2466 /// this[_y] = y; | 2466 /// this[_y] = y; |
2467 /// } | 2467 /// } |
2468 /// get x() { return this[_x]; } | 2468 /// get x() { return this[_x]; } |
2469 /// get y() { return this[_y]; } | 2469 /// get y() { return this[_y]; } |
2470 /// } | 2470 /// } |
2471 /// | 2471 /// |
2472 /// For user-defined operators the following names are allowed: | 2472 /// For user-defined operators the following names are allowed: |
2473 /// | 2473 /// |
2474 /// <, >, <=, >=, ==, -, +, /, ˜/, *, %, |, ˆ, &, <<, >>, []=, [], ˜ | 2474 /// <, >, <=, >=, ==, -, +, /, ~/, *, %, |, ^, &, <<, >>, []=, [], ~ |
2475 /// | 2475 /// |
2476 /// They generate code like: | 2476 /// They generate code like: |
2477 /// | 2477 /// |
2478 /// x['+'](y) | 2478 /// x['+'](y) |
2479 /// | 2479 /// |
2480 /// There are three exceptions: [], []= and unary -. | 2480 /// There are three exceptions: [], []= and unary -. |
2481 /// The indexing operators we use `get` and `set` instead: | 2481 /// The indexing operators we use `get` and `set` instead: |
2482 /// | 2482 /// |
2483 /// x.get('hi') | 2483 /// x.get('hi') |
2484 /// x.set('hi', 123) | 2484 /// x.set('hi', 123) |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2650 | 2650 |
2651 /// A special kind of element created by the compiler, signifying a temporary | 2651 /// A special kind of element created by the compiler, signifying a temporary |
2652 /// variable. These objects use instance equality, and should be shared | 2652 /// variable. These objects use instance equality, and should be shared |
2653 /// everywhere in the tree where they are treated as the same variable. | 2653 /// everywhere in the tree where they are treated as the same variable. |
2654 class TemporaryVariableElement extends LocalVariableElementImpl { | 2654 class TemporaryVariableElement extends LocalVariableElementImpl { |
2655 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); | 2655 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); |
2656 | 2656 |
2657 int get hashCode => identityHashCode(this); | 2657 int get hashCode => identityHashCode(this); |
2658 bool operator ==(Object other) => identical(this, other); | 2658 bool operator ==(Object other) => identical(this, other); |
2659 } | 2659 } |
OLD | NEW |