Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart2js.ir_builder_task; | 5 library dart2js.ir_builder_task; |
| 6 | 6 |
| 7 import '../closure.dart' as closurelib; | 7 import '../closure.dart' as closurelib; |
| 8 import '../closure.dart' hide ClosureScope; | 8 import '../closure.dart' hide ClosureScope; |
| 9 import '../constants/expressions.dart'; | 9 import '../constants/expressions.dart'; |
| 10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 } | 245 } |
| 246 return null; | 246 return null; |
| 247 } | 247 } |
| 248 | 248 |
| 249 ir.Primitive visitRethrow(ast.Rethrow node) { | 249 ir.Primitive visitRethrow(ast.Rethrow node) { |
| 250 assert(irBuilder.isOpen); | 250 assert(irBuilder.isOpen); |
| 251 irBuilder.buildRethrow(); | 251 irBuilder.buildRethrow(); |
| 252 return null; | 252 return null; |
| 253 } | 253 } |
| 254 | 254 |
| 255 /// Construct a method that executes the forwarding call to the target | |
| 256 /// constructor. This is only required, if the forwarding factory | |
| 257 /// constructor can potentially be the target of a reflective call, because | |
| 258 /// the builder shortcuts calls to redirecting factories at the call site | |
| 259 /// (see [JsIrBuilderVisitor.handleConstructorInvoke]). | |
| 260 visitRedirectingFactoryBody(ast.RedirectingFactoryBody node) { | |
| 261 ConstructorElement targetConstructor = | |
| 262 elements.getRedirectingTargetConstructor(node).implementation; | |
| 263 ConstructorElement redirectingConstructor = | |
| 264 irBuilder.state.currentElement.implementation; | |
| 265 List<ir.Primitive> inputs = <ir.Primitive>[]; | |
| 266 FunctionSignature targetSignature = targetConstructor.functionSignature; | |
| 267 FunctionSignature redirectingSignature = | |
| 268 redirectingConstructor.functionSignature; | |
| 269 redirectingSignature.forEachRequiredParameter((ParameterElement parameter) { | |
| 270 inputs.add(irBuilder.environment.lookup(parameter)); | |
| 271 }); | |
| 272 List<Element> targetOptionals = | |
| 273 targetSignature.orderedOptionalParameters; | |
| 274 List<Element> redirectingOptionals = | |
| 275 redirectingSignature.orderedOptionalParameters; | |
| 276 // TODO(karlklose): match named parameters correctly, once the mirror | |
| 277 // system implements them. | |
|
asgerf
2015/07/09 09:47:54
Please use normalizeStaticArguments and get rid of
| |
| 278 int i = 0; | |
| 279 for (; i < redirectingOptionals.length; i++) { | |
| 280 ParameterElement parameter = redirectingOptionals[i]; | |
| 281 inputs.add(irBuilder.environment.lookup(parameter)); | |
| 282 } | |
| 283 for (; i < targetOptionals.length; i++) { | |
| 284 ConstantValue constantValue = getConstantForVariable(targetOptionals[i]); | |
| 285 inputs.add(irBuilder.buildConstant(constantValue)); | |
| 286 } | |
| 287 ClassElement cls = redirectingConstructor.enclosingClass; | |
| 288 InterfaceType targetType = | |
| 289 redirectingConstructor.computeEffectiveTargetType(cls.thisType); | |
| 290 List<String> namedParameters = redirectingSignature.optionalParameters | |
| 291 .where((ParameterElement p) => p.isNamed) | |
| 292 .map((ParameterElement p) => p.name) | |
| 293 .toList(); | |
| 294 CallStructure callStructure = new CallStructure( | |
| 295 redirectingSignature.parameterCount, | |
| 296 namedParameters); | |
| 297 ir.Primitive instance = irBuilder.buildConstructorInvocation( | |
| 298 targetConstructor, | |
| 299 callStructure, | |
| 300 targetType, | |
| 301 inputs); | |
| 302 irBuilder.buildReturn(instance); | |
| 303 } | |
| 304 | |
| 255 visitFor(ast.For node) { | 305 visitFor(ast.For node) { |
| 256 List<LocalElement> loopVariables = <LocalElement>[]; | 306 List<LocalElement> loopVariables = <LocalElement>[]; |
| 257 if (node.initializer is ast.VariableDefinitions) { | 307 if (node.initializer is ast.VariableDefinitions) { |
| 258 ast.VariableDefinitions definitions = node.initializer; | 308 ast.VariableDefinitions definitions = node.initializer; |
| 259 for (ast.Node node in definitions.definitions.nodes) { | 309 for (ast.Node node in definitions.definitions.nodes) { |
| 260 LocalElement loopVariable = elements[node]; | 310 LocalElement loopVariable = elements[node]; |
| 261 loopVariables.add(loopVariable); | 311 loopVariables.add(loopVariable); |
| 262 } | 312 } |
| 263 } | 313 } |
| 264 | 314 |
| (...skipping 3018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3283 } | 3333 } |
| 3284 | 3334 |
| 3285 processSetStatic(ir.SetStatic node) { | 3335 processSetStatic(ir.SetStatic node) { |
| 3286 node.body = replacementFor(node.body); | 3336 node.body = replacementFor(node.body); |
| 3287 } | 3337 } |
| 3288 | 3338 |
| 3289 processContinuation(ir.Continuation node) { | 3339 processContinuation(ir.Continuation node) { |
| 3290 node.body = replacementFor(node.body); | 3340 node.body = replacementFor(node.body); |
| 3291 } | 3341 } |
| 3292 } | 3342 } |
| OLD | NEW |