| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/builtins/builtins.h" | 5 #include "src/builtins/builtins.h" |
| 6 #include "src/builtins/builtins-utils.h" | 6 #include "src/builtins/builtins-utils.h" |
| 7 | 7 |
| 8 #include "src/messages.h" | 8 #include "src/messages.h" |
| 9 #include "src/property-descriptor.h" | 9 #include "src/property-descriptor.h" |
| 10 #include "src/string-builder.h" | 10 #include "src/string-builder.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 return isolate->heap()->undefined_value(); | 74 return isolate->heap()->undefined_value(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 // ES6 section 19.5.3.4 Error.prototype.toString ( ) | 77 // ES6 section 19.5.3.4 Error.prototype.toString ( ) |
| 78 BUILTIN(ErrorPrototypeToString) { | 78 BUILTIN(ErrorPrototypeToString) { |
| 79 HandleScope scope(isolate); | 79 HandleScope scope(isolate); |
| 80 RETURN_RESULT_OR_FAILURE(isolate, | 80 RETURN_RESULT_OR_FAILURE(isolate, |
| 81 ErrorUtils::ToString(isolate, args.receiver())); | 81 ErrorUtils::ToString(isolate, args.receiver())); |
| 82 } | 82 } |
| 83 | 83 |
| 84 BUILTIN(MakeGenericError) { | 84 namespace { |
| 85 HandleScope scope(isolate); | |
| 86 | 85 |
| 87 Handle<Object> constructor = args.atOrUndefined(isolate, 1); | 86 Object* MakeGenericError(Isolate* isolate, BuiltinArguments args, |
| 88 Handle<Object> template_index = args.atOrUndefined(isolate, 2); | 87 Handle<JSFunction> constructor) { |
| 89 Handle<Object> arg0 = args.atOrUndefined(isolate, 3); | 88 Handle<Object> template_index = args.atOrUndefined(isolate, 1); |
| 90 Handle<Object> arg1 = args.atOrUndefined(isolate, 4); | 89 Handle<Object> arg0 = args.atOrUndefined(isolate, 2); |
| 91 Handle<Object> arg2 = args.atOrUndefined(isolate, 5); | 90 Handle<Object> arg1 = args.atOrUndefined(isolate, 3); |
| 91 Handle<Object> arg2 = args.atOrUndefined(isolate, 4); |
| 92 | 92 |
| 93 DCHECK(constructor->IsJSFunction()); | |
| 94 DCHECK(template_index->IsSmi()); | 93 DCHECK(template_index->IsSmi()); |
| 95 | 94 |
| 96 RETURN_RESULT_OR_FAILURE( | 95 RETURN_RESULT_OR_FAILURE( |
| 96 isolate, ErrorUtils::MakeGenericError(isolate, constructor, |
| 97 Smi::cast(*template_index)->value(), |
| 98 arg0, arg1, arg2, SKIP_NONE)); |
| 99 } |
| 100 |
| 101 } // namespace |
| 102 |
| 103 BUILTIN(MakeError) { |
| 104 HandleScope scope(isolate); |
| 105 return MakeGenericError(isolate, args, isolate->error_function()); |
| 106 } |
| 107 |
| 108 BUILTIN(MakeRangeError) { |
| 109 HandleScope scope(isolate); |
| 110 return MakeGenericError(isolate, args, isolate->range_error_function()); |
| 111 } |
| 112 |
| 113 BUILTIN(MakeSyntaxError) { |
| 114 HandleScope scope(isolate); |
| 115 return MakeGenericError(isolate, args, isolate->syntax_error_function()); |
| 116 } |
| 117 |
| 118 BUILTIN(MakeTypeError) { |
| 119 HandleScope scope(isolate); |
| 120 return MakeGenericError(isolate, args, isolate->type_error_function()); |
| 121 } |
| 122 |
| 123 BUILTIN(MakeURIError) { |
| 124 HandleScope scope(isolate); |
| 125 Handle<JSFunction> constructor = isolate->uri_error_function(); |
| 126 Handle<Object> undefined = isolate->factory()->undefined_value(); |
| 127 const int template_index = MessageTemplate::kURIMalformed; |
| 128 RETURN_RESULT_OR_FAILURE( |
| 97 isolate, | 129 isolate, |
| 98 ErrorUtils::MakeGenericError( | 130 ErrorUtils::MakeGenericError(isolate, constructor, template_index, |
| 99 isolate, Handle<JSFunction>::cast(constructor), | 131 undefined, undefined, undefined, SKIP_NONE)); |
| 100 Smi::cast(*template_index)->value(), arg0, arg1, arg2, SKIP_FIRST)); | |
| 101 } | 132 } |
| 102 | 133 |
| 103 } // namespace internal | 134 } // namespace internal |
| 104 } // namespace v8 | 135 } // namespace v8 |
| OLD | NEW |