Java Code Examples for jdk.nashorn.internal.objects.annotations.Property

The following examples show how to use jdk.nashorn.internal.objects.annotations.Property. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: TencentKona-8   Source File: Global.java    License: GNU General Public License v2.0 6 votes vote down vote up
private List<jdk.nashorn.internal.runtime.Property> extractBuiltinProperties(final String name, final ScriptObject func) {
    final List<jdk.nashorn.internal.runtime.Property> list = new ArrayList<>();

    list.addAll(Arrays.asList(func.getMap().getProperties()));

    if (func instanceof ScriptFunction) {
        final ScriptObject proto = ScriptFunction.getPrototype((ScriptFunction)func);
        if (proto != null) {
            list.addAll(Arrays.asList(proto.getMap().getProperties()));
        }
    }

    final jdk.nashorn.internal.runtime.Property prop = getProperty(name);
    if (prop != null) {
        list.add(prop);
    }

    return list;
}
 
Example 2
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 6 votes vote down vote up
private List<jdk.nashorn.internal.runtime.Property> extractBuiltinProperties(final String name, final ScriptObject func) {
    final List<jdk.nashorn.internal.runtime.Property> list = new ArrayList<>();

    list.addAll(Arrays.asList(func.getMap().getProperties()));

    if (func instanceof ScriptFunction) {
        final ScriptObject proto = ScriptFunction.getPrototype((ScriptFunction)func);
        if (proto != null) {
            list.addAll(Arrays.asList(proto.getMap().getProperties()));
        }
    }

    final jdk.nashorn.internal.runtime.Property prop = getProperty(name);
    if (prop != null) {
        list.add(prop);
    }

    return list;
}
 
Example 3
Source Project: openjdk-jdk8u   Source File: Global.java    License: GNU General Public License v2.0 6 votes vote down vote up
private List<jdk.nashorn.internal.runtime.Property> extractBuiltinProperties(final String name, final ScriptObject func) {
    final List<jdk.nashorn.internal.runtime.Property> list = new ArrayList<>();

    list.addAll(Arrays.asList(func.getMap().getProperties()));

    if (func instanceof ScriptFunction) {
        final ScriptObject proto = ScriptFunction.getPrototype((ScriptFunction)func);
        if (proto != null) {
            list.addAll(Arrays.asList(proto.getMap().getProperties()));
        }
    }

    final jdk.nashorn.internal.runtime.Property prop = getProperty(name);
    if (prop != null) {
        list.add(prop);
    }

    return list;
}
 
Example 4
Source Project: openjdk-jdk8u-backup   Source File: Global.java    License: GNU General Public License v2.0 6 votes vote down vote up
private List<jdk.nashorn.internal.runtime.Property> extractBuiltinProperties(final String name, final ScriptObject func) {
    final List<jdk.nashorn.internal.runtime.Property> list = new ArrayList<>();

    list.addAll(Arrays.asList(func.getMap().getProperties()));

    if (func instanceof ScriptFunction) {
        final ScriptObject proto = ScriptFunction.getPrototype((ScriptFunction)func);
        if (proto != null) {
            list.addAll(Arrays.asList(proto.getMap().getProperties()));
        }
    }

    final jdk.nashorn.internal.runtime.Property prop = getProperty(name);
    if (prop != null) {
        list.add(prop);
    }

    return list;
}
 
Example 5
Source Project: openjdk-jdk9   Source File: Global.java    License: GNU General Public License v2.0 6 votes vote down vote up
private List<jdk.nashorn.internal.runtime.Property> extractBuiltinProperties(final String name, final ScriptObject func) {
    final List<jdk.nashorn.internal.runtime.Property> list = new ArrayList<>();

    list.addAll(Arrays.asList(func.getMap().getProperties()));

    if (func instanceof ScriptFunction) {
        final ScriptObject proto = ScriptFunction.getPrototype((ScriptFunction)func);
        if (proto != null) {
            list.addAll(Arrays.asList(proto.getMap().getProperties()));
        }
    }

    final jdk.nashorn.internal.runtime.Property prop = getProperty(name);
    if (prop != null) {
        list.add(prop);
    }

    return list;
}
 
Example 6
Source Project: hottub   Source File: Global.java    License: GNU General Public License v2.0 6 votes vote down vote up
private List<jdk.nashorn.internal.runtime.Property> extractBuiltinProperties(final String name, final ScriptObject func) {
    final List<jdk.nashorn.internal.runtime.Property> list = new ArrayList<>();

    list.addAll(Arrays.asList(func.getMap().getProperties()));

    if (func instanceof ScriptFunction) {
        final ScriptObject proto = ScriptFunction.getPrototype((ScriptFunction)func);
        if (proto != null) {
            list.addAll(Arrays.asList(proto.getMap().getProperties()));
        }
    }

    final jdk.nashorn.internal.runtime.Property prop = getProperty(name);
    if (prop != null) {
        list.add(prop);
    }

    return list;
}
 
Example 7
Source Project: jdk8u_nashorn   Source File: Global.java    License: GNU General Public License v2.0 6 votes vote down vote up
private List<jdk.nashorn.internal.runtime.Property> extractBuiltinProperties(final String name, final ScriptObject func) {
    final List<jdk.nashorn.internal.runtime.Property> list = new ArrayList<>();

    list.addAll(Arrays.asList(func.getMap().getProperties()));

    if (func instanceof ScriptFunction) {
        final ScriptObject proto = ScriptFunction.getPrototype((ScriptFunction)func);
        if (proto != null) {
            list.addAll(Arrays.asList(proto.getMap().getProperties()));
        }
    }

    final jdk.nashorn.internal.runtime.Property prop = getProperty(name);
    if (prop != null) {
        list.add(prop);
    }

    return list;
}
 
Example 8
Source Project: TencentKona-8   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given a builtin object, traverse its properties recursively and associate them with a name that
 * will be a key to their invalidation switchpoint.
 * @param name name for key
 * @param func builtin script object
 */
private void tagBuiltinProperties(final String name, final ScriptObject func) {
    SwitchPoint sp = context.getBuiltinSwitchPoint(name);
    if (sp == null) {
        sp = context.newBuiltinSwitchPoint(name);
    }

    //get all builtin properties in this builtin object and register switchpoints keyed on the propery name,
    //one overwrite destroys all for now, e.g. Function.prototype.apply = 17; also destroys Function.prototype.call etc
    for (final jdk.nashorn.internal.runtime.Property prop : extractBuiltinProperties(name, func)) {
        prop.setBuiltinSwitchPoint(sp);
    }
}
 
Example 9
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given a builtin object, traverse its properties recursively and associate them with a name that
 * will be a key to their invalidation switchpoint.
 * @param name name for key
 * @param func builtin script object
 */
private void tagBuiltinProperties(final String name, final ScriptObject func) {
    SwitchPoint sp = context.getBuiltinSwitchPoint(name);
    if (sp == null) {
        sp = context.newBuiltinSwitchPoint(name);
    }

    //get all builtin properties in this builtin object and register switchpoints keyed on the propery name,
    //one overwrite destroys all for now, e.g. Function.prototype.apply = 17; also destroys Function.prototype.call etc
    for (final jdk.nashorn.internal.runtime.Property prop : extractBuiltinProperties(name, func)) {
        prop.setBuiltinSwitchPoint(sp);
    }
}
 
Example 10
Source Project: openjdk-jdk8u   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given a builtin object, traverse its properties recursively and associate them with a name that
 * will be a key to their invalidation switchpoint.
 * @param name name for key
 * @param func builtin script object
 */
private void tagBuiltinProperties(final String name, final ScriptObject func) {
    SwitchPoint sp = context.getBuiltinSwitchPoint(name);
    if (sp == null) {
        sp = context.newBuiltinSwitchPoint(name);
    }

    //get all builtin properties in this builtin object and register switchpoints keyed on the propery name,
    //one overwrite destroys all for now, e.g. Function.prototype.apply = 17; also destroys Function.prototype.call etc
    for (final jdk.nashorn.internal.runtime.Property prop : extractBuiltinProperties(name, func)) {
        prop.setBuiltinSwitchPoint(sp);
    }
}
 
Example 11
Source Project: openjdk-jdk8u-backup   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given a builtin object, traverse its properties recursively and associate them with a name that
 * will be a key to their invalidation switchpoint.
 * @param name name for key
 * @param func builtin script object
 */
private void tagBuiltinProperties(final String name, final ScriptObject func) {
    SwitchPoint sp = context.getBuiltinSwitchPoint(name);
    if (sp == null) {
        sp = context.newBuiltinSwitchPoint(name);
    }

    //get all builtin properties in this builtin object and register switchpoints keyed on the propery name,
    //one overwrite destroys all for now, e.g. Function.prototype.apply = 17; also destroys Function.prototype.call etc
    for (final jdk.nashorn.internal.runtime.Property prop : extractBuiltinProperties(name, func)) {
        prop.setBuiltinSwitchPoint(sp);
    }
}
 
Example 12
Source Project: openjdk-jdk9   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given a builtin object, traverse its properties recursively and associate them with a name that
 * will be a key to their invalidation switchpoint.
 * @param name name for key
 * @param func builtin script object
 */
private void tagBuiltinProperties(final String name, final ScriptObject func) {
    SwitchPoint sp = context.getBuiltinSwitchPoint(name);
    if (sp == null) {
        sp = context.newBuiltinSwitchPoint(name);
    }

    //get all builtin properties in this builtin object and register switchpoints keyed on the propery name,
    //one overwrite destroys all for now, e.g. Function.prototype.apply = 17; also destroys Function.prototype.call etc
    for (final jdk.nashorn.internal.runtime.Property prop : extractBuiltinProperties(name, func)) {
        prop.setBuiltinSwitchPoint(sp);
    }
}
 
Example 13
Source Project: hottub   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given a builtin object, traverse its properties recursively and associate them with a name that
 * will be a key to their invalidation switchpoint.
 * @param name name for key
 * @param func builtin script object
 */
private void tagBuiltinProperties(final String name, final ScriptObject func) {
    SwitchPoint sp = context.getBuiltinSwitchPoint(name);
    if (sp == null) {
        sp = context.newBuiltinSwitchPoint(name);
    }

    //get all builtin properties in this builtin object and register switchpoints keyed on the propery name,
    //one overwrite destroys all for now, e.g. Function.prototype.apply = 17; also destroys Function.prototype.call etc
    for (final jdk.nashorn.internal.runtime.Property prop : extractBuiltinProperties(name, func)) {
        prop.setBuiltinSwitchPoint(sp);
    }
}
 
Example 14
Source Project: jdk8u_nashorn   Source File: Global.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Given a builtin object, traverse its properties recursively and associate them with a name that
 * will be a key to their invalidation switchpoint.
 * @param name name for key
 * @param func builtin script object
 */
private void tagBuiltinProperties(final String name, final ScriptObject func) {
    SwitchPoint sp = context.getBuiltinSwitchPoint(name);
    if (sp == null) {
        sp = context.newBuiltinSwitchPoint(name);
    }

    //get all builtin properties in this builtin object and register switchpoints keyed on the propery name,
    //one overwrite destroys all for now, e.g. Function.prototype.apply = 17; also destroys Function.prototype.call etc
    for (final jdk.nashorn.internal.runtime.Property prop : extractBuiltinProperties(name, func)) {
        prop.setBuiltinSwitchPoint(sp);
    }
}
 
Example 15
Source Project: TencentKona-8   Source File: Global.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void addBoundProperties(final ScriptObject source, final jdk.nashorn.internal.runtime.Property[] properties) {
    PropertyMap ownMap = getMap();
    LexicalScope lexScope = null;
    PropertyMap lexicalMap = null;
    boolean hasLexicalDefinitions = false;

    if (context.getEnv()._es6) {
        lexScope = (LexicalScope) getLexicalScope();
        lexicalMap = lexScope.getMap();

        for (final jdk.nashorn.internal.runtime.Property property : properties) {
            if (property.isLexicalBinding()) {
                hasLexicalDefinitions = true;
            }
            // ES6 15.1.8 steps 6. and 7.
            final jdk.nashorn.internal.runtime.Property globalProperty = ownMap.findProperty(property.getKey());
            if (globalProperty != null && !globalProperty.isConfigurable() && property.isLexicalBinding()) {
                throw ECMAErrors.syntaxError("redeclare.variable", property.getKey());
            }
            final jdk.nashorn.internal.runtime.Property lexicalProperty = lexicalMap.findProperty(property.getKey());
            if (lexicalProperty != null && !property.isConfigurable()) {
                throw ECMAErrors.syntaxError("redeclare.variable", property.getKey());
            }
        }
    }

    final boolean extensible = isExtensible();
    for (final jdk.nashorn.internal.runtime.Property property : properties) {
        if (property.isLexicalBinding()) {
            assert lexScope != null;
            lexicalMap = lexScope.addBoundProperty(lexicalMap, source, property, true);

            if (ownMap.findProperty(property.getKey()) != null) {
                // If property exists in the global object invalidate any global constant call sites.
                invalidateGlobalConstant(property.getKey());
            }
        } else {
            ownMap = addBoundProperty(ownMap, source, property, extensible);
        }
    }

    setMap(ownMap);

    if (hasLexicalDefinitions) {
        assert lexScope != null;
        lexScope.setMap(lexicalMap);
        invalidateLexicalSwitchPoint();
    }
}
 
Example 16
Source Project: TencentKona-8   Source File: Global.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
protected PropertyMap addBoundProperty(final PropertyMap propMap, final ScriptObject source, final jdk.nashorn.internal.runtime.Property property, final boolean extensible) {
    // We override this method just to make it callable by Global
    return super.addBoundProperty(propMap, source, property, extensible);
}
 
Example 17
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void addBoundProperties(final ScriptObject source, final jdk.nashorn.internal.runtime.Property[] properties) {
    PropertyMap ownMap = getMap();
    LexicalScope lexScope = null;
    PropertyMap lexicalMap = null;
    boolean hasLexicalDefinitions = false;

    if (context.getEnv()._es6) {
        lexScope = (LexicalScope) getLexicalScope();
        lexicalMap = lexScope.getMap();

        for (final jdk.nashorn.internal.runtime.Property property : properties) {
            if (property.isLexicalBinding()) {
                hasLexicalDefinitions = true;
            }
            // ES6 15.1.8 steps 6. and 7.
            final jdk.nashorn.internal.runtime.Property globalProperty = ownMap.findProperty(property.getKey());
            if (globalProperty != null && !globalProperty.isConfigurable() && property.isLexicalBinding()) {
                throw ECMAErrors.syntaxError("redeclare.variable", property.getKey());
            }
            final jdk.nashorn.internal.runtime.Property lexicalProperty = lexicalMap.findProperty(property.getKey());
            if (lexicalProperty != null && !property.isConfigurable()) {
                throw ECMAErrors.syntaxError("redeclare.variable", property.getKey());
            }
        }
    }

    for (final jdk.nashorn.internal.runtime.Property property : properties) {
        if (property.isLexicalBinding()) {
            assert lexScope != null;
            lexicalMap = lexScope.addBoundProperty(lexicalMap, source, property);

            if (ownMap.findProperty(property.getKey()) != null) {
                // If property exists in the global object invalidate any global constant call sites.
                invalidateGlobalConstant(property.getKey());
            }
        } else {
            ownMap = addBoundProperty(ownMap, source, property);
        }
    }

    setMap(ownMap);

    if (hasLexicalDefinitions) {
        assert lexScope != null;
        lexScope.setMap(lexicalMap);
        invalidateLexicalSwitchPoint();
    }
}
 
Example 18
Source Project: jdk8u60   Source File: Global.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
protected PropertyMap addBoundProperty(final PropertyMap propMap, final ScriptObject source, final jdk.nashorn.internal.runtime.Property property) {
    // We override this method just to make it callable by Global
    return super.addBoundProperty(propMap, source, property);
}
 
Example 19
Source Project: openjdk-jdk8u   Source File: Global.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void addBoundProperties(final ScriptObject source, final jdk.nashorn.internal.runtime.Property[] properties) {
    PropertyMap ownMap = getMap();
    LexicalScope lexScope = null;
    PropertyMap lexicalMap = null;
    boolean hasLexicalDefinitions = false;

    if (context.getEnv()._es6) {
        lexScope = (LexicalScope) getLexicalScope();
        lexicalMap = lexScope.getMap();

        for (final jdk.nashorn.internal.runtime.Property property : properties) {
            if (property.isLexicalBinding()) {
                hasLexicalDefinitions = true;
            }
            // ES6 15.1.8 steps 6. and 7.
            final jdk.nashorn.internal.runtime.Property globalProperty = ownMap.findProperty(property.getKey());
            if (globalProperty != null && !globalProperty.isConfigurable() && property.isLexicalBinding()) {
                throw ECMAErrors.syntaxError("redeclare.variable", property.getKey());
            }
            final jdk.nashorn.internal.runtime.Property lexicalProperty = lexicalMap.findProperty(property.getKey());
            if (lexicalProperty != null && !property.isConfigurable()) {
                throw ECMAErrors.syntaxError("redeclare.variable", property.getKey());
            }
        }
    }

    final boolean extensible = isExtensible();
    for (final jdk.nashorn.internal.runtime.Property property : properties) {
        if (property.isLexicalBinding()) {
            assert lexScope != null;
            lexicalMap = lexScope.addBoundProperty(lexicalMap, source, property, true);

            if (ownMap.findProperty(property.getKey()) != null) {
                // If property exists in the global object invalidate any global constant call sites.
                invalidateGlobalConstant(property.getKey());
            }
        } else {
            ownMap = addBoundProperty(ownMap, source, property, extensible);
        }
    }

    setMap(ownMap);

    if (hasLexicalDefinitions) {
        assert lexScope != null;
        lexScope.setMap(lexicalMap);
        invalidateLexicalSwitchPoint();
    }
}
 
Example 20
Source Project: openjdk-jdk8u   Source File: Global.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
protected PropertyMap addBoundProperty(final PropertyMap propMap, final ScriptObject source, final jdk.nashorn.internal.runtime.Property property, final boolean extensible) {
    // We override this method just to make it callable by Global
    return super.addBoundProperty(propMap, source, property, extensible);
}
 
Example 21
Source Project: openjdk-jdk8u-backup   Source File: Global.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void addBoundProperties(final ScriptObject source, final jdk.nashorn.internal.runtime.Property[] properties) {
    PropertyMap ownMap = getMap();
    LexicalScope lexScope = null;
    PropertyMap lexicalMap = null;
    boolean hasLexicalDefinitions = false;

    if (context.getEnv()._es6) {
        lexScope = (LexicalScope) getLexicalScope();
        lexicalMap = lexScope.getMap();

        for (final jdk.nashorn.internal.runtime.Property property : properties) {
            if (property.isLexicalBinding()) {
                hasLexicalDefinitions = true;
            }
            // ES6 15.1.8 steps 6. and 7.
            final jdk.nashorn.internal.runtime.Property globalProperty = ownMap.findProperty(property.getKey());
            if (globalProperty != null && !globalProperty.isConfigurable() && property.isLexicalBinding()) {
                throw ECMAErrors.syntaxError("redeclare.variable", property.getKey());
            }
            final jdk.nashorn.internal.runtime.Property lexicalProperty = lexicalMap.findProperty(property.getKey());
            if (lexicalProperty != null && !property.isConfigurable()) {
                throw ECMAErrors.syntaxError("redeclare.variable", property.getKey());
            }
        }
    }

    final boolean extensible = isExtensible();
    for (final jdk.nashorn.internal.runtime.Property property : properties) {
        if (property.isLexicalBinding()) {
            assert lexScope != null;
            lexicalMap = lexScope.addBoundProperty(lexicalMap, source, property, true);

            if (ownMap.findProperty(property.getKey()) != null) {
                // If property exists in the global object invalidate any global constant call sites.
                invalidateGlobalConstant(property.getKey());
            }
        } else {
            ownMap = addBoundProperty(ownMap, source, property, extensible);
        }
    }

    setMap(ownMap);

    if (hasLexicalDefinitions) {
        assert lexScope != null;
        lexScope.setMap(lexicalMap);
        invalidateLexicalSwitchPoint();
    }
}
 
Example 22
Source Project: openjdk-jdk8u-backup   Source File: Global.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
protected PropertyMap addBoundProperty(final PropertyMap propMap, final ScriptObject source, final jdk.nashorn.internal.runtime.Property property, final boolean extensible) {
    // We override this method just to make it callable by Global
    return super.addBoundProperty(propMap, source, property, extensible);
}
 
Example 23
Source Project: openjdk-jdk9   Source File: Global.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void addBoundProperties(final ScriptObject source, final jdk.nashorn.internal.runtime.Property[] properties) {
    PropertyMap ownMap = getMap();
    LexicalScope lexScope = null;
    PropertyMap lexicalMap = null;
    boolean hasLexicalDefinitions = false;

    if (context.getEnv()._es6) {
        lexScope = (LexicalScope) getLexicalScope();
        lexicalMap = lexScope.getMap();

        for (final jdk.nashorn.internal.runtime.Property property : properties) {
            if (property.isLexicalBinding()) {
                hasLexicalDefinitions = true;
            }
            // ES6 15.1.8 steps 6. and 7.
            final jdk.nashorn.internal.runtime.Property globalProperty = ownMap.findProperty(property.getKey());
            if (globalProperty != null && !globalProperty.isConfigurable() && property.isLexicalBinding()) {
                throw ECMAErrors.syntaxError("redeclare.variable", property.getKey().toString());
            }
            final jdk.nashorn.internal.runtime.Property lexicalProperty = lexicalMap.findProperty(property.getKey());
            if (lexicalProperty != null && !property.isConfigurable()) {
                throw ECMAErrors.syntaxError("redeclare.variable", property.getKey().toString());
            }
        }
    }

    final boolean extensible = isExtensible();
    for (final jdk.nashorn.internal.runtime.Property property : properties) {
        if (property.isLexicalBinding()) {
            assert lexScope != null;
            lexicalMap = lexScope.addBoundProperty(lexicalMap, source, property, true);

            if (ownMap.findProperty(property.getKey()) != null) {
                // If property exists in the global object invalidate any global constant call sites.
                invalidateGlobalConstant(property.getKey());
            }
        } else {
            ownMap = addBoundProperty(ownMap, source, property, extensible);
        }
    }

    setMap(ownMap);

    if (hasLexicalDefinitions) {
        assert lexScope != null;
        lexScope.setMap(lexicalMap);
        invalidateLexicalSwitchPoint();
    }
}
 
Example 24
Source Project: openjdk-jdk9   Source File: Global.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
protected PropertyMap addBoundProperty(final PropertyMap propMap, final ScriptObject source, final jdk.nashorn.internal.runtime.Property property, final boolean extensible) {
    // We override this method just to make it callable by Global
    return super.addBoundProperty(propMap, source, property, extensible);
}
 
Example 25
Source Project: hottub   Source File: Global.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void addBoundProperties(final ScriptObject source, final jdk.nashorn.internal.runtime.Property[] properties) {
    PropertyMap ownMap = getMap();
    LexicalScope lexScope = null;
    PropertyMap lexicalMap = null;
    boolean hasLexicalDefinitions = false;

    if (context.getEnv()._es6) {
        lexScope = (LexicalScope) getLexicalScope();
        lexicalMap = lexScope.getMap();

        for (final jdk.nashorn.internal.runtime.Property property : properties) {
            if (property.isLexicalBinding()) {
                hasLexicalDefinitions = true;
            }
            // ES6 15.1.8 steps 6. and 7.
            final jdk.nashorn.internal.runtime.Property globalProperty = ownMap.findProperty(property.getKey());
            if (globalProperty != null && !globalProperty.isConfigurable() && property.isLexicalBinding()) {
                throw ECMAErrors.syntaxError("redeclare.variable", property.getKey());
            }
            final jdk.nashorn.internal.runtime.Property lexicalProperty = lexicalMap.findProperty(property.getKey());
            if (lexicalProperty != null && !property.isConfigurable()) {
                throw ECMAErrors.syntaxError("redeclare.variable", property.getKey());
            }
        }
    }

    final boolean extensible = isExtensible();
    for (final jdk.nashorn.internal.runtime.Property property : properties) {
        if (property.isLexicalBinding()) {
            assert lexScope != null;
            lexicalMap = lexScope.addBoundProperty(lexicalMap, source, property, true);

            if (ownMap.findProperty(property.getKey()) != null) {
                // If property exists in the global object invalidate any global constant call sites.
                invalidateGlobalConstant(property.getKey());
            }
        } else {
            ownMap = addBoundProperty(ownMap, source, property, extensible);
        }
    }

    setMap(ownMap);

    if (hasLexicalDefinitions) {
        assert lexScope != null;
        lexScope.setMap(lexicalMap);
        invalidateLexicalSwitchPoint();
    }
}
 
Example 26
Source Project: hottub   Source File: Global.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
protected PropertyMap addBoundProperty(final PropertyMap propMap, final ScriptObject source, final jdk.nashorn.internal.runtime.Property property, final boolean extensible) {
    // We override this method just to make it callable by Global
    return super.addBoundProperty(propMap, source, property, extensible);
}
 
Example 27
Source Project: jdk8u_nashorn   Source File: Global.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void addBoundProperties(final ScriptObject source, final jdk.nashorn.internal.runtime.Property[] properties) {
    PropertyMap ownMap = getMap();
    LexicalScope lexScope = null;
    PropertyMap lexicalMap = null;
    boolean hasLexicalDefinitions = false;

    if (context.getEnv()._es6) {
        lexScope = (LexicalScope) getLexicalScope();
        lexicalMap = lexScope.getMap();

        for (final jdk.nashorn.internal.runtime.Property property : properties) {
            if (property.isLexicalBinding()) {
                hasLexicalDefinitions = true;
            }
            // ES6 15.1.8 steps 6. and 7.
            final jdk.nashorn.internal.runtime.Property globalProperty = ownMap.findProperty(property.getKey());
            if (globalProperty != null && !globalProperty.isConfigurable() && property.isLexicalBinding()) {
                throw ECMAErrors.syntaxError("redeclare.variable", property.getKey());
            }
            final jdk.nashorn.internal.runtime.Property lexicalProperty = lexicalMap.findProperty(property.getKey());
            if (lexicalProperty != null && !property.isConfigurable()) {
                throw ECMAErrors.syntaxError("redeclare.variable", property.getKey());
            }
        }
    }

    final boolean extensible = isExtensible();
    for (final jdk.nashorn.internal.runtime.Property property : properties) {
        if (property.isLexicalBinding()) {
            assert lexScope != null;
            lexicalMap = lexScope.addBoundProperty(lexicalMap, source, property, true);

            if (ownMap.findProperty(property.getKey()) != null) {
                // If property exists in the global object invalidate any global constant call sites.
                invalidateGlobalConstant(property.getKey());
            }
        } else {
            ownMap = addBoundProperty(ownMap, source, property, extensible);
        }
    }

    setMap(ownMap);

    if (hasLexicalDefinitions) {
        assert lexScope != null;
        lexScope.setMap(lexicalMap);
        invalidateLexicalSwitchPoint();
    }
}
 
Example 28
Source Project: jdk8u_nashorn   Source File: Global.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
protected PropertyMap addBoundProperty(final PropertyMap propMap, final ScriptObject source, final jdk.nashorn.internal.runtime.Property property, final boolean extensible) {
    // We override this method just to make it callable by Global
    return super.addBoundProperty(propMap, source, property, extensible);
}