src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MapCreator.java

Print this page




  83                         key,
  84                         flags,
  85                         structure,
  86                         symbol.getFieldIndex(),
  87                         initialType);
  88                 properties.add(property);
  89             }
  90         }
  91 
  92         return PropertyMap.newMap(properties, structure.getName(), fieldCount, fieldMaximum, 0);
  93     }
  94 
  95     PropertyMap makeSpillMap(final boolean hasArguments) {
  96         final List<Property> properties = new ArrayList<>();
  97         int spillIndex = 0;
  98         assert tuples != null;
  99 
 100         for (final MapTuple<T> tuple : tuples) {
 101             final String key    = tuple.key;
 102             final Symbol symbol = tuple.symbol;

 103 
 104             //TODO initial type is object here no matter what. Is that right?
 105             if (symbol != null && !isValidArrayIndex(getArrayIndex(key))) {
 106                 final int flags = getPropertyFlags(symbol, hasArguments, false);
 107                 properties.add(
 108                         new SpillProperty(
 109                                 key,
 110                                 flags,
 111                                 spillIndex++));

 112             }
 113         }
 114 
 115         return PropertyMap.newMap(properties, structure.getName(), 0, 0, spillIndex);
 116     }
 117 
 118     /**
 119      * Compute property flags given local state of a field. May be overridden and extended,
 120      *
 121      * @param symbol       symbol to check
 122      * @param hasArguments does the created object have an "arguments" property
 123      *
 124      * @return flags to use for fields
 125      */
 126     static int getPropertyFlags(final Symbol symbol, final boolean hasArguments, final boolean evalCode) {
 127         int flags = 0;
 128 
 129         if (symbol.isParam()) {
 130             flags |= Property.IS_PARAMETER;
 131         }




  83                         key,
  84                         flags,
  85                         structure,
  86                         symbol.getFieldIndex(),
  87                         initialType);
  88                 properties.add(property);
  89             }
  90         }
  91 
  92         return PropertyMap.newMap(properties, structure.getName(), fieldCount, fieldMaximum, 0);
  93     }
  94 
  95     PropertyMap makeSpillMap(final boolean hasArguments) {
  96         final List<Property> properties = new ArrayList<>();
  97         int spillIndex = 0;
  98         assert tuples != null;
  99 
 100         for (final MapTuple<T> tuple : tuples) {
 101             final String key    = tuple.key;
 102             final Symbol symbol = tuple.symbol;
 103             final Class<?> initialType = tuple.getValueType();
 104 
 105             //TODO initial type is object here no matter what. Is that right?
 106             if (symbol != null && !isValidArrayIndex(getArrayIndex(key))) {
 107                 final int flags = getPropertyFlags(symbol, hasArguments, false);
 108                 properties.add(
 109                         new SpillProperty(
 110                                 key,
 111                                 flags,
 112                                 spillIndex++,
 113                                 initialType));
 114             }
 115         }
 116 
 117         return PropertyMap.newMap(properties, structure.getName(), 0, 0, spillIndex);
 118     }
 119 
 120     /**
 121      * Compute property flags given local state of a field. May be overridden and extended,
 122      *
 123      * @param symbol       symbol to check
 124      * @param hasArguments does the created object have an "arguments" property
 125      *
 126      * @return flags to use for fields
 127      */
 128     static int getPropertyFlags(final Symbol symbol, final boolean hasArguments, final boolean evalCode) {
 129         int flags = 0;
 130 
 131         if (symbol.isParam()) {
 132             flags |= Property.IS_PARAMETER;
 133         }