OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
6 | 6 |
7 // TODO(ahe): Share these with js_helper.dart. | 7 // TODO(ahe): Share these with js_helper.dart. |
8 const FUNCTION_INDEX = 0; | 8 const FUNCTION_INDEX = 0; |
9 const NAME_INDEX = 1; | 9 const NAME_INDEX = 1; |
10 const CALL_NAME_INDEX = 2; | 10 const CALL_NAME_INDEX = 2; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 // | 232 // |
233 // The entries of [data] are built in [assembleProgram] above. | 233 // The entries of [data] are built in [assembleProgram] above. |
234 | 234 |
235 var name = data[0]; | 235 var name = data[0]; |
236 var uri = data[1]; | 236 var uri = data[1]; |
237 var metadata = data[2]; | 237 var metadata = data[2]; |
238 var globalObject = data[3]; | 238 var globalObject = data[3]; |
239 var descriptor = data[4]; | 239 var descriptor = data[4]; |
240 var isRoot = !!data[5]; | 240 var isRoot = !!data[5]; |
241 var fields = descriptor && descriptor["${namer.classDescriptorProperty}"]; | 241 var fields = descriptor && descriptor["${namer.classDescriptorProperty}"]; |
| 242 if (fields instanceof Array) fields = fields[0]; |
242 var classes = []; | 243 var classes = []; |
243 var functions = []; | 244 var functions = []; |
244 processStatics(descriptor); | 245 processStatics(descriptor); |
245 libraries.push([name, uri, classes, functions, metadata, fields, isRoot, | 246 libraries.push([name, uri, classes, functions, metadata, fields, isRoot, |
246 globalObject]); | 247 globalObject]); |
247 } | 248 } |
248 '''; | 249 '''; |
249 | 250 |
250 return js(''' | 251 return js(''' |
251 (function (reflectionData) { | 252 (function (reflectionData) { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 (function() { | 374 (function() { |
374 var result = $array[$index]; | 375 var result = $array[$index]; |
375 if ($check) { | 376 if ($check) { |
376 throw new Error( | 377 throw new Error( |
377 name + ": expected value of type \'$type\' at index " + ($index) + | 378 name + ": expected value of type \'$type\' at index " + ($index) + |
378 " but got " + (typeof result)); | 379 " but got " + (typeof result)); |
379 } | 380 } |
380 return result; | 381 return result; |
381 })()'''; | 382 })()'''; |
382 } | 383 } |
OLD | NEW |