| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 if (declaredVariables.contains(name)) continue; | 177 if (declaredVariables.contains(name)) continue; |
| 178 js.VariableInitialization jsVariable = new js.VariableInitialization( | 178 js.VariableInitialization jsVariable = new js.VariableInitialization( |
| 179 new js.VariableDeclaration(name), | 179 new js.VariableDeclaration(name), |
| 180 null); | 180 null); |
| 181 jsVariables.add(jsVariable); | 181 jsVariables.add(jsVariable); |
| 182 } | 182 } |
| 183 | 183 |
| 184 if (jsVariables.length > 0) { | 184 if (jsVariables.length > 0) { |
| 185 // Would be nice to avoid inserting at the beginning of list. | 185 // Would be nice to avoid inserting at the beginning of list. |
| 186 accumulator.insert(0, new js.ExpressionStatement( | 186 accumulator.insert(0, new js.ExpressionStatement( |
| 187 new js.VariableDeclarationList(jsVariables))); | 187 new js.VariableDeclarationList(jsVariables) |
| 188 .withSourceInformation(function.sourceInformation))); |
| 188 } | 189 } |
| 189 return new js.Fun(parameters, new js.Block(accumulator)); | 190 return new js.Fun(parameters, new js.Block(accumulator)); |
| 190 } | 191 } |
| 191 | 192 |
| 192 @override | 193 @override |
| 193 js.Expression visitExpression(tree_ir.Expression node) { | 194 js.Expression visitExpression(tree_ir.Expression node) { |
| 194 js.Expression result = node.accept(this); | 195 js.Expression result = node.accept(this); |
| 195 if (result == null) { | 196 if (result == null) { |
| 196 glue.reportInternalError('$node did not produce code.'); | 197 glue.reportInternalError('$node did not produce code.'); |
| 197 } | 198 } |
| (...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 void registerDefaultParameterValues(ExecutableElement element) { | 1244 void registerDefaultParameterValues(ExecutableElement element) { |
| 1244 if (element is! FunctionElement) return; | 1245 if (element is! FunctionElement) return; |
| 1245 FunctionElement function = element; | 1246 FunctionElement function = element; |
| 1246 if (function.isStatic) return; // Defaults are inlined at call sites. | 1247 if (function.isStatic) return; // Defaults are inlined at call sites. |
| 1247 function.functionSignature.forEachOptionalParameter((param) { | 1248 function.functionSignature.forEachOptionalParameter((param) { |
| 1248 ConstantValue constant = glue.getDefaultParameterValue(param); | 1249 ConstantValue constant = glue.getDefaultParameterValue(param); |
| 1249 registry.registerCompileTimeConstant(constant); | 1250 registry.registerCompileTimeConstant(constant); |
| 1250 }); | 1251 }); |
| 1251 } | 1252 } |
| 1252 } | 1253 } |
| OLD | NEW |