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

The following examples show how to use jdk.nashorn.internal.objects.annotations.Property. 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 check out the related API usage on the sidebar.
Example #1
Source File: Global.java    From TencentKona-8 with 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 File: Global.java    From jdk8u_nashorn with 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 File: Global.java    From jdk8u60 with 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 File: Global.java    From hottub with 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 File: Global.java    From openjdk-jdk9 with 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 File: Global.java    From openjdk-jdk8u with 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 File: Global.java    From openjdk-jdk8u-backup with 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 File: Global.java    From openjdk-jdk8u-backup with 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 File: Global.java    From jdk8u_nashorn with 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 File: Global.java    From hottub with 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 File: Global.java    From openjdk-jdk9 with 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 File: Global.java    From openjdk-jdk8u with 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 File: Global.java    From TencentKona-8 with 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 File: Global.java    From jdk8u60 with 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 File: Global.java    From openjdk-jdk9 with 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 #16
Source File: Global.java    From jdk8u_nashorn with 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 File: Global.java    From TencentKona-8 with 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 #18
Source File: Global.java    From jdk8u_nashorn with 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 #19
Source File: Global.java    From hottub with 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 #20
Source File: Global.java    From jdk8u60 with 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 #21
Source File: Global.java    From hottub with 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 File: Global.java    From openjdk-jdk8u with 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 File: Global.java    From jdk8u60 with 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 #24
Source File: Global.java    From openjdk-jdk8u with 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 #25
Source File: Global.java    From openjdk-jdk9 with 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 #26
Source File: Global.java    From openjdk-jdk8u-backup with 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 File: Global.java    From TencentKona-8 with 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 File: Global.java    From openjdk-jdk8u-backup with 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();
    }
}