OLD | NEW |
(Empty) | |
| 1 library closure2_test; |
| 2 import self as self; |
| 3 import "dart:core" as core; |
| 4 import "../../runtime/reify/interceptors.dart" as int; |
| 5 import "../../runtime/reify/types.dart" as typ; |
| 6 import "dart:mock" as mock; |
| 7 import "./test_base.dart" as tes; |
| 8 import "../../runtime/reify/declarations.dart" as dec; |
| 9 |
| 10 class A extends core::Object implements int::HasRuntimeTypeGetter { |
| 11 final field typ::ReifiedType $type; |
| 12 constructor •(typ::ReifiedType $type) → void |
| 13 : self::A::$type = $type, super core::Object::•() |
| 14 ; |
| 15 method fun() → dynamic { |
| 16 return new self::Closure#A#fun#function::•(new typ::Interface::•(self::$decl
arations.[](1), typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$decla
rations.[](0)))), null); |
| 17 } |
| 18 get $A$T() → typ::ReifiedType |
| 19 return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declaratio
ns.[](0))).[](0); |
| 20 get runtimeType() → core::Type |
| 21 return this.{=self::A::$type}; |
| 22 } |
| 23 class X extends core::Object implements int::HasRuntimeTypeGetter { |
| 24 constructor •() → void |
| 25 : super core::Object::•() |
| 26 ; |
| 27 get $type() → typ::ReifiedType |
| 28 return new typ::Interface::•(self::$declarations.[](2)); |
| 29 } |
| 30 class Y extends core::Object implements int::HasRuntimeTypeGetter { |
| 31 constructor •() → void |
| 32 : super core::Object::•() |
| 33 ; |
| 34 get $type() → typ::ReifiedType |
| 35 return new typ::Interface::•(self::$declarations.[](3)); |
| 36 } |
| 37 class Closure#A#fun#function extends core::Object implements core::Function, int
::HasRuntimeTypeGetter { |
| 38 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; |
| 39 field mock::Context context; |
| 40 final field typ::ReifiedType $type; |
| 41 constructor •(typ::ReifiedType $type, final mock::Context context) → dynamic |
| 42 : self::Closure#A#fun#function::$type = $type, self::Closure#A#fun#function:
:context = context |
| 43 ; |
| 44 method call(dynamic o) → dynamic { |
| 45 "This is a temporary solution. In the VM, this will become an additional par
ameter."; |
| 46 final mock::Context #contextParameter = this.{self::Closure#A#fun#function::
context}; |
| 47 return typ::isSubtypeOf(int::type(o), this.$Closure#A#fun#function$T); |
| 48 } |
| 49 get $Closure#A#fun#function$T() → typ::ReifiedType |
| 50 return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declaratio
ns.[](1))).[](0); |
| 51 get runtimeType() → core::Type |
| 52 return this.{=self::Closure#A#fun#function::$type}; |
| 53 } |
| 54 static final field core::List<dec::Class> $declarations = (core::List<dec::Class
> d) → core::List<dec::Class> { |
| 55 dec::init(d, 0, new typ::Interface::•(d.[](17))); |
| 56 dec::init(d, 1, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface:
:•(d.[](19))], new typ::FunctionType::•(new typ::Interface::•(d.[](19)), const t
yp::Dynamic::•(), 0, <dynamic>[const typ::Dynamic::•()])); |
| 57 dec::init(d, 2, new typ::Interface::•(d.[](17))); |
| 58 dec::init(d, 3, new typ::Interface::•(d.[](17))); |
| 59 dec::init(d, 4, new typ::Interface::•(d.[](17))); |
| 60 dec::init(d, 5, new typ::Interface::•(d.[](17))); |
| 61 dec::init(d, 6, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface:
:•(d.[](20), <dynamic>[new typ::Interface::•(d.[](6))]), new typ::Interface::•(d
.[](21))]); |
| 62 dec::init(d, 7, new typ::Interface::•(d.[](22))); |
| 63 dec::init(d, 8, new typ::Interface::•(d.[](22))); |
| 64 dec::init(d, 9, new typ::Interface::•(d.[](17))); |
| 65 dec::init(d, 10, new typ::Interface::•(d.[](23))); |
| 66 dec::init(d, 11, new typ::Interface::•(d.[](23))); |
| 67 dec::init(d, 12, new typ::Interface::•(d.[](23))); |
| 68 dec::init(d, 13, new typ::Interface::•(d.[](23))); |
| 69 dec::init(d, 14, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface
::•(d.[](24))]); |
| 70 dec::init(d, 15, new typ::Interface::•(d.[](16))); |
| 71 dec::init(d, 16, new typ::Interface::•(d.[](23))); |
| 72 dec::init(d, 17, null); |
| 73 dec::init(d, 19, new typ::Interface::•(d.[](17))); |
| 74 dec::init(d, 20, new typ::Interface::•(d.[](17))); |
| 75 dec::init(d, 21, new typ::Interface::•(d.[](17))); |
| 76 dec::init(d, 22, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface
::•(d.[](20), <dynamic>[new typ::Interface::•(d.[](22))])]); |
| 77 dec::init(d, 23, new typ::Interface::•(d.[](17))); |
| 78 dec::init(d, 24, new typ::Interface::•(d.[](17))); |
| 79 return d; |
| 80 }.call(dec::allocateDeclarations(<dynamic>["A", "Closure#A#fun#function", "X", "
Y", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiati
onError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError",
"IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasR
untimeTypeGetter", "Function", "Comparable", "Pattern", "num", "Error", "Excepti
on"], <dynamic>[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0
, 0, 0, 0])); |
| 81 static method main() → dynamic { |
| 82 dynamic tester = new self::A::•(new typ::Interface::•(self::$declarations.[](0
), <dynamic>[new typ::Interface::•(self::$declarations.[](2))])).fun(); |
| 83 tes::expectTrue(tester.call(new self::X::•())); |
| 84 tes::expectFalse(tester.call(new self::Y::•())); |
| 85 } |
OLD | NEW |