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-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
7 #include "src/counters.h" | 7 #include "src/counters.h" |
8 #include "src/objects-inl.h" | 8 #include "src/objects-inl.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 // ----------------------------------------------------------------------------- | 13 // ----------------------------------------------------------------------------- |
14 // ES6 section 19.4 Symbol Objects | 14 // ES6 section 19.4 Symbol Objects |
15 | 15 |
16 // ES6 section 19.4.1.1 Symbol ( [ description ] ) for the [[Call]] case. | 16 // ES6 section 19.4.1.1 Symbol ( [ description ] ) for the [[Call]] case. |
17 BUILTIN(SymbolConstructor) { | 17 BUILTIN(SymbolConstructor) { |
18 HandleScope scope(isolate); | 18 HandleScope scope(isolate); |
19 Handle<Symbol> result = isolate->factory()->NewSymbol(); | |
20 Handle<Object> description = args.atOrUndefined(isolate, 1); | 19 Handle<Object> description = args.atOrUndefined(isolate, 1); |
21 if (!description->IsUndefined(isolate)) { | 20 if (!description->IsUndefined(isolate)) { |
22 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, description, | 21 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, description, |
23 Object::ToString(isolate, description)); | 22 Object::ToString(isolate, description)); |
24 result->set_name(*description); | |
25 } | 23 } |
26 return *result; | 24 RETURN_RESULT_OR_FAILURE(isolate, isolate->factory()->NewSymbol(description)); |
27 } | 25 } |
28 | 26 |
29 // ES6 section 19.4.1.1 Symbol ( [ description ] ) for the [[Construct]] case. | 27 // ES6 section 19.4.1.1 Symbol ( [ description ] ) for the [[Construct]] case. |
30 BUILTIN(SymbolConstructor_ConstructStub) { | 28 BUILTIN(SymbolConstructor_ConstructStub) { |
31 HandleScope scope(isolate); | 29 HandleScope scope(isolate); |
32 THROW_NEW_ERROR_RETURN_FAILURE( | 30 THROW_NEW_ERROR_RETURN_FAILURE( |
33 isolate, NewTypeError(MessageTemplate::kNotConstructor, | 31 isolate, NewTypeError(MessageTemplate::kNotConstructor, |
34 isolate->factory()->Symbol_string())); | 32 isolate->factory()->Symbol_string())); |
35 } | 33 } |
36 | 34 |
(...skipping 24 matching lines...) Expand all Loading... |
61 } else { | 59 } else { |
62 result = isolate->heap()->undefined_value(); | 60 result = isolate->heap()->undefined_value(); |
63 } | 61 } |
64 DCHECK_EQ(isolate->heap()->public_symbol_table()->SlowReverseLookup(*symbol), | 62 DCHECK_EQ(isolate->heap()->public_symbol_table()->SlowReverseLookup(*symbol), |
65 result); | 63 result); |
66 return result; | 64 return result; |
67 } | 65 } |
68 | 66 |
69 } // namespace internal | 67 } // namespace internal |
70 } // namespace v8 | 68 } // namespace v8 |
OLD | NEW |