| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class Interceptors { | 5 class Interceptors { |
| 6 Compiler compiler; | 6 Compiler compiler; |
| 7 Interceptors(Compiler this.compiler); | 7 Interceptors(Compiler this.compiler); |
| 8 | 8 |
| 9 SourceString mapOperatorToMethodName(Operator op) { | 9 SourceString mapOperatorToMethodName(Operator op) { |
| 10 String name = op.source.stringValue; | 10 String name = op.source.stringValue; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } | 232 } |
| 233 HForeignNew newObject = new HForeignNew(classElement, fieldValues); | 233 HForeignNew newObject = new HForeignNew(classElement, fieldValues); |
| 234 add(newObject); | 234 add(newObject); |
| 235 | 235 |
| 236 // Call the method body. | 236 // Call the method body. |
| 237 SourceString methodName = compiler.namer.getConstructorName(bodyElement); | 237 SourceString methodName = compiler.namer.getConstructorName(bodyElement); |
| 238 | 238 |
| 239 List bodyCallInputs = <HInstruction>[]; | 239 List bodyCallInputs = <HInstruction>[]; |
| 240 bodyCallInputs.add(newObject); | 240 bodyCallInputs.add(newObject); |
| 241 for (Link link = parameters.nodes; !link.isEmpty(); link = link.tail) { | 241 for (Link link = parameters.nodes; !link.isEmpty(); link = link.tail) { |
| 242 Link<Node> identifierLink = link.head.definitions.nodes; | 242 Link<Node> nodeLink = link.head.definitions.nodes; |
| 243 // We expect exactly one identifier. | 243 // We expect exactly one identifier. |
| 244 assert(!identifierLink.isEmpty() && identifierLink.tail.isEmpty()); | 244 assert(!nodeLink.isEmpty() && nodeLink.tail.isEmpty()); |
| 245 if (identifierLink.head is !Identifier) { | 245 Node current = nodeLink.head; |
| 246 compiler.unimplemented("SsaBuilder.buildFactory non-identifier"); | 246 Element parameterElement = elements[current]; |
| 247 } | |
| 248 Identifier name = identifierLink.head; | |
| 249 Element parameterElement = elements[name]; | |
| 250 HInstruction currentValue = definitions[parameterElement]; | 247 HInstruction currentValue = definitions[parameterElement]; |
| 251 bodyCallInputs.add(currentValue); | 248 bodyCallInputs.add(currentValue); |
| 252 } | 249 } |
| 253 add(new HInvokeDynamicMethod(methodName, bodyCallInputs)); | 250 add(new HInvokeDynamicMethod(methodName, bodyCallInputs)); |
| 254 close(new HReturn(newObject)).addSuccessor(graph.exit); | 251 close(new HReturn(newObject)).addSuccessor(graph.exit); |
| 255 return closeFunction(); | 252 return closeFunction(); |
| 256 } | 253 } |
| 257 | 254 |
| 258 void openFunction(FunctionElement functionElement) { | 255 void openFunction(FunctionElement functionElement) { |
| 259 stack = new List<HInstruction>(); | 256 stack = new List<HInstruction>(); |
| 260 definitions = new Map<Element, HInstruction>(); | 257 definitions = new Map<Element, HInstruction>(); |
| 261 | 258 |
| 262 graph = new HGraph(); | 259 graph = new HGraph(); |
| 263 HBasicBlock block = graph.addNewBlock(); | 260 HBasicBlock block = graph.addNewBlock(); |
| 264 | 261 |
| 265 open(graph.entry); | 262 open(graph.entry); |
| 266 if (functionElement.isInstanceMember()) { | 263 if (functionElement.isInstanceMember()) { |
| 267 thisDefinition = new HThis(); | 264 thisDefinition = new HThis(); |
| 268 add(thisDefinition); | 265 add(thisDefinition); |
| 269 } | 266 } |
| 270 FunctionExpression function = functionElement.parseNode(compiler, compiler); | 267 FunctionExpression function = functionElement.parseNode(compiler, compiler); |
| 271 visitParameterValues(function.parameters); | 268 handleParameterValues(function.parameters); |
| 272 close(new HGoto()).addSuccessor(block); | 269 close(new HGoto()).addSuccessor(block); |
| 273 | 270 |
| 274 open(block); | 271 open(block); |
| 275 } | 272 } |
| 276 | 273 |
| 277 HGraph closeFunction() { | 274 HGraph closeFunction() { |
| 278 // TODO(kasperl): Make this goto an implicit return. | 275 // TODO(kasperl): Make this goto an implicit return. |
| 279 if (!isAborted()) close(new HGoto()).addSuccessor(graph.exit); | 276 if (!isAborted()) close(new HGoto()).addSuccessor(graph.exit); |
| 280 graph.finalize(); | 277 graph.finalize(); |
| 281 return graph; | 278 return graph; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 HBoolify popBoolified() { | 322 HBoolify popBoolified() { |
| 326 HBoolify boolified = new HBoolify(pop()); | 323 HBoolify boolified = new HBoolify(pop()); |
| 327 add(boolified); | 324 add(boolified); |
| 328 return boolified; | 325 return boolified; |
| 329 } | 326 } |
| 330 | 327 |
| 331 void visit(Node node) { | 328 void visit(Node node) { |
| 332 if (node !== null) node.accept(this); | 329 if (node !== null) node.accept(this); |
| 333 } | 330 } |
| 334 | 331 |
| 335 visitParameterValues(NodeList parameters) { | 332 handleParameterValues(NodeList parameters) { |
| 336 int parameterIndex = 0; | 333 int parameterIndex = 0; |
| 337 for (Link<Node> link = parameters.nodes; | 334 for (Link<Node> link = parameters.nodes; |
| 338 !link.isEmpty(); | 335 !link.isEmpty(); |
| 339 link = link.tail) { | 336 link = link.tail) { |
| 340 VariableDefinitions container = link.head; | 337 VariableDefinitions container = link.head; |
| 341 Link<Node> identifierLink = container.definitions.nodes; | 338 Link<Node> nodeLink = container.definitions.nodes; |
| 342 // The identifier link must contain exactly one argument. | 339 // The identifier link must contain exactly one argument. |
| 343 assert(!identifierLink.isEmpty() && identifierLink.tail.isEmpty()); | 340 assert(!nodeLink.isEmpty() && nodeLink.tail.isEmpty()); |
| 344 if (identifierLink.head is !Identifier) { | 341 Node current = nodeLink.head; |
| 345 compiler.unimplemented( | 342 VariableElement element = elements[current]; |
| 346 "SsaBuilder.visitParameterValues non-identifier", node: parameters); | |
| 347 } | |
| 348 Identifier parameterId = identifierLink.head; | |
| 349 VariableElement element = elements[parameterId]; | |
| 350 HParameterValue parameter = new HParameterValue(element); | 343 HParameterValue parameter = new HParameterValue(element); |
| 351 add(parameter); | 344 add(parameter); |
| 352 definitions[element] = parameter; | 345 definitions[element] = parameter; |
| 353 } | 346 } |
| 354 } | 347 } |
| 355 | 348 |
| 356 visitBlock(Block node) { | 349 visitBlock(Block node) { |
| 357 for (Link<Node> link = node.statements.nodes; | 350 for (Link<Node> link = node.statements.nodes; |
| 358 !link.isEmpty(); | 351 !link.isEmpty(); |
| 359 link = link.tail) { | 352 link = link.tail) { |
| (...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 } | 1403 } |
| 1411 | 1404 |
| 1412 visitCatchBlock(CatchBlock node) { | 1405 visitCatchBlock(CatchBlock node) { |
| 1413 compiler.unimplemented('SsaBuilder.visitCatchBlock', node: node); | 1406 compiler.unimplemented('SsaBuilder.visitCatchBlock', node: node); |
| 1414 } | 1407 } |
| 1415 | 1408 |
| 1416 visitTypedef(Typedef node) { | 1409 visitTypedef(Typedef node) { |
| 1417 compiler.unimplemented('SsaBuilder.visitTypedef', node: node); | 1410 compiler.unimplemented('SsaBuilder.visitTypedef', node: node); |
| 1418 } | 1411 } |
| 1419 } | 1412 } |
| OLD | NEW |