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_metalet; | 5 library dev_compiler.src.codegen.js_metalet; |
6 | 6 |
7 // TODO(jmesserly): import from its own package | 7 // TODO(jmesserly): import from its own package |
8 import 'package:dev_compiler/src/js/js_ast.dart'; | 8 import 'package:dev_compiler/src/js/js_ast.dart'; |
9 import 'package:dev_compiler/src/js/precedence.dart'; | 9 import 'package:dev_compiler/src/js/precedence.dart'; |
10 | 10 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 accept(NodeVisitor visitor) => toExpression().accept(visitor); | 123 accept(NodeVisitor visitor) => toExpression().accept(visitor); |
124 | 124 |
125 void visitChildren(NodeVisitor visitor) { | 125 void visitChildren(NodeVisitor visitor) { |
126 toExpression().visitChildren(visitor); | 126 toExpression().visitChildren(visitor); |
127 } | 127 } |
128 | 128 |
129 /// This generates as either a comma expression or a call. | 129 /// This generates as either a comma expression or a call. |
130 int get precedenceLevel => variables.isEmpty ? EXPRESSION : CALL; | 130 int get precedenceLevel => variables.isEmpty ? EXPRESSION : CALL; |
131 | 131 |
132 Block _finishStatement(List<Statement> statements) { | 132 Block _finishStatement(List<Statement> statements) { |
133 var params = []; | 133 var params = <TemporaryId>[]; |
134 var values = []; | 134 var values = <Expression>[]; |
135 var block = _build(params, values, new Block(statements)); | 135 var block = _build(params, values, new Block(statements)); |
136 if (params.isEmpty) return block; | 136 if (params.isEmpty) return block; |
137 | 137 |
138 var vars = []; | 138 var vars = []; |
139 for (int i = 0; i < params.length; i++) { | 139 for (int i = 0; i < params.length; i++) { |
140 vars.add(new VariableInitialization(params[i], values[i])); | 140 vars.add(new VariableInitialization(params[i], values[i])); |
141 } | 141 } |
142 | 142 |
143 return new Block(<Statement>[ | 143 return new Block(<Statement>[ |
144 new VariableDeclarationList('let', vars).toStatement(), | 144 new VariableDeclarationList('let', vars).toStatement(), |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 bool found = false; | 241 bool found = false; |
242 _IdentFinder(this.name); | 242 _IdentFinder(this.name); |
243 | 243 |
244 visitIdentifier(Identifier node) { | 244 visitIdentifier(Identifier node) { |
245 if (node.name == name) found = true; | 245 if (node.name == name) found = true; |
246 } | 246 } |
247 visitNode(Node node) { | 247 visitNode(Node node) { |
248 if (!found) super.visitNode(node); | 248 if (!found) super.visitNode(node); |
249 } | 249 } |
250 } | 250 } |
OLD | NEW |