11cb0ef41Sopenharmony_ci// Copyright 2019 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_cinamespace symbol { 61cb0ef41Sopenharmony_ciextern runtime SymbolDescriptiveString(implicit context: Context)(Symbol): 71cb0ef41Sopenharmony_ci String; 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_citransitioning macro ThisSymbolValue(implicit context: Context)( 101cb0ef41Sopenharmony_ci receiver: JSAny, method: constexpr string): Symbol { 111cb0ef41Sopenharmony_ci return UnsafeCast<Symbol>( 121cb0ef41Sopenharmony_ci ToThisValue(receiver, PrimitiveType::kSymbol, method)); 131cb0ef41Sopenharmony_ci} 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci// ES #sec-symbol.prototype.description 161cb0ef41Sopenharmony_citransitioning javascript builtin SymbolPrototypeDescriptionGetter( 171cb0ef41Sopenharmony_ci js-implicit context: NativeContext, receiver: JSAny)(): String|Undefined { 181cb0ef41Sopenharmony_ci // 1. Let s be the this value. 191cb0ef41Sopenharmony_ci // 2. Let sym be ? thisSymbolValue(s). 201cb0ef41Sopenharmony_ci const sym: Symbol = ThisSymbolValue(receiver, 'Symbol.prototype.description'); 211cb0ef41Sopenharmony_ci // 3. Return sym.[[Description]]. 221cb0ef41Sopenharmony_ci return sym.description; 231cb0ef41Sopenharmony_ci} 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci// ES6 #sec-symbol.prototype-@@toprimitive 261cb0ef41Sopenharmony_citransitioning javascript builtin SymbolPrototypeToPrimitive( 271cb0ef41Sopenharmony_ci js-implicit context: NativeContext, receiver: JSAny)(_hint: JSAny): JSAny { 281cb0ef41Sopenharmony_ci // 1. Return ? thisSymbolValue(this value). 291cb0ef41Sopenharmony_ci return ThisSymbolValue(receiver, 'Symbol.prototype [ @@toPrimitive ]'); 301cb0ef41Sopenharmony_ci} 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci// ES6 #sec-symbol.prototype.tostring 331cb0ef41Sopenharmony_citransitioning javascript builtin SymbolPrototypeToString( 341cb0ef41Sopenharmony_ci js-implicit context: NativeContext, receiver: JSAny)(): JSAny { 351cb0ef41Sopenharmony_ci // 1. Let sym be ? thisSymbolValue(this value). 361cb0ef41Sopenharmony_ci const sym: Symbol = ThisSymbolValue(receiver, 'Symbol.prototype.toString'); 371cb0ef41Sopenharmony_ci // 2. Return SymbolDescriptiveString(sym). 381cb0ef41Sopenharmony_ci return SymbolDescriptiveString(sym); 391cb0ef41Sopenharmony_ci} 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_ci// ES6 #sec-symbol.prototype.valueof 421cb0ef41Sopenharmony_citransitioning javascript builtin SymbolPrototypeValueOf( 431cb0ef41Sopenharmony_ci js-implicit context: NativeContext, receiver: JSAny)(): JSAny { 441cb0ef41Sopenharmony_ci // 1. Return ? thisSymbolValue(this value). 451cb0ef41Sopenharmony_ci return ThisSymbolValue(receiver, 'Symbol.prototype.valueOf'); 461cb0ef41Sopenharmony_ci} 471cb0ef41Sopenharmony_ci} 48