8015684: FieldObjectCreator.putField ignores getValueType
authorattila
Fri, 31 May 2013 12:57:25 +0200
changeset 17968 108ba976aa02
parent 17967 0ac7d2a303b9
child 17969 0a4ddfce5b84
8015684: FieldObjectCreator.putField ignores getValueType Reviewed-by: jlaskey, lagergren
nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java
nashorn/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java
--- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Fri May 31 12:56:56 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java	Fri May 31 12:57:25 2013 +0200
@@ -60,7 +60,6 @@
 import java.util.List;
 import java.util.Locale;
 import java.util.TreeMap;
-
 import jdk.nashorn.internal.codegen.ClassEmitter.Flag;
 import jdk.nashorn.internal.codegen.CompilerConstants.Call;
 import jdk.nashorn.internal.codegen.RuntimeCallSite.SpecializedRuntimeNode;
@@ -80,11 +79,11 @@
 import jdk.nashorn.internal.ir.ExecuteNode;
 import jdk.nashorn.internal.ir.ForNode;
 import jdk.nashorn.internal.ir.FunctionNode;
-import jdk.nashorn.internal.ir.LexicalContext;
 import jdk.nashorn.internal.ir.FunctionNode.CompilationState;
 import jdk.nashorn.internal.ir.IdentNode;
 import jdk.nashorn.internal.ir.IfNode;
 import jdk.nashorn.internal.ir.IndexNode;
+import jdk.nashorn.internal.ir.LexicalContext;
 import jdk.nashorn.internal.ir.LexicalContextNode;
 import jdk.nashorn.internal.ir.LiteralNode;
 import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode;
@@ -942,11 +941,6 @@
              */
             final FieldObjectCreator<Symbol> foc = new FieldObjectCreator<Symbol>(this, nameList, newSymbols, values, true, hasArguments) {
                 @Override
-                protected Type getValueType(final Symbol value) {
-                    return value.getSymbolType();
-                }
-
-                @Override
                 protected void loadValue(final Symbol value) {
                     method.load(value);
                 }
@@ -1357,11 +1351,6 @@
 
         new FieldObjectCreator<Node>(this, keys, symbols, values) {
             @Override
-            protected Type getValueType(final Node node) {
-                return node.getType();
-            }
-
-            @Override
             protected void loadValue(final Node node) {
                 load(node);
             }
--- a/nashorn/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java	Fri May 31 12:56:56 2013 +0200
+++ b/nashorn/src/jdk/nashorn/internal/codegen/FieldObjectCreator.java	Fri May 31 12:57:25 2013 +0200
@@ -145,15 +145,6 @@
     protected abstract void loadValue(T value);
 
     /**
-     * Determine the type of a value. Defined by anonymous subclasses in code gen.
-     *
-     * @param value Value to inspect.
-     *
-     * @return Value type.
-     */
-    protected abstract Type getValueType(T value);
-
-    /**
      * Store a value in a field of the generated class object.
      *
      * @param method      Script method.
@@ -165,13 +156,6 @@
         method.dup();
 
         loadValue(value);
-
-        final Type valueType = getValueType(value);
-        // for example when we have a with scope
-        if (valueType.isObject() || valueType.isBoolean()) {
-            method.convert(OBJECT);
-        }
-
         method.convert(OBJECT);
         method.putField(getClassName(), ObjectClassGenerator.getFieldName(fieldIndex, Type.OBJECT), typeDescriptor(Object.class));
     }