OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 4271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4282 } else if (pending_error_char_arg_ != NULL) { | 4282 } else if (pending_error_char_arg_ != NULL) { |
4283 Handle<String> arg_string = | 4283 Handle<String> arg_string = |
4284 factory->NewStringFromUtf8(CStrVector(pending_error_char_arg_)) | 4284 factory->NewStringFromUtf8(CStrVector(pending_error_char_arg_)) |
4285 .ToHandleChecked(); | 4285 .ToHandleChecked(); |
4286 elements->set(0, *arg_string); | 4286 elements->set(0, *arg_string); |
4287 } | 4287 } |
4288 isolate->debug()->OnCompileError(script); | 4288 isolate->debug()->OnCompileError(script); |
4289 | 4289 |
4290 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); | 4290 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); |
4291 Handle<Object> error; | 4291 Handle<Object> error; |
4292 MaybeHandle<Object> maybe_error; | |
4293 switch (pending_error_type_) { | 4292 switch (pending_error_type_) { |
4294 case kReferenceError: | 4293 case kReferenceError: |
4295 maybe_error = factory->NewReferenceError(pending_error_message_, array); | 4294 error = factory->NewReferenceError(pending_error_message_, array); |
4296 break; | 4295 break; |
4297 case kSyntaxError: | 4296 case kSyntaxError: |
4298 maybe_error = factory->NewSyntaxError(pending_error_message_, array); | 4297 error = factory->NewSyntaxError(pending_error_message_, array); |
4299 break; | 4298 break; |
4300 } | 4299 } |
4301 DCHECK(!maybe_error.is_null() || isolate->has_pending_exception()); | |
4302 | 4300 |
4303 if (maybe_error.ToHandle(&error)) { | 4301 Handle<JSObject> jserror = Handle<JSObject>::cast(error); |
4304 Handle<JSObject> jserror = Handle<JSObject>::cast(error); | |
4305 | 4302 |
4306 Handle<Name> key_start_pos = factory->error_start_pos_symbol(); | 4303 Handle<Name> key_start_pos = factory->error_start_pos_symbol(); |
4307 JSObject::SetProperty(jserror, key_start_pos, | 4304 JSObject::SetProperty(jserror, key_start_pos, |
4308 handle(Smi::FromInt(location.start_pos()), isolate), | 4305 handle(Smi::FromInt(location.start_pos()), isolate), |
4309 SLOPPY).Check(); | 4306 SLOPPY).Check(); |
4310 | 4307 |
4311 Handle<Name> key_end_pos = factory->error_end_pos_symbol(); | 4308 Handle<Name> key_end_pos = factory->error_end_pos_symbol(); |
4312 JSObject::SetProperty(jserror, key_end_pos, | 4309 JSObject::SetProperty(jserror, key_end_pos, |
4313 handle(Smi::FromInt(location.end_pos()), isolate), | 4310 handle(Smi::FromInt(location.end_pos()), isolate), |
4314 SLOPPY).Check(); | 4311 SLOPPY).Check(); |
4315 | 4312 |
4316 Handle<Name> key_script = factory->error_script_symbol(); | 4313 Handle<Name> key_script = factory->error_script_symbol(); |
4317 JSObject::SetProperty(jserror, key_script, script, SLOPPY).Check(); | 4314 JSObject::SetProperty(jserror, key_script, script, SLOPPY).Check(); |
4318 | 4315 |
4319 isolate->Throw(*error, &location); | 4316 isolate->Throw(*error, &location); |
4320 } | |
4321 } | 4317 } |
4322 } | 4318 } |
4323 | 4319 |
4324 | 4320 |
4325 void Parser::Internalize(Isolate* isolate, Handle<Script> script, bool error) { | 4321 void Parser::Internalize(Isolate* isolate, Handle<Script> script, bool error) { |
4326 // Internalize strings. | 4322 // Internalize strings. |
4327 ast_value_factory()->Internalize(isolate); | 4323 ast_value_factory()->Internalize(isolate); |
4328 | 4324 |
4329 // Error processing. | 4325 // Error processing. |
4330 if (error) { | 4326 if (error) { |
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5463 } else { | 5459 } else { |
5464 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); | 5460 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); |
5465 running_hash = StringHasher::ComputeRunningHash(running_hash, data, | 5461 running_hash = StringHasher::ComputeRunningHash(running_hash, data, |
5466 raw_string->length()); | 5462 raw_string->length()); |
5467 } | 5463 } |
5468 } | 5464 } |
5469 | 5465 |
5470 return running_hash; | 5466 return running_hash; |
5471 } | 5467 } |
5472 } } // namespace v8::internal | 5468 } } // namespace v8::internal |
OLD | NEW |