OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 js_backend; | 5 part of js_backend; |
6 | 6 |
7 /** | 7 /** |
8 * A function element that represents a closure call. The signature is copied | 8 * A function element that represents a closure call. The signature is copied |
9 * from the given element. | 9 * from the given element. |
10 */ | 10 */ |
(...skipping 3016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3027 deferredBuffer.add('\$\$$_=$_{};$n'); | 3027 deferredBuffer.add('\$\$$_=$_{};$n'); |
3028 | 3028 |
3029 deferredBuffer | 3029 deferredBuffer |
3030 ..write(REFLECTION_DATA_PARSER) | 3030 ..write(REFLECTION_DATA_PARSER) |
3031 ..write('([$n'); | 3031 ..write('([$n'); |
3032 var sortedLibraries = Elements.sortedByPosition(libraryBuffers.keys); | 3032 var sortedLibraries = Elements.sortedByPosition(libraryBuffers.keys); |
3033 for (LibraryElement library in sortedLibraries) { | 3033 for (LibraryElement library in sortedLibraries) { |
3034 List<CodeBuffer> buffers = libraryBuffers[library]; | 3034 List<CodeBuffer> buffers = libraryBuffers[library]; |
3035 var buffer = buffers[0]; | 3035 var buffer = buffers[0]; |
3036 if (buffer != null) { | 3036 if (buffer != null) { |
| 3037 var uri = library.canonicalUri; |
| 3038 if (uri.scheme == 'file' && compiler.sourceMapUri != null) { |
| 3039 // TODO(ahe): It is a hack to use compiler.sourceMapUri |
| 3040 // here. It should be relative to the main JavaScript |
| 3041 // output file. |
| 3042 uri = relativize( |
| 3043 compiler.sourceMapUri, library.canonicalUri, false); |
| 3044 } |
3037 mainBuffer | 3045 mainBuffer |
3038 ..write('["${library.getLibraryOrScriptName()}",$_{$n') | 3046 ..write('["${library.getLibraryOrScriptName()}",') |
| 3047 ..write('"${uri}",') |
| 3048 ..write('$_{$n') |
3039 ..addBuffer(buffer) | 3049 ..addBuffer(buffer) |
3040 ..write('}],$n'); | 3050 ..write('}],$n'); |
3041 } | 3051 } |
3042 buffer = buffers[1]; | 3052 buffer = buffers[1]; |
3043 if (buffer != null) { | 3053 if (buffer != null) { |
3044 deferredBuffer | 3054 deferredBuffer |
3045 ..write('["${library.getLibraryOrScriptName()}",$_{$n') | 3055 ..write('["${library.getLibraryOrScriptName()}",$_{$n') |
3046 ..addBuffer(buffer) | 3056 ..addBuffer(buffer) |
3047 ..write('}],$n'); | 3057 ..write('}],$n'); |
3048 } | 3058 } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3220 // TODO(ahe): The uri field below is fake. | 3230 // TODO(ahe): The uri field below is fake. |
3221 const String REFLECTION_DATA_PARSER = r''' | 3231 const String REFLECTION_DATA_PARSER = r''' |
3222 (function (reflectionData) { | 3232 (function (reflectionData) { |
3223 if (!init.libraries) init.libraries = []; | 3233 if (!init.libraries) init.libraries = []; |
3224 var libraries = init.libraries; | 3234 var libraries = init.libraries; |
3225 var hasOwnProperty = Object.prototype.hasOwnProperty; | 3235 var hasOwnProperty = Object.prototype.hasOwnProperty; |
3226 var length = reflectionData.length; | 3236 var length = reflectionData.length; |
3227 for (var i = 0; i < length; i++) { | 3237 for (var i = 0; i < length; i++) { |
3228 var data = reflectionData[i]; | 3238 var data = reflectionData[i]; |
3229 var name = data[0]; | 3239 var name = data[0]; |
3230 var descriptor = data[1]; | 3240 var uri = data[1]; |
| 3241 var descriptor = data[2]; |
3231 var classes = []; | 3242 var classes = []; |
3232 var functions = []; | 3243 var functions = []; |
3233 for (var property in descriptor) { | 3244 for (var property in descriptor) { |
3234 if (!hasOwnProperty.call(descriptor, property)) continue; | 3245 if (!hasOwnProperty.call(descriptor, property)) continue; |
3235 var element = descriptor[property]; | 3246 var element = descriptor[property]; |
3236 if (typeof element === "function") { | 3247 if (typeof element === "function") { |
3237 $[property] = element; | 3248 $[property] = element; |
3238 functions.push(property); | 3249 functions.push(property); |
3239 } else { | 3250 } else { |
3240 $$[property] = element; | 3251 $$[property] = element; |
3241 classes.push(property); | 3252 classes.push(property); |
3242 classes.push(element[""]); | 3253 classes.push(element[""]); |
3243 } | 3254 } |
3244 } | 3255 } |
3245 var uri = ".../library" + i + ".dart"; | |
3246 libraries.push([name, uri, classes, functions]); | 3256 libraries.push([name, uri, classes, functions]); |
3247 } | 3257 } |
3248 })'''; | 3258 })'''; |
OLD | NEW |