OLD | NEW |
| (Empty) |
1 dart_library.library('fieldtest', null, /* Imports */[ | |
2 'dart_sdk' | |
3 ], function(exports, dart_sdk) { | |
4 'use strict'; | |
5 const core = dart_sdk.core; | |
6 const dart = dart_sdk.dart; | |
7 const dartx = dart_sdk.dartx; | |
8 const fieldtest = Object.create(null); | |
9 fieldtest.A = class A extends core.Object { | |
10 new() { | |
11 this.x = 42; | |
12 } | |
13 }; | |
14 fieldtest.B$ = dart.generic(T => { | |
15 class B extends core.Object { | |
16 new() { | |
17 this.x = null; | |
18 this.y = null; | |
19 this.z = null; | |
20 } | |
21 } | |
22 return B; | |
23 }); | |
24 fieldtest.B = fieldtest.B$(); | |
25 fieldtest.foo = function(a) { | |
26 core.print(a.x); | |
27 return a.x; | |
28 }; | |
29 dart.fn(fieldtest.foo, core.int, [fieldtest.A]); | |
30 fieldtest.bar = function(a) { | |
31 core.print(dart.dload(a, 'x')); | |
32 return dart.as(dart.dload(a, 'x'), core.int); | |
33 }; | |
34 dart.fn(fieldtest.bar, core.int, [dart.dynamic]); | |
35 fieldtest.baz = function(a) { | |
36 return a.x; | |
37 }; | |
38 dart.fn(fieldtest.baz, dart.dynamic, [fieldtest.A]); | |
39 fieldtest.compute = function() { | |
40 return 123; | |
41 }; | |
42 dart.fn(fieldtest.compute, core.int, []); | |
43 dart.defineLazy(fieldtest, { | |
44 get y() { | |
45 return dart.notNull(fieldtest.compute()) + 444; | |
46 }, | |
47 set y(_) {} | |
48 }); | |
49 dart.copyProperties(fieldtest, { | |
50 get q() { | |
51 return 'life, ' + 'the universe ' + 'and everything'; | |
52 } | |
53 }); | |
54 dart.copyProperties(fieldtest, { | |
55 get z() { | |
56 return 42; | |
57 }, | |
58 set z(value) { | |
59 fieldtest.y = dart.as(value, core.int); | |
60 } | |
61 }); | |
62 fieldtest.BaseWithGetter = class BaseWithGetter extends core.Object { | |
63 get foo() { | |
64 return 1; | |
65 } | |
66 }; | |
67 fieldtest.Derived = class Derived extends fieldtest.BaseWithGetter { | |
68 new() { | |
69 this[foo] = 2; | |
70 this.bar = 3; | |
71 } | |
72 get foo() { | |
73 return this[foo]; | |
74 } | |
75 set foo(value) { | |
76 this[foo] = value; | |
77 } | |
78 }; | |
79 const foo = Symbol(fieldtest.Derived.name + "." + 'foo'.toString()); | |
80 fieldtest.Generic$ = dart.generic(T => { | |
81 class Generic extends core.Object { | |
82 foo(t) { | |
83 dart.as(t, T); | |
84 return core.print(dart.notNull(fieldtest.Generic.bar) + dart.notNull(dar
t.as(t, core.String))); | |
85 } | |
86 } | |
87 dart.setSignature(Generic, { | |
88 methods: () => ({foo: [dart.dynamic, [T]]}) | |
89 }); | |
90 return Generic; | |
91 }); | |
92 fieldtest.Generic = fieldtest.Generic$(); | |
93 fieldtest.Generic.bar = 'hello'; | |
94 fieldtest.StaticFieldOrder1 = class StaticFieldOrder1 extends core.Object {}; | |
95 fieldtest.StaticFieldOrder1.d = 4; | |
96 dart.defineLazy(fieldtest.StaticFieldOrder1, { | |
97 get a() { | |
98 return fieldtest.StaticFieldOrder1.b + 1; | |
99 }, | |
100 get c() { | |
101 return fieldtest.StaticFieldOrder1.d + 2; | |
102 }, | |
103 get b() { | |
104 return fieldtest.StaticFieldOrder1.c + 3; | |
105 } | |
106 }); | |
107 fieldtest.StaticFieldOrder2 = class StaticFieldOrder2 extends core.Object {}; | |
108 fieldtest.StaticFieldOrder2.d = 4; | |
109 dart.defineLazy(fieldtest.StaticFieldOrder2, { | |
110 get a() { | |
111 return fieldtest.StaticFieldOrder2.b + 1; | |
112 }, | |
113 get c() { | |
114 return fieldtest.StaticFieldOrder2.d + 2; | |
115 }, | |
116 get b() { | |
117 return fieldtest.StaticFieldOrder2.c + 3; | |
118 } | |
119 }); | |
120 fieldtest.MyEnum = class MyEnum extends core.Object { | |
121 new(index) { | |
122 this.index = index; | |
123 } | |
124 toString() { | |
125 return { | |
126 0: "MyEnum.Val1", | |
127 1: "MyEnum.Val2", | |
128 2: "MyEnum.Val3", | |
129 3: "MyEnum.Val4" | |
130 }[this.index]; | |
131 } | |
132 }; | |
133 fieldtest.MyEnum.Val1 = dart.const(new fieldtest.MyEnum(0)); | |
134 fieldtest.MyEnum.Val2 = dart.const(new fieldtest.MyEnum(1)); | |
135 fieldtest.MyEnum.Val3 = dart.const(new fieldtest.MyEnum(2)); | |
136 fieldtest.MyEnum.Val4 = dart.const(new fieldtest.MyEnum(3)); | |
137 fieldtest.MyEnum.values = dart.const(dart.list([fieldtest.MyEnum.Val1, fieldte
st.MyEnum.Val2, fieldtest.MyEnum.Val3, fieldtest.MyEnum.Val4], fieldtest.MyEnum)
); | |
138 fieldtest.main = function() { | |
139 let a = new fieldtest.A(); | |
140 fieldtest.foo(a); | |
141 fieldtest.bar(a); | |
142 core.print(fieldtest.baz(a)); | |
143 core.print(new (fieldtest.Generic$(core.String))().foo(' world')); | |
144 core.print(fieldtest.MyEnum.values); | |
145 }; | |
146 dart.fn(fieldtest.main, dart.void, []); | |
147 // Exports: | |
148 exports.fieldtest = fieldtest; | |
149 }); | |
OLD | NEW |