OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 vmservice_io; | 5 part of vmservice_io; |
6 | 6 |
7 _sanitizeWindowsPath(path) { | 7 _sanitizeWindowsPath(path) { |
8 // For Windows we need to massage the paths a bit according to | 8 // For Windows we need to massage the paths a bit according to |
9 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx | 9 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx |
10 // | 10 // |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 const _Dart_kScriptTag = 1; // Load the root script. | 946 const _Dart_kScriptTag = 1; // Load the root script. |
947 const _Dart_kSourceTag = 2; // Load a part source. | 947 const _Dart_kSourceTag = 2; // Load a part source. |
948 const _Dart_kImportTag = 3; // Import a library. | 948 const _Dart_kImportTag = 3; // Import a library. |
949 | 949 |
950 // Extra requests. Keep these in sync between loader.dart and builtin.dart. | 950 // Extra requests. Keep these in sync between loader.dart and builtin.dart. |
951 const _Dart_kInitLoader = 4; // Initialize the loader. | 951 const _Dart_kInitLoader = 4; // Initialize the loader. |
952 const _Dart_kResourceLoad = 5; // Resource class support. | 952 const _Dart_kResourceLoad = 5; // Resource class support. |
953 const _Dart_kGetPackageRootUri = 6; // Uri of the packages/ directory. | 953 const _Dart_kGetPackageRootUri = 6; // Uri of the packages/ directory. |
954 const _Dart_kGetPackageConfigUri = 7; // Uri of the .packages file. | 954 const _Dart_kGetPackageConfigUri = 7; // Uri of the .packages file. |
955 const _Dart_kResolvePackageUri = 8; // Resolve a package: uri. | 955 const _Dart_kResolvePackageUri = 8; // Resolve a package: uri. |
| 956 |
| 957 // Extra requests. Keep these in sync between loader.dart and loader.cc. |
956 const _Dart_kImportExtension = 9; // Import a dart-ext: file. | 958 const _Dart_kImportExtension = 9; // Import a dart-ext: file. |
| 959 const _Dart_kResolveAsFilePath = 10; // Resolve uri to file path. |
957 | 960 |
958 // External entry point for loader requests. | 961 // External entry point for loader requests. |
959 _processLoadRequest(request) { | 962 _processLoadRequest(request) { |
960 assert(request is List); | 963 assert(request is List); |
961 assert(request.length > 4); | 964 assert(request.length > 4); |
962 | 965 |
963 // Should we trace loading? | 966 // Should we trace loading? |
964 bool traceLoading = request[0]; | 967 bool traceLoading = request[0]; |
965 | 968 |
966 // This is the sending isolate's Dart_GetMainPortId(). | 969 // This is the sending isolate's Dart_GetMainPortId(). |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 }); | 1111 }); |
1109 break; | 1112 break; |
1110 default: | 1113 default: |
1111 if (traceLoading) { | 1114 if (traceLoading) { |
1112 _log('Unknown scheme (${pathUri.scheme}) in $pathUri.'); | 1115 _log('Unknown scheme (${pathUri.scheme}) in $pathUri.'); |
1113 } | 1116 } |
1114 _sendExtensionImportResponse(sp, uri, libraryUri, null); | 1117 _sendExtensionImportResponse(sp, uri, libraryUri, null); |
1115 break; | 1118 break; |
1116 } | 1119 } |
1117 break; | 1120 break; |
| 1121 case _Dart_kResolveAsFilePath: |
| 1122 String uri = request[4]; |
| 1123 Uri resolvedUri = Uri.parse(uri); |
| 1124 try { |
| 1125 if (resolvedUri.scheme == 'package') { |
| 1126 resolvedUri = loaderState._resolvePackageUri(resolvedUri); |
| 1127 } |
| 1128 if (resolvedUri.scheme == '' || resolvedUri.scheme == 'file') { |
| 1129 resolvedUri = loaderState._workingDirectory.resolveUri(resolvedUri); |
| 1130 var msg = new List(5); |
| 1131 msg[0] = tag; |
| 1132 msg[1] = uri; |
| 1133 msg[2] = resolvedUri.toString(); |
| 1134 msg[3] = null; |
| 1135 msg[4] = resolvedUri.toFilePath(); |
| 1136 sp.send(msg); |
| 1137 } else { |
| 1138 throw "Cannot resolve scheme (${resolvedUri.scheme}) to file path" |
| 1139 " for $resolvedUri"; |
| 1140 } |
| 1141 } catch (e) { |
| 1142 var msg = new List(5); |
| 1143 msg[0] = -tag; |
| 1144 msg[1] = uri; |
| 1145 msg[2] = resolvedUri.toString(); |
| 1146 msg[3] = null; |
| 1147 msg[4] = e.toString(); |
| 1148 sp.send(msg); |
| 1149 } |
| 1150 break; |
1118 default: | 1151 default: |
1119 _log('Unknown loader request tag=$tag from $isolateId'); | 1152 _log('Unknown loader request tag=$tag from $isolateId'); |
1120 } | 1153 } |
1121 } | 1154 } |
OLD | NEW |