Search in sources :

Example 1 with Symbol

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;
}
Also used : Symbol(com.github.anba.es6draft.runtime.types.Symbol)

Example 2 with Symbol

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;
}
Also used : Symbol(com.github.anba.es6draft.runtime.types.Symbol)

Example 3 with Symbol

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);
}
Also used : ScriptObject(com.github.anba.es6draft.runtime.types.ScriptObject) Symbol(com.github.anba.es6draft.runtime.types.Symbol)

Example 4 with Symbol

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);
}
Also used : ExecutionContext(com.github.anba.es6draft.runtime.ExecutionContext) Symbol(com.github.anba.es6draft.runtime.types.Symbol) BuiltinSymbol(com.github.anba.es6draft.runtime.types.BuiltinSymbol) ScriptObject(com.github.anba.es6draft.runtime.types.ScriptObject) ToFlatString(com.github.anba.es6draft.runtime.AbstractOperations.ToFlatString)

Aggregations

Symbol (com.github.anba.es6draft.runtime.types.Symbol)4 ScriptObject (com.github.anba.es6draft.runtime.types.ScriptObject)2 ToFlatString (com.github.anba.es6draft.runtime.AbstractOperations.ToFlatString)1 ExecutionContext (com.github.anba.es6draft.runtime.ExecutionContext)1 BuiltinSymbol (com.github.anba.es6draft.runtime.types.BuiltinSymbol)1