OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 // See inspector.txt for expected behavior. | |
6 | |
7 library manual_inspector_test; | |
8 | |
9 import 'dart:isolate'; | |
10 import 'dart:mirrors'; | |
11 import 'dart:developer'; | |
12 import 'dart:typed_data'; | |
13 | |
14 part 'inspector_part.dart'; | |
15 | |
16 var libraryField; | |
17 var node; | |
18 var uninitialized = new Object(); | |
19 | |
20 extractPrivateField(obj, name) { | |
21 return reflect(obj).getField(MirrorSystem.getSymbol(name, reflect(obj).type.ow
ner)).reflectee; | |
22 } | |
23 | |
24 class A <T> {} | |
25 class B <S extends num> {} | |
26 | |
27 class S {} | |
28 class M {} | |
29 class MA extends S with M {} | |
30 | |
31 class Node { | |
32 static var classField; | |
33 | |
34 var nullable; | |
35 var mixedType; | |
36 var array; | |
37 var bigint; | |
38 var blockClean; | |
39 var blockCopying; | |
40 var blockFull; | |
41 var blockFullWithChain; | |
42 var boundedType; | |
43 var capability; | |
44 var counter; | |
45 var expando; | |
46 var float32x4; | |
47 var float64; | |
48 var float64x2; | |
49 var gauge; | |
50 var growableList; | |
51 var int32x4; | |
52 var isolate; | |
53 var map; | |
54 var mint; | |
55 var mirrorClass; | |
56 var mirrorClosure; | |
57 var mirrorInstance; | |
58 var mirrorReference; | |
59 var portReceive; | |
60 var portSend; | |
61 var regex; | |
62 var smi; | |
63 var stacktrace; | |
64 var string; | |
65 var stringLatin1; | |
66 var stringSnowflake; | |
67 var stringUnicode; | |
68 var stringHebrew; | |
69 var stringTrebleClef; | |
70 var theFalse; | |
71 var theNull; | |
72 var theTrue; | |
73 var type; | |
74 var typeParameter; | |
75 var typedData; | |
76 var userTag; | |
77 var weakProperty; | |
78 | |
79 genStacktrace() { | |
80 try { | |
81 num.parse(','); | |
82 } catch (e, s) { | |
83 return s; | |
84 } | |
85 } | |
86 | |
87 genCleanBlock() { | |
88 block(x) => x; | |
89 return block; | |
90 } | |
91 | |
92 genCopyingBlock() { | |
93 final x = 'I could be copied down'; | |
94 block() => x; | |
95 return block; | |
96 } | |
97 | |
98 genFullBlock() { | |
99 var x = 0; | |
100 block() => x++; | |
101 return block; | |
102 } | |
103 | |
104 genFullBlockWithChain() { | |
105 var x = 0; | |
106 outer() { | |
107 var y = 0; | |
108 block() => x++ + y++; | |
109 return block; | |
110 } | |
111 return outer; | |
112 } | |
113 | |
114 f(int x) { | |
115 ++x; | |
116 return x; | |
117 } | |
118 | |
119 static staticMain() { | |
120 node.main(); | |
121 } | |
122 | |
123 main() { | |
124 print("Started main"); | |
125 | |
126 f(9); | |
127 | |
128 nullable = 1; | |
129 nullable = null; | |
130 nullable = 1; | |
131 mixedType = 1; | |
132 mixedType = "2"; | |
133 mixedType = false; | |
134 | |
135 array = new List(3); | |
136 array[0] = 1; | |
137 array[1] = 2; | |
138 array[2] = 3; | |
139 bigint = 1 << 65; | |
140 blockClean = genCleanBlock(); | |
141 blockCopying = genCopyingBlock(); | |
142 blockFull = genFullBlock(); | |
143 blockFullWithChain = genFullBlockWithChain(); | |
144 boundedType = extractPrivateField(reflect(new B<int>()).type.typeVariables.s
ingle, '_reflectee'); | |
145 counter = new Counter("CounterName", "Counter description"); | |
146 expando = new Expando("expando-name"); | |
147 expando[array] = 'The weakly associated value'; | |
148 float32x4 = new Float32x4(0.0, -1.0, 3.14, 2e28); | |
149 float64 = 3.14; | |
150 float64x2 = new Float64x2(0.0, 3.14); | |
151 gauge = new Gauge("GaugeName", "Gauge description", 0.0, 100.0); | |
152 growableList = new List(); | |
153 int32x4 = new Int32x4(0,1,10,11); | |
154 map = { "x-key": "x-value", "y-key": "y-value", "removed-key": "removed-valu
e" }; | |
155 map.remove("removed-key"); | |
156 mint = 1 << 32; | |
157 mirrorClass = reflectClass(Object); | |
158 mirrorClosure = reflect(blockFull); | |
159 mirrorInstance = reflect("a reflectee"); | |
160 mirrorReference = extractPrivateField(mirrorClass, '_reflectee'); | |
161 portReceive = new RawReceivePort(); | |
162 portSend = portReceive.sendPort; | |
163 regex = new RegExp("a*b+c"); | |
164 smi = 7; | |
165 stacktrace = genStacktrace(); | |
166 string = "Hello $smi ${smi.runtimeType}"; | |
167 stringLatin1 = "blåbærgrød"; | |
168 stringSnowflake = "❄"; | |
169 stringUnicode = "Îñţérñåţîöñåļîžåţîờñ"; | |
170 stringHebrew = "שלום רב שובך צפורה נחמדת"; // An example of Right-to-Left. | |
171 stringTrebleClef = "𝄞"; // An example of a surrogate pair. | |
172 theFalse = false; | |
173 theNull = null; | |
174 theTrue = true; | |
175 type = String; | |
176 typeParameter = extractPrivateField(reflectClass(A).typeVariables.single, '_
reflectee'); | |
177 typedData = extractPrivateField(new ByteData(64), '_typedData'); | |
178 userTag = new UserTag("Example tag name"); | |
179 weakProperty = extractPrivateField(expando, '_data').firstWhere((e) => e !=
null); | |
180 | |
181 Isolate.spawn(secondMain, "Hello2").then((otherIsolate) { | |
182 isolate = otherIsolate; | |
183 portSend = otherIsolate.controlPort; | |
184 capability = otherIsolate.terminateCapability; | |
185 }); | |
186 Isolate.spawn(secondMain, "Hello3").then((otherIsolate) { | |
187 isolate = otherIsolate; | |
188 portSend = otherIsolate.controlPort; | |
189 capability = otherIsolate.terminateCapability; | |
190 }); | |
191 | |
192 print("Finished main"); | |
193 busy(); | |
194 } | |
195 | |
196 busy() { | |
197 var localVar = 0; | |
198 while (true) { | |
199 localVar = (localVar + 1) & 0xFFFF; | |
200 } | |
201 } | |
202 } | |
203 | |
204 secondMain(msg) { | |
205 print("Hello from second isolate"); | |
206 } | |
207 | |
208 var typed; | |
209 class Typed { | |
210 var float32List = new Float32List(16); | |
211 var float64List = new Float64List(16); | |
212 | |
213 var int32x4 = new Int32x4(1, 2, 3, 4); | |
214 var float32x4 = new Float32x4.zero(); | |
215 var float64x2 = new Float64x2.zero(); | |
216 var int32x4List = new Int32x4List(16); | |
217 var float32x4List = new Float32x4List(16); | |
218 var float64x2List = new Float64x2List(16); | |
219 | |
220 var int8List = new Int8List(8); | |
221 var int16List = new Int16List(8); | |
222 var int32List = new Int32List(8); | |
223 var int64List = new Int64List(8); | |
224 var uint8List = new Uint8List(8); | |
225 var uint16List = new Uint16List(8); | |
226 var uint32List = new Uint32List(8); | |
227 var uint64List = new Uint64List(8); | |
228 var uint8ClampedList = new Uint8ClampedList(8); | |
229 | |
230 var byteBuffer = new Uint8List(8).buffer; | |
231 var byteBuffer2 = new Float32List(8).buffer; | |
232 | |
233 var byteData = new ByteData(8); | |
234 | |
235 Typed() { | |
236 float32List[0] = 3.14; | |
237 int8List[0] = 5; | |
238 } | |
239 | |
240 Typed._named() { | |
241 float32List[0] = 3.14; | |
242 int8List[0] = 5; | |
243 } | |
244 } | |
245 | |
246 main() { | |
247 libraryField = 'Library field value'; | |
248 Node.classField = 'Class field value'; | |
249 typed = new Typed(); | |
250 node = new Node(); | |
251 Node.staticMain(); | |
252 } | |
253 | |
254 class C { | |
255 static doPrint() { | |
256 print("Original"); | |
257 } | |
258 } | |
OLD | NEW |