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 #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/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 } | 174 } |
175 } | 175 } |
176 return error.raw(); | 176 return error.raw(); |
177 } | 177 } |
178 | 178 |
179 | 179 |
180 static Dart_Handle LoadPartSource(Thread* thread, | 180 static Dart_Handle LoadPartSource(Thread* thread, |
181 const Library& lib, | 181 const Library& lib, |
182 const String& uri) { | 182 const String& uri) { |
183 Zone* zone = thread->zone(); | 183 Zone* zone = thread->zone(); |
184 Isolate* isolate = thread->isolate(); | |
185 const String& part_source = String::Handle( | 184 const String& part_source = String::Handle( |
186 zone, GetLibrarySource(lib, uri, false)); | 185 zone, GetLibrarySource(lib, uri, false)); |
187 const String& lib_uri = String::Handle(zone, lib.url()); | 186 const String& lib_uri = String::Handle(zone, lib.url()); |
188 if (part_source.IsNull()) { | 187 if (part_source.IsNull()) { |
189 return Api::NewError("Unable to read part file '%s' of library '%s'", | 188 return Api::NewError("Unable to read part file '%s' of library '%s'", |
190 uri.ToCString(), lib_uri.ToCString()); | 189 uri.ToCString(), lib_uri.ToCString()); |
191 } | 190 } |
192 | 191 |
193 // Prepend the library URI to form a unique script URI for the part. | 192 // Prepend the library URI to form a unique script URI for the part. |
194 const Array& strings = Array::Handle(zone, Array::New(3)); | 193 const Array& strings = Array::Handle(zone, Array::New(3)); |
195 strings.SetAt(0, lib_uri); | 194 strings.SetAt(0, lib_uri); |
196 strings.SetAt(1, Symbols::Slash()); | 195 strings.SetAt(1, Symbols::Slash()); |
197 strings.SetAt(2, uri); | 196 strings.SetAt(2, uri); |
198 const String& part_uri = String::Handle(zone, String::ConcatAll(strings)); | 197 const String& part_uri = String::Handle(zone, String::ConcatAll(strings)); |
199 | 198 |
200 // Create a script object and compile the part. | 199 // Create a script object and compile the part. |
201 const Script& part_script = Script::Handle( | 200 const Script& part_script = Script::Handle( |
202 zone, Script::New(part_uri, part_source, RawScript::kSourceTag)); | 201 zone, Script::New(part_uri, part_source, RawScript::kSourceTag)); |
203 const Error& error = Error::Handle(zone, Compile(lib, part_script)); | 202 const Error& error = Error::Handle(zone, Compile(lib, part_script)); |
204 return Api::NewHandle(isolate, error.raw()); | 203 return Api::NewHandle(thread, error.raw()); |
205 } | 204 } |
206 | 205 |
207 | 206 |
208 static Dart_Handle BootstrapLibraryTagHandler(Dart_LibraryTag tag, | 207 static Dart_Handle BootstrapLibraryTagHandler(Dart_LibraryTag tag, |
209 Dart_Handle library, | 208 Dart_Handle library, |
210 Dart_Handle uri) { | 209 Dart_Handle uri) { |
211 Thread* thread = Thread::Current(); | 210 Thread* thread = Thread::Current(); |
212 Zone* zone = thread->zone(); | 211 Zone* zone = thread->zone(); |
213 if (!Dart_IsLibrary(library)) { | 212 if (!Dart_IsLibrary(library)) { |
214 return Api::NewError("not a library"); | 213 return Api::NewError("not a library"); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 Compiler::CompileClass(cls); | 349 Compiler::CompileClass(cls); |
351 } | 350 } |
352 | 351 |
353 // Restore the library tag handler for the isolate. | 352 // Restore the library tag handler for the isolate. |
354 isolate->set_library_tag_handler(saved_tag_handler); | 353 isolate->set_library_tag_handler(saved_tag_handler); |
355 | 354 |
356 return error.raw(); | 355 return error.raw(); |
357 } | 356 } |
358 | 357 |
359 } // namespace dart | 358 } // namespace dart |
OLD | NEW |