use of com.github.anba.es6draft.runtime.types.Symbol in project es6draft by anba.
the class GlobalSymbolRegistry method getSymbol.
/**
* Returns the symbol which is mapped to {@code key}, or creates a new mapping.
*
* @param key
* the symbol string key
* @return the mapped symbol
*/
public Symbol getSymbol(String key) {
assert key != null : "key must not be null";
Symbol symbol = elements.get(key);
if (symbol != null) {
return symbol;
}
Symbol newSymbol = new Symbol(key);
elements.put(key, newSymbol);
return newSymbol;
}
use of com.github.anba.es6draft.runtime.types.Symbol in project es6draft by anba.
the class GlobalSymbolRegistry method getKey.
/**
* Returns the key which is mapped to {@code symbol}, or returns <code>null</code> if there is
* no mapping.
*
* @param symbol
* the global symbol
* @return the symbol string key or {@code null} if the symbol is not in the registry
*/
public String getKey(Symbol symbol) {
assert symbol != null : "symbol must not be null";
String key = symbol.getDescription();
Symbol existingSymbol = elements.get(key);
if (existingSymbol == symbol) {
return key;
}
return null;
}
use of com.github.anba.es6draft.runtime.types.Symbol in project es6draft by anba.
the class ObjectConstructor method GetOwnPropertySymbols.
/**
* 19.1.2.10.1 Runtime Semantics: GetOwnPropertyKeys ( O, Type ), with Type = Symbol
*
* @param cx
* the execution context
* @param o
* the script object
* @return the own symbol-valued property keys of <var>o</var>
*/
public static ArrayObject GetOwnPropertySymbols(ExecutionContext cx, Object o) {
/* step 1 */
ScriptObject obj = ToObject(cx, o);
/* steps 2-4 */
List<Symbol> nameList = obj.ownPropertySymbols(cx);
/* step 5 */
return CreateArrayFromList(cx, nameList);
}
use of com.github.anba.es6draft.runtime.types.Symbol in project es6draft by anba.
the class SymbolConstructor method call.
/**
* 19.4.1.1 Symbol ( [ description ] )
*/
@Override
public Symbol call(ExecutionContext callerContext, Object thisValue, Object... args) {
ExecutionContext calleeContext = calleeContext();
Object description = argument(args, 0);
/* step 1 (not applicable) */
/* steps 2-3 */
String descString = Type.isUndefined(description) ? null : ToFlatString(calleeContext, description);
/* step 4 */
return new Symbol(descString);
}
Aggregations