| 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 // VMOptions=-DUSE_CPS_IR=true | 4 // VMOptions=-DUSE_CPS_IR=true |
| 5 | 5 |
| 6 // Tests of interceptors. | 6 // Tests of interceptors. |
| 7 | 7 |
| 8 library supercall_test; | 8 library supercall_test; |
| 9 | 9 |
| 10 import 'js_backend_cps_ir.dart'; | 10 import 'js_backend_cps_ir.dart'; |
| 11 | 11 |
| 12 const List<TestEntry> tests = const [ | 12 const List<TestEntry> tests = const [ |
| 13 const TestEntry.forMethod('function(Sub#m)', """ | 13 const TestEntry.forMethod('function(Sub#m)', """ |
| 14 class Base { | 14 class Base { |
| 15 m(x) { | 15 m(x) { |
| 16 print(x+1); | 16 print(x+1); |
| 17 } | 17 } |
| 18 } | 18 } |
| 19 class Sub extends Base { | 19 class Sub extends Base { |
| 20 m(x) => super.m(x+10); | 20 m(x) => super.m(x+10); |
| 21 } | 21 } |
| 22 main() { | 22 main() { |
| 23 new Sub().m(100); | 23 new Sub().m(100); |
| 24 }""", | 24 }""", |
| 25 r""" | 25 r""" |
| 26 function(x) { | 26 function(x) { |
| 27 var v0, v1; | 27 return V.Base.prototype.m$1.call(this, J.getInterceptor$ns(x).$add(x, 10)); |
| 28 v0 = 10; | |
| 29 v1 = J.getInterceptor$ns(x).$add(x, v0); | |
| 30 return V.Base.prototype.m$1.call(this, v1); | |
| 31 }"""), | 28 }"""), |
| 32 | 29 |
| 33 // Reenable when we support compiling functions that | 30 // Reenable when we support compiling functions that |
| 34 // need interceptor calling convention. | 31 // need interceptor calling convention. |
| 35 // const TestEntry.forMethod('function(Sub#+)', """ | 32 // const TestEntry.forMethod('function(Sub#+)', """ |
| 36 // class Base { | 33 // class Base { |
| 37 // m(x) { | 34 // m(x) { |
| 38 // print(x+1000); | 35 // print(x+1000); |
| 39 // } | 36 // } |
| 40 // operator+(x) => m(x+10); | 37 // operator+(x) => m(x+10); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 71 v0 = this.field; | 68 v0 = this.field; |
| 72 return J.getInterceptor$ns(x).$add(x, v0); | 69 return J.getInterceptor$ns(x).$add(x, v0); |
| 73 }"""), | 70 }"""), |
| 74 | 71 |
| 75 | 72 |
| 76 ]; | 73 ]; |
| 77 | 74 |
| 78 void main() { | 75 void main() { |
| 79 runTests(tests); | 76 runTests(tests); |
| 80 } | 77 } |
| OLD | NEW |