| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 2250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2261 handleForeignJsCallInIsolate(node); | 2261 handleForeignJsCallInIsolate(node); |
| 2262 } else if (element.name == const SourceString('DART_CLOSURE_TO_JS')) { | 2262 } else if (element.name == const SourceString('DART_CLOSURE_TO_JS')) { |
| 2263 handleForeignDartClosureToJs(node); | 2263 handleForeignDartClosureToJs(node); |
| 2264 } else if (element.name == const SourceString('native')) { | 2264 } else if (element.name == const SourceString('native')) { |
| 2265 native.handleSsaNative(this, node); | 2265 native.handleSsaNative(this, node); |
| 2266 } else { | 2266 } else { |
| 2267 throw "Unknown foreign: ${node.selector}"; | 2267 throw "Unknown foreign: ${node.selector}"; |
| 2268 } | 2268 } |
| 2269 } | 2269 } |
| 2270 | 2270 |
| 2271 generateSuperNoSuchMethodSend(Send node) { |
| 2272 ClassElement cls = work.element.getEnclosingClass(); |
| 2273 Element element = cls.lookupSuperMember(Compiler.NO_SUCH_METHOD); |
| 2274 HStatic target = new HStatic(element); |
| 2275 add(target); |
| 2276 HInstruction self = localsHandler.readThis(); |
| 2277 Identifier identifier = node.selector.asIdentifier(); |
| 2278 String name = identifier.source.slowToString(); |
| 2279 // TODO(ahe): Add the arguments to this list. |
| 2280 push(new HLiteralList([])); |
| 2281 var inputs = <HInstruction>[ |
| 2282 target, |
| 2283 self, |
| 2284 graph.addConstantString(new DartString.literal(name), node), |
| 2285 pop()]; |
| 2286 push(new HInvokeSuper(Selector.INVOCATION_2, inputs)); |
| 2287 } |
| 2288 |
| 2271 visitSuperSend(Send node) { | 2289 visitSuperSend(Send node) { |
| 2272 Selector selector = elements.getSelector(node); | 2290 Selector selector = elements.getSelector(node); |
| 2273 Element element = elements[node]; | 2291 Element element = elements[node]; |
| 2274 if (element === null) { | 2292 if (element === null) return generateSuperNoSuchMethodSend(node); |
| 2275 ClassElement cls = work.element.getEnclosingClass(); | |
| 2276 element = cls.lookupSuperMember(Compiler.NO_SUCH_METHOD); | |
| 2277 HStatic target = new HStatic(element); | |
| 2278 add(target); | |
| 2279 HInstruction self = localsHandler.readThis(); | |
| 2280 Identifier identifier = node.selector.asIdentifier(); | |
| 2281 String name = identifier.source.slowToString(); | |
| 2282 // TODO(ahe): Add the arguments to this list. | |
| 2283 push(new HLiteralList([])); | |
| 2284 var inputs = <HInstruction>[ | |
| 2285 target, | |
| 2286 self, | |
| 2287 graph.addConstantString(new DartString.literal(name), node), | |
| 2288 pop()]; | |
| 2289 push(new HInvokeSuper(Selector.INVOCATION_2, inputs)); | |
| 2290 return; | |
| 2291 } | |
| 2292 HInstruction target = new HStatic(element); | 2293 HInstruction target = new HStatic(element); |
| 2293 HInstruction context = localsHandler.readThis(); | 2294 HInstruction context = localsHandler.readThis(); |
| 2294 add(target); | 2295 add(target); |
| 2295 var inputs = <HInstruction>[target, context]; | 2296 var inputs = <HInstruction>[target, context]; |
| 2296 if (node.isPropertyAccess) { | 2297 if (node.isPropertyAccess) { |
| 2297 push(new HInvokeSuper(selector, inputs)); | 2298 push(new HInvokeSuper(selector, inputs)); |
| 2298 } else if (element.kind == ElementKind.FUNCTION || | 2299 } else if (element.kind == ElementKind.FUNCTION || |
| 2299 element.kind == ElementKind.GENERATIVE_CONSTRUCTOR) { | 2300 element.kind == ElementKind.GENERATIVE_CONSTRUCTOR) { |
| 2300 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, | 2301 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, |
| 2301 element, inputs); | 2302 element, inputs); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2455 Constant constant = handler.compileNodeWithDefinitions(node, elements); | 2456 Constant constant = handler.compileNodeWithDefinitions(node, elements); |
| 2456 stack.add(graph.addConstant(constant)); | 2457 stack.add(graph.addConstant(constant)); |
| 2457 } else { | 2458 } else { |
| 2458 visitNewSend(node.send); | 2459 visitNewSend(node.send); |
| 2459 } | 2460 } |
| 2460 } | 2461 } |
| 2461 | 2462 |
| 2462 visitSendSet(SendSet node) { | 2463 visitSendSet(SendSet node) { |
| 2463 Operator op = node.assignmentOperator; | 2464 Operator op = node.assignmentOperator; |
| 2464 if (node.isSuperCall) { | 2465 if (node.isSuperCall) { |
| 2465 compiler.unimplemented('super property store', node: node); | 2466 Selector selector = elements.getSelector(node); |
| 2467 Element element = elements[node]; |
| 2468 if (element === null) return generateSuperNoSuchMethodSend(node); |
| 2469 HInstruction target = new HStatic(element); |
| 2470 HInstruction context = localsHandler.readThis(); |
| 2471 add(target); |
| 2472 var inputs = <HInstruction>[target, context]; |
| 2473 addDynamicSendArgumentsToList(node, inputs); |
| 2474 push(new HInvokeSuper(selector, inputs)); |
| 2466 } else if (node.isIndex) { | 2475 } else if (node.isIndex) { |
| 2467 if (!methodInterceptionEnabled) { | 2476 if (!methodInterceptionEnabled) { |
| 2468 assert(op.source.stringValue === '='); | 2477 assert(op.source.stringValue === '='); |
| 2469 visitDynamicSend(node); | 2478 visitDynamicSend(node); |
| 2470 } else { | 2479 } else { |
| 2471 HStatic target = new HStatic( | 2480 HStatic target = new HStatic( |
| 2472 interceptors.getIndexAssignmentInterceptor()); | 2481 interceptors.getIndexAssignmentInterceptor()); |
| 2473 add(target); | 2482 add(target); |
| 2474 visit(node.receiver); | 2483 visit(node.receiver); |
| 2475 HInstruction receiver = pop(); | 2484 HInstruction receiver = pop(); |
| (...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3405 <HInstruction>[target, input], | 3414 <HInstruction>[target, input], |
| 3406 HType.STRING)); | 3415 HType.STRING)); |
| 3407 return builder.pop(); | 3416 return builder.pop(); |
| 3408 } | 3417 } |
| 3409 | 3418 |
| 3410 HInstruction result(Node node) { | 3419 HInstruction result(Node node) { |
| 3411 flushLiterals(node); | 3420 flushLiterals(node); |
| 3412 return prefix; | 3421 return prefix; |
| 3413 } | 3422 } |
| 3414 } | 3423 } |
| OLD | NEW |