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

Side by Side Diff: runtime/vm/bootstrap.cc

Issue 27694005: Fix issue 13942 - Dart_Error function invokes OS::VSNPrint with the "format" string containing data… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl.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 "vm/bootstrap.h" 5 #include "vm/bootstrap.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "vm/bootstrap_natives.h" 9 #include "vm/bootstrap_natives.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 159 }
160 160
161 161
162 static Dart_Handle LoadPartSource(Isolate* isolate, 162 static Dart_Handle LoadPartSource(Isolate* isolate,
163 const Library& lib, 163 const Library& lib,
164 const String& uri) { 164 const String& uri) {
165 const String& part_source = String::Handle( 165 const String& part_source = String::Handle(
166 isolate, GetLibrarySource(lib, uri, false)); 166 isolate, GetLibrarySource(lib, uri, false));
167 const String& lib_uri = String::Handle(isolate, lib.url()); 167 const String& lib_uri = String::Handle(isolate, lib.url());
168 if (part_source.IsNull()) { 168 if (part_source.IsNull()) {
169 return Dart_NewApiError("Unable to read part file '%s' of library '%s'", 169 return Api::NewError("Unable to read part file '%s' of library '%s'",
170 uri.ToCString(), lib_uri.ToCString()); 170 uri.ToCString(), lib_uri.ToCString());
171 } 171 }
172 172
173 // Prepend the library URI to form a unique script URI for the part. 173 // Prepend the library URI to form a unique script URI for the part.
174 const Array& strings = Array::Handle(isolate, Array::New(3)); 174 const Array& strings = Array::Handle(isolate, Array::New(3));
175 strings.SetAt(0, lib_uri); 175 strings.SetAt(0, lib_uri);
176 strings.SetAt(1, Symbols::Slash()); 176 strings.SetAt(1, Symbols::Slash());
177 strings.SetAt(2, uri); 177 strings.SetAt(2, uri);
178 const String& part_uri = String::Handle(isolate, String::ConcatAll(strings)); 178 const String& part_uri = String::Handle(isolate, String::ConcatAll(strings));
179 179
180 // Create a script object and compile the part. 180 // Create a script object and compile the part.
181 const Script& part_script = Script::Handle( 181 const Script& part_script = Script::Handle(
182 isolate, Script::New(part_uri, part_source, RawScript::kSourceTag)); 182 isolate, Script::New(part_uri, part_source, RawScript::kSourceTag));
183 const Error& error = Error::Handle(isolate, Compile(lib, part_script)); 183 const Error& error = Error::Handle(isolate, Compile(lib, part_script));
184 return Api::NewHandle(isolate, error.raw()); 184 return Api::NewHandle(isolate, error.raw());
185 } 185 }
186 186
187 187
188 static Dart_Handle BootstrapLibraryTagHandler(Dart_LibraryTag tag, 188 static Dart_Handle BootstrapLibraryTagHandler(Dart_LibraryTag tag,
189 Dart_Handle library, 189 Dart_Handle library,
190 Dart_Handle uri) { 190 Dart_Handle uri) {
191 Isolate* isolate = Isolate::Current(); 191 Isolate* isolate = Isolate::Current();
192 if (!Dart_IsLibrary(library)) { 192 if (!Dart_IsLibrary(library)) {
193 return Dart_NewApiError("not a library"); 193 return Api::NewError("not a library");
194 } 194 }
195 if (!Dart_IsString(uri)) { 195 if (!Dart_IsString(uri)) {
196 return Dart_NewApiError("uri is not a string"); 196 return Api::NewError("uri is not a string");
197 } 197 }
198 if (tag == Dart_kCanonicalizeUrl) { 198 if (tag == Dart_kCanonicalizeUrl) {
199 // In the boot strap loader we do not try and do any canonicalization. 199 // In the boot strap loader we do not try and do any canonicalization.
200 return uri; 200 return uri;
201 } 201 }
202 const String& uri_str = Api::UnwrapStringHandle(isolate, uri); 202 const String& uri_str = Api::UnwrapStringHandle(isolate, uri);
203 ASSERT(!uri_str.IsNull()); 203 ASSERT(!uri_str.IsNull());
204 if (tag == Dart_kImportTag) { 204 if (tag == Dart_kImportTag) {
205 // We expect the core bootstrap libraries to only import other 205 // We expect the core bootstrap libraries to only import other
206 // core bootstrap libraries. 206 // core bootstrap libraries.
207 // We have precreated all the bootstrap library objects hence 207 // We have precreated all the bootstrap library objects hence
208 // we do not expect to be called back with the tag set to kImportTag. 208 // we do not expect to be called back with the tag set to kImportTag.
209 // The bootstrap process explicitly loads all the libraries one by one. 209 // The bootstrap process explicitly loads all the libraries one by one.
210 return Dart_NewApiError("Invalid import of '%s' in a bootstrap library", 210 return Api::NewError("Invalid import of '%s' in a bootstrap library",
211 uri_str.ToCString()); 211 uri_str.ToCString());
212 } 212 }
213 ASSERT(tag == Dart_kSourceTag); 213 ASSERT(tag == Dart_kSourceTag);
214 const Library& lib = Api::UnwrapLibraryHandle(isolate, library); 214 const Library& lib = Api::UnwrapLibraryHandle(isolate, library);
215 ASSERT(!lib.IsNull()); 215 ASSERT(!lib.IsNull());
216 return LoadPartSource(isolate, lib, uri_str); 216 return LoadPartSource(isolate, lib, uri_str);
217 } 217 }
218 218
219 219
220 static RawError* LoadPatchFiles(Isolate* isolate, 220 static RawError* LoadPatchFiles(Isolate* isolate,
221 const Library& lib, 221 const Library& lib,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 // Exit the Dart scope. 320 // Exit the Dart scope.
321 Dart_ExitScope(); 321 Dart_ExitScope();
322 322
323 // Restore the library tag handler for the isolate. 323 // Restore the library tag handler for the isolate.
324 isolate->set_library_tag_handler(saved_tag_handler); 324 isolate->set_library_tag_handler(saved_tag_handler);
325 325
326 return error.raw(); 326 return error.raw();
327 } 327 }
328 328
329 } // namespace dart 329 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698