OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 4229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4240 } else { | 4240 } else { |
4241 *result = Api::NewHandle(isolate, error.raw()); | 4241 *result = Api::NewHandle(isolate, error.raw()); |
4242 if (update_lib_status) { | 4242 if (update_lib_status) { |
4243 lib.SetLoadError(); | 4243 lib.SetLoadError(); |
4244 } | 4244 } |
4245 } | 4245 } |
4246 } | 4246 } |
4247 | 4247 |
4248 | 4248 |
4249 DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url, | 4249 DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url, |
4250 Dart_Handle source) { | 4250 Dart_Handle source, |
| 4251 intptr_t line_offset, |
| 4252 intptr_t col_offset) { |
4251 TIMERSCOPE(time_script_loading); | 4253 TIMERSCOPE(time_script_loading); |
4252 Isolate* isolate = Isolate::Current(); | 4254 Isolate* isolate = Isolate::Current(); |
4253 DARTSCOPE(isolate); | 4255 DARTSCOPE(isolate); |
4254 const String& url_str = Api::UnwrapStringHandle(isolate, url); | 4256 const String& url_str = Api::UnwrapStringHandle(isolate, url); |
4255 if (url_str.IsNull()) { | 4257 if (url_str.IsNull()) { |
4256 RETURN_TYPE_ERROR(isolate, url, String); | 4258 RETURN_TYPE_ERROR(isolate, url, String); |
4257 } | 4259 } |
4258 const String& source_str = Api::UnwrapStringHandle(isolate, source); | 4260 const String& source_str = Api::UnwrapStringHandle(isolate, source); |
4259 if (source_str.IsNull()) { | 4261 if (source_str.IsNull()) { |
4260 RETURN_TYPE_ERROR(isolate, source, String); | 4262 RETURN_TYPE_ERROR(isolate, source, String); |
4261 } | 4263 } |
4262 Library& library = | 4264 Library& library = |
4263 Library::Handle(isolate, isolate->object_store()->root_library()); | 4265 Library::Handle(isolate, isolate->object_store()->root_library()); |
4264 if (!library.IsNull()) { | 4266 if (!library.IsNull()) { |
4265 const String& library_url = String::Handle(isolate, library.url()); | 4267 const String& library_url = String::Handle(isolate, library.url()); |
4266 return Api::NewError("%s: A script has already been loaded from '%s'.", | 4268 return Api::NewError("%s: A script has already been loaded from '%s'.", |
4267 CURRENT_FUNC, library_url.ToCString()); | 4269 CURRENT_FUNC, library_url.ToCString()); |
4268 } | 4270 } |
4269 CHECK_CALLBACK_STATE(isolate); | |
4270 | |
4271 library = Library::New(url_str); | |
4272 library.set_debuggable(true); | |
4273 library.Register(); | |
4274 isolate->object_store()->set_root_library(library); | |
4275 | |
4276 const Script& script = Script::Handle( | |
4277 isolate, Script::New(url_str, source_str, RawScript::kScriptTag)); | |
4278 Dart_Handle result; | |
4279 CompileSource(isolate, library, script, &result); | |
4280 return result; | |
4281 } | |
4282 | |
4283 | |
4284 DART_EXPORT Dart_Handle Dart_LoadEmbeddedScript(Dart_Handle url, | |
4285 Dart_Handle source, | |
4286 intptr_t line_offset, | |
4287 intptr_t col_offset) { | |
4288 TIMERSCOPE(time_script_loading); | |
4289 Isolate* isolate = Isolate::Current(); | |
4290 DARTSCOPE(isolate); | |
4291 const String& url_str = Api::UnwrapStringHandle(isolate, url); | |
4292 if (url_str.IsNull()) { | |
4293 RETURN_TYPE_ERROR(isolate, url, String); | |
4294 } | |
4295 const String& source_str = Api::UnwrapStringHandle(isolate, source); | |
4296 if (source_str.IsNull()) { | |
4297 RETURN_TYPE_ERROR(isolate, source, String); | |
4298 } | |
4299 Library& library = | |
4300 Library::Handle(isolate, isolate->object_store()->root_library()); | |
4301 if (!library.IsNull()) { | |
4302 const String& library_url = String::Handle(isolate, library.url()); | |
4303 return Api::NewError("%s: A script has already been loaded from '%s'.", | |
4304 CURRENT_FUNC, library_url.ToCString()); | |
4305 } | |
4306 if (line_offset < 0) { | 4271 if (line_offset < 0) { |
4307 return Api::NewError("%s: argument 'line_offset' must be positive number", | 4272 return Api::NewError("%s: argument 'line_offset' must be positive number", |
4308 CURRENT_FUNC); | 4273 CURRENT_FUNC); |
4309 } | 4274 } |
4310 if (col_offset < 0) { | 4275 if (col_offset < 0) { |
4311 return Api::NewError("%s: argument 'col_offset' must be positive number", | 4276 return Api::NewError("%s: argument 'col_offset' must be positive number", |
4312 CURRENT_FUNC); | 4277 CURRENT_FUNC); |
4313 } | 4278 } |
4314 CHECK_CALLBACK_STATE(isolate); | 4279 CHECK_CALLBACK_STATE(isolate); |
4315 | 4280 |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4709 } | 4674 } |
4710 { | 4675 { |
4711 NoGCScope no_gc; | 4676 NoGCScope no_gc; |
4712 RawObject* raw_obj = obj.raw(); | 4677 RawObject* raw_obj = obj.raw(); |
4713 isolate->heap()->SetPeer(raw_obj, peer); | 4678 isolate->heap()->SetPeer(raw_obj, peer); |
4714 } | 4679 } |
4715 return Api::Success(isolate); | 4680 return Api::Success(isolate); |
4716 } | 4681 } |
4717 | 4682 |
4718 } // namespace dart | 4683 } // namespace dart |
OLD | NEW |