OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 code_generator; | 5 library code_generator; |
6 | 6 |
7 import 'glue.dart'; | 7 import 'glue.dart'; |
8 | 8 |
9 import '../../closure.dart' show | 9 import '../../closure.dart' show |
10 ClosureClassElement; | 10 ClosureClassElement; |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 } | 363 } |
364 | 364 |
365 @override | 365 @override |
366 js.Expression visitLiteralList(tree_ir.LiteralList node) { | 366 js.Expression visitLiteralList(tree_ir.LiteralList node) { |
367 registry.registerInstantiatedClass(glue.listClass); | 367 registry.registerInstantiatedClass(glue.listClass); |
368 List<js.Expression> entries = visitExpressionList(node.values); | 368 List<js.Expression> entries = visitExpressionList(node.values); |
369 return new js.ArrayInitializer(entries); | 369 return new js.ArrayInitializer(entries); |
370 } | 370 } |
371 | 371 |
372 @override | 372 @override |
373 js.Expression visitLiteralMap(tree_ir.LiteralMap node) { | |
374 ConstructorElement constructor; | |
375 if (node.entries.isEmpty) { | |
376 constructor = glue.mapLiteralConstructorEmpty; | |
377 } else { | |
378 constructor = glue.mapLiteralConstructor; | |
379 } | |
380 List<js.Expression> entries = | |
381 new List<js.Expression>(2 * node.entries.length); | |
382 for (int i = 0; i < node.entries.length; i++) { | |
383 entries[2 * i] = visitExpression(node.entries[i].key); | |
384 entries[2 * i + 1] = visitExpression(node.entries[i].value); | |
385 } | |
386 List<js.Expression> args = entries.isEmpty | |
387 ? <js.Expression>[] | |
388 : <js.Expression>[new js.ArrayInitializer(entries)]; | |
389 return buildStaticInvoke(constructor, args); | |
390 } | |
391 | |
392 @override | |
393 js.Expression visitLogicalOperator(tree_ir.LogicalOperator node) { | 373 js.Expression visitLogicalOperator(tree_ir.LogicalOperator node) { |
394 return new js.Binary( | 374 return new js.Binary( |
395 node.operator, | 375 node.operator, |
396 visitExpression(node.left), | 376 visitExpression(node.left), |
397 visitExpression(node.right)); | 377 visitExpression(node.right)); |
398 } | 378 } |
399 | 379 |
400 @override | 380 @override |
401 js.Expression visitNot(tree_ir.Not node) { | 381 js.Expression visitNot(tree_ir.Not node) { |
402 return new js.Prefix("!", visitExpression(node.operand)); | 382 return new js.Prefix("!", visitExpression(node.operand)); |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 void registerDefaultParameterValues(ExecutableElement element) { | 1217 void registerDefaultParameterValues(ExecutableElement element) { |
1238 if (element is! FunctionElement) return; | 1218 if (element is! FunctionElement) return; |
1239 FunctionElement function = element; | 1219 FunctionElement function = element; |
1240 if (function.isStatic) return; // Defaults are inlined at call sites. | 1220 if (function.isStatic) return; // Defaults are inlined at call sites. |
1241 function.functionSignature.forEachOptionalParameter((param) { | 1221 function.functionSignature.forEachOptionalParameter((param) { |
1242 ConstantValue constant = glue.getDefaultParameterValue(param); | 1222 ConstantValue constant = glue.getDefaultParameterValue(param); |
1243 registry.registerCompileTimeConstant(constant); | 1223 registry.registerCompileTimeConstant(constant); |
1244 }); | 1224 }); |
1245 } | 1225 } |
1246 } | 1226 } |
OLD | NEW |