Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: bin/dartutils.cc

Issue 9359009: Implement support for specifying string interopolation style variable substitution in the import ... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « bin/dartutils.h ('k') | bin/gen_snapshot.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 6
7 #include "bin/file.h" 7 #include "bin/file.h"
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/globals.h" 10 #include "platform/globals.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 Dart_Handle str = Dart_NewString(text_buffer); 165 Dart_Handle str = Dart_NewString(text_buffer);
166 free(text_buffer); 166 free(text_buffer);
167 return str; 167 return str;
168 } 168 }
169 169
170 170
171 Dart_Handle DartUtils::LoadSource(CommandLineOptions* url_mapping, 171 Dart_Handle DartUtils::LoadSource(CommandLineOptions* url_mapping,
172 Dart_Handle library, 172 Dart_Handle library,
173 Dart_Handle url, 173 Dart_Handle url,
174 Dart_LibraryTag tag, 174 Dart_LibraryTag tag,
175 const char* url_string) { 175 const char* url_string,
176 Dart_Handle import_map) {
176 if (url_mapping != NULL && IsDartSchemeURL(url_string)) { 177 if (url_mapping != NULL && IsDartSchemeURL(url_string)) {
177 const char* mapped_url_string = MapLibraryUrl(url_mapping, url_string); 178 const char* mapped_url_string = MapLibraryUrl(url_mapping, url_string);
178 if (mapped_url_string == NULL) { 179 if (mapped_url_string == NULL) {
179 return Dart_Error("Do not know how to load %s", url_string); 180 return Dart_Error("Do not know how to load %s", url_string);
180 } 181 }
181 // We have a URL mapping specified, just read the file that the 182 // We have a URL mapping specified, just read the file that the
182 // URL mapping specifies and load it. 183 // URL mapping specifies and load it.
183 url_string = mapped_url_string; 184 url_string = mapped_url_string;
184 } 185 }
185 // The tag is either an import or a source tag. 186 // The tag is either an import or a source tag.
186 // Read the file and load it according to the specified tag. 187 // Read the file and load it according to the specified tag.
187 Dart_Handle source = DartUtils::ReadStringFromFile(url_string); 188 Dart_Handle source = DartUtils::ReadStringFromFile(url_string);
188 if (Dart_IsError(source)) { 189 if (Dart_IsError(source)) {
189 return source; // source contains the error string. 190 return source; // source contains the error string.
190 } 191 }
191 if (tag == kImportTag) { 192 if (tag == kImportTag) {
192 // Return library object or an error string. 193 // Return library object or an error string.
193 return Dart_LoadLibrary(url, source); 194 return Dart_LoadLibrary(url, source, import_map);
194 } else if (tag == kSourceTag) { 195 } else if (tag == kSourceTag) {
195 return Dart_LoadSource(library, url, source); 196 return Dart_LoadSource(library, url, source);
196 } 197 }
197 return Dart_Error("wrong tag"); 198 return Dart_Error("wrong tag");
198 } 199 }
199 200
200 201
201 const char* DartUtils::GetCanonicalPath(const char* reference_dir, 202 const char* DartUtils::GetCanonicalPath(const char* reference_dir,
202 const char* filename) { 203 const char* filename) {
203 if (File::IsAbsolutePath(filename)) { 204 if (File::IsAbsolutePath(filename)) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 bool DartUtils::PostInt32(Dart_Port port_id, int32_t value) { 244 bool DartUtils::PostInt32(Dart_Port port_id, int32_t value) {
244 // Post a message with the integer value. 245 // Post a message with the integer value.
245 int32_t min = 0xc0000000; // -1073741824 246 int32_t min = 0xc0000000; // -1073741824
246 int32_t max = 0x3fffffff; // 1073741823 247 int32_t max = 0x3fffffff; // 1073741823
247 ASSERT(min <= value && value < max); 248 ASSERT(min <= value && value < max);
248 Dart_CObject object; 249 Dart_CObject object;
249 object.type = Dart_CObject::kInt32; 250 object.type = Dart_CObject::kInt32;
250 object.value.as_int32 = value; 251 object.value.as_int32 = value;
251 return Dart_PostCObject(port_id, &object); 252 return Dart_PostCObject(port_id, &object);
252 } 253 }
OLDNEW
« no previous file with comments | « bin/dartutils.h ('k') | bin/gen_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698