149 import jdk.nashorn.internal.runtime.Source; |
149 import jdk.nashorn.internal.runtime.Source; |
150 import jdk.nashorn.internal.runtime.Undefined; |
150 import jdk.nashorn.internal.runtime.Undefined; |
151 import jdk.nashorn.internal.runtime.UnwarrantedOptimismException; |
151 import jdk.nashorn.internal.runtime.UnwarrantedOptimismException; |
152 import jdk.nashorn.internal.runtime.arrays.ArrayData; |
152 import jdk.nashorn.internal.runtime.arrays.ArrayData; |
153 import jdk.nashorn.internal.runtime.linker.LinkerCallSite; |
153 import jdk.nashorn.internal.runtime.linker.LinkerCallSite; |
|
154 import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor; |
154 import jdk.nashorn.internal.runtime.logging.DebugLogger; |
155 import jdk.nashorn.internal.runtime.logging.DebugLogger; |
155 import jdk.nashorn.internal.runtime.logging.Loggable; |
156 import jdk.nashorn.internal.runtime.logging.Loggable; |
156 import jdk.nashorn.internal.runtime.logging.Logger; |
157 import jdk.nashorn.internal.runtime.logging.Logger; |
157 import jdk.nashorn.internal.runtime.options.Options; |
158 import jdk.nashorn.internal.runtime.options.Options; |
158 |
159 |
3786 |
3793 |
3787 public void loadVOID(final UnaryNode unaryNode, final TypeBounds resultBounds) { |
3794 public void loadVOID(final UnaryNode unaryNode, final TypeBounds resultBounds) { |
3788 loadAndDiscard(unaryNode.getExpression()); |
3795 loadAndDiscard(unaryNode.getExpression()); |
3789 if (!lc.popDiscardIfCurrent(unaryNode)) { |
3796 if (!lc.popDiscardIfCurrent(unaryNode)) { |
3790 method.loadUndefined(resultBounds.widest); |
3797 method.loadUndefined(resultBounds.widest); |
|
3798 } |
|
3799 } |
|
3800 |
|
3801 public void loadDELETE(final UnaryNode unaryNode) { |
|
3802 final Expression expression = unaryNode.getExpression(); |
|
3803 if (expression instanceof IdentNode) { |
|
3804 final IdentNode ident = (IdentNode)expression; |
|
3805 final Symbol symbol = ident.getSymbol(); |
|
3806 final String name = ident.getName(); |
|
3807 |
|
3808 if (symbol.isThis()) { |
|
3809 // Can't delete "this", ignore and return true |
|
3810 if (!lc.popDiscardIfCurrent(unaryNode)) { |
|
3811 method.load(true); |
|
3812 } |
|
3813 } else if (lc.getCurrentFunction().isStrict()) { |
|
3814 // All other scope identifier delete attempts fail for strict mode |
|
3815 method.load(name); |
|
3816 method.invoke(ScriptRuntime.STRICT_FAIL_DELETE); |
|
3817 } else if (!symbol.isScope() && (symbol.isParam() || (symbol.isVar() && !symbol.isProgramLevel()))) { |
|
3818 // If symbol is a function parameter, or a declared non-global variable, delete is a no-op and returns false. |
|
3819 if (!lc.popDiscardIfCurrent(unaryNode)) { |
|
3820 method.load(false); |
|
3821 } |
|
3822 } else { |
|
3823 method.loadCompilerConstant(SCOPE); |
|
3824 method.load(name); |
|
3825 if ((symbol.isGlobal() && !symbol.isFunctionDeclaration()) || symbol.isProgramLevel()) { |
|
3826 method.invoke(ScriptRuntime.SLOW_DELETE); |
|
3827 } else { |
|
3828 method.load(false); // never strict here; that was handled with STRICT_FAIL_DELETE above. |
|
3829 method.invoke(ScriptObject.DELETE); |
|
3830 } |
|
3831 } |
|
3832 } else if (expression instanceof BaseNode) { |
|
3833 loadExpressionAsObject(((BaseNode)expression).getBase()); |
|
3834 if (expression instanceof AccessNode) { |
|
3835 final AccessNode accessNode = (AccessNode) expression; |
|
3836 method.dynamicRemove(accessNode.getProperty(), getCallSiteFlags(), accessNode.isIndex()); |
|
3837 } else if (expression instanceof IndexNode) { |
|
3838 loadExpressionAsObject(((IndexNode) expression).getIndex()); |
|
3839 method.dynamicRemoveIndex(getCallSiteFlags()); |
|
3840 } else { |
|
3841 throw new AssertionError(expression.getClass().getName()); |
|
3842 } |
|
3843 } else { |
|
3844 throw new AssertionError(expression.getClass().getName()); |
3791 } |
3845 } |
3792 } |
3846 } |
3793 |
3847 |
3794 public void loadADD(final BinaryNode binaryNode, final TypeBounds resultBounds) { |
3848 public void loadADD(final BinaryNode binaryNode, final TypeBounds resultBounds) { |
3795 new OptimisticOperation(binaryNode, resultBounds) { |
3849 new OptimisticOperation(binaryNode, resultBounds) { |