< prev index next >

src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/PropertyNode.java

Print this page

        

*** 34,93 **** @Immutable public final class PropertyNode extends Node { private static final long serialVersionUID = 1L; /** Property key. */ ! private final PropertyKey key; /** Property value. */ private final Expression value; /** Property getter. */ private final FunctionNode getter; /** Property getter. */ private final FunctionNode setter; /** * Constructor * * @param token token * @param finish finish * @param key the key of this property * @param value the value of this property * @param getter getter function body * @param setter setter function body */ ! public PropertyNode(final long token, final int finish, final PropertyKey key, final Expression value, final FunctionNode getter, final FunctionNode setter) { super(token, finish); this.key = key; this.value = value; this.getter = getter; this.setter = setter; } ! private PropertyNode(final PropertyNode propertyNode, final PropertyKey key, final Expression value, final FunctionNode getter, final FunctionNode setter) { super(propertyNode); this.key = key; this.value = value; this.getter = getter; this.setter = setter; } /** * Get the name of the property key * @return key name */ public String getKeyName() { ! return key.getPropertyName(); } @Override public Node accept(final NodeVisitor<? extends LexicalContext> visitor) { if (visitor.enterPropertyNode(this)) { return visitor.leavePropertyNode( ! setKey((PropertyKey)((Node)key).accept(visitor)). setValue(value == null ? null : (Expression)value.accept(visitor)). setGetter(getter == null ? null : (FunctionNode)getter.accept(visitor)). setSetter(setter == null ? null : (FunctionNode)setter.accept(visitor))); } --- 34,105 ---- @Immutable public final class PropertyNode extends Node { private static final long serialVersionUID = 1L; /** Property key. */ ! private final Expression key; /** Property value. */ private final Expression value; /** Property getter. */ private final FunctionNode getter; /** Property getter. */ private final FunctionNode setter; + /** static property flag */ + private final boolean isStatic; + + /** Computed property flag */ + private final boolean computed; + /** * Constructor * * @param token token * @param finish finish * @param key the key of this property * @param value the value of this property * @param getter getter function body * @param setter setter function body + * @param isStatic is this a static property? + * @param computed is this a computed property? */ ! public PropertyNode(final long token, final int finish, final Expression key, final Expression value, final FunctionNode getter, final FunctionNode setter, final boolean isStatic, final boolean computed) { super(token, finish); this.key = key; this.value = value; this.getter = getter; this.setter = setter; + this.isStatic = isStatic; + this.computed = computed; } ! private PropertyNode(final PropertyNode propertyNode, final Expression key, final Expression value, final FunctionNode getter, final FunctionNode setter, final boolean isStatic, final boolean computed) { super(propertyNode); this.key = key; this.value = value; this.getter = getter; this.setter = setter; + this.isStatic = isStatic; + this.computed = computed; } /** * Get the name of the property key * @return key name */ public String getKeyName() { ! return key instanceof PropertyKey ? ((PropertyKey) key).getPropertyName() : null; } @Override public Node accept(final NodeVisitor<? extends LexicalContext> visitor) { if (visitor.enterPropertyNode(this)) { return visitor.leavePropertyNode( ! setKey((Expression) key.accept(visitor)). setValue(value == null ? null : (Expression)value.accept(visitor)). setGetter(getter == null ? null : (FunctionNode)getter.accept(visitor)). setSetter(setter == null ? null : (FunctionNode)setter.accept(visitor))); }
*** 132,157 **** */ public PropertyNode setGetter(final FunctionNode getter) { if (this.getter == getter) { return this; } ! return new PropertyNode(this, key, value, getter, setter); } /** * Return the key for this property node * @return the key */ public Expression getKey() { ! return (Expression)key; } ! private PropertyNode setKey(final PropertyKey key) { if (this.key == key) { return this; } ! return new PropertyNode(this, key, value, getter, setter); } /** * Get the setter for this property * @return setter or null if none exists --- 144,169 ---- */ public PropertyNode setGetter(final FunctionNode getter) { if (this.getter == getter) { return this; } ! return new PropertyNode(this, key, value, getter, setter, isStatic, computed); } /** * Return the key for this property node * @return the key */ public Expression getKey() { ! return key; } ! private PropertyNode setKey(final Expression key) { if (this.key == key) { return this; } ! return new PropertyNode(this, key, value, getter, setter, isStatic, computed); } /** * Get the setter for this property * @return setter or null if none exists
*** 167,177 **** */ public PropertyNode setSetter(final FunctionNode setter) { if (this.setter == setter) { return this; } ! return new PropertyNode(this, key, value, getter, setter); } /** * Get the value of this property * @return property value --- 179,189 ---- */ public PropertyNode setSetter(final FunctionNode setter) { if (this.setter == setter) { return this; } ! return new PropertyNode(this, key, value, getter, setter, isStatic, computed); } /** * Get the value of this property * @return property value
*** 187,194 **** */ public PropertyNode setValue(final Expression value) { if (this.value == value) { return this; } ! return new PropertyNode(this, key, value, getter, setter); } } --- 199,224 ---- */ public PropertyNode setValue(final Expression value) { if (this.value == value) { return this; } ! return new PropertyNode(this, key, value, getter, setter, isStatic, computed); ! } ! ! /** ! * Returns true if this is a static property. ! * ! * @return true if static flag is set ! */ ! public boolean isStatic() { ! return isStatic; ! } ! ! /** ! * Returns true if this is a computed property. ! * ! * @return true if the computed flag is set ! */ ! public boolean isComputed() { ! return computed; } }
< prev index next >