OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/isolate-inl.h" |
8 #include "src/objects-inl.h" | 9 #include "src/objects-inl.h" |
| 10 #include "src/string-builder.h" |
9 | 11 |
10 namespace v8 { | 12 namespace v8 { |
11 namespace internal { | 13 namespace internal { |
12 | 14 |
13 RUNTIME_FUNCTION(Runtime_CreateSymbol) { | 15 RUNTIME_FUNCTION(Runtime_CreateSymbol) { |
14 HandleScope scope(isolate); | 16 HandleScope scope(isolate); |
15 DCHECK(args.length() == 1); | 17 DCHECK(args.length() == 1); |
16 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); | 18 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); |
17 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); | 19 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); |
18 Handle<Symbol> symbol = isolate->factory()->NewSymbol(); | 20 Handle<Symbol> symbol = isolate->factory()->NewSymbol(); |
(...skipping 12 matching lines...) Expand all Loading... |
31 | 33 |
32 | 34 |
33 RUNTIME_FUNCTION(Runtime_SymbolDescription) { | 35 RUNTIME_FUNCTION(Runtime_SymbolDescription) { |
34 SealHandleScope shs(isolate); | 36 SealHandleScope shs(isolate); |
35 DCHECK(args.length() == 1); | 37 DCHECK(args.length() == 1); |
36 CONVERT_ARG_CHECKED(Symbol, symbol, 0); | 38 CONVERT_ARG_CHECKED(Symbol, symbol, 0); |
37 return symbol->name(); | 39 return symbol->name(); |
38 } | 40 } |
39 | 41 |
40 | 42 |
| 43 RUNTIME_FUNCTION(Runtime_SymbolDescriptiveString) { |
| 44 HandleScope scope(isolate); |
| 45 DCHECK_EQ(1, args.length()); |
| 46 CONVERT_ARG_HANDLE_CHECKED(Symbol, symbol, 0); |
| 47 IncrementalStringBuilder builder(isolate); |
| 48 builder.AppendCString("Symbol("); |
| 49 if (symbol->name()->IsString()) { |
| 50 builder.AppendString(handle(String::cast(symbol->name()), isolate)); |
| 51 } |
| 52 builder.AppendCharacter(')'); |
| 53 Handle<String> result; |
| 54 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, builder.Finish()); |
| 55 return *result; |
| 56 } |
| 57 |
| 58 |
41 RUNTIME_FUNCTION(Runtime_SymbolRegistry) { | 59 RUNTIME_FUNCTION(Runtime_SymbolRegistry) { |
42 HandleScope scope(isolate); | 60 HandleScope scope(isolate); |
43 DCHECK(args.length() == 0); | 61 DCHECK(args.length() == 0); |
44 return *isolate->GetSymbolRegistry(); | 62 return *isolate->GetSymbolRegistry(); |
45 } | 63 } |
46 | 64 |
47 | 65 |
48 RUNTIME_FUNCTION(Runtime_SymbolIsPrivate) { | 66 RUNTIME_FUNCTION(Runtime_SymbolIsPrivate) { |
49 SealHandleScope shs(isolate); | 67 SealHandleScope shs(isolate); |
50 DCHECK(args.length() == 1); | 68 DCHECK(args.length() == 1); |
51 CONVERT_ARG_CHECKED(Symbol, symbol, 0); | 69 CONVERT_ARG_CHECKED(Symbol, symbol, 0); |
52 return isolate->heap()->ToBoolean(symbol->is_private()); | 70 return isolate->heap()->ToBoolean(symbol->is_private()); |
53 } | 71 } |
54 } // namespace internal | 72 } // namespace internal |
55 } // namespace v8 | 73 } // namespace v8 |
OLD | NEW |