src/jdk/nashorn/internal/codegen/CodeGeneratorLexicalContext.java

Print this page
rev 738 : 8030182: scopeCall with -1 as line number
Reviewed-by: hannesw, jlaskey


 141     Collection<SharedScopeCall> getScopeCalls() {
 142         return Collections.unmodifiableCollection(scopeCalls.values());
 143     }
 144 
 145     /**
 146      * Get a shared static method representing a dynamic scope callsite.
 147      *
 148      * @param unit current compile unit
 149      * @param symbol the symbol
 150      * @param valueType the value type of the symbol
 151      * @param returnType the return type
 152      * @param paramTypes the parameter types
 153      * @param flags the callsite flags
 154      * @return an object representing a shared scope call
 155      */
 156     SharedScopeCall getScopeCall(final CompileUnit unit, final Symbol symbol, final Type valueType, final Type returnType, final Type[] paramTypes, final int flags) {
 157         final SharedScopeCall scopeCall = new SharedScopeCall(symbol, valueType, returnType, paramTypes, flags);
 158         if (scopeCalls.containsKey(scopeCall)) {
 159             return scopeCalls.get(scopeCall);
 160         }
 161         scopeCall.setClassAndName(unit, getCurrentFunction().uniqueName("scopeCall"));
 162         scopeCalls.put(scopeCall, scopeCall);
 163         return scopeCall;
 164     }
 165 
 166     /**
 167      * Get a shared static method representing a dynamic scope get access.
 168      *
 169      * @param unit current compile unit
 170      * @param type the type of the variable
 171      * @param symbol the symbol
 172      * @param flags the callsite flags
 173      * @return an object representing a shared scope call
 174      */
 175     SharedScopeCall getScopeGet(final CompileUnit unit, final Type type, final Symbol symbol, final int flags) {
 176         final SharedScopeCall scopeCall = new SharedScopeCall(symbol, type, type, null, flags);
 177         if (scopeCalls.containsKey(scopeCall)) {
 178             return scopeCalls.get(scopeCall);
 179         }
 180         scopeCall.setClassAndName(unit, getCurrentFunction().uniqueName("scopeCall"));
 181         scopeCalls.put(scopeCall, scopeCall);
 182         return scopeCall;
 183     }
 184 
 185 
 186     void nextFreeSlot(final Block block) {
 187         final boolean isFunctionBody = isFunctionBody();
 188 
 189         final int nextFreeSlot;
 190         if (isFunctionBody) {
 191             // On entry to function, start with slot 0
 192             nextFreeSlot = 0;
 193         } else {
 194             // Otherwise, continue from previous block's first free slot
 195             nextFreeSlot = nextFreeSlots[nextFreeSlotsSize - 1];
 196         }
 197         if (nextFreeSlotsSize == nextFreeSlots.length) {
 198             final int[] newNextFreeSlots = new int[nextFreeSlotsSize * 2];
 199             System.arraycopy(nextFreeSlots, 0, newNextFreeSlots, 0, nextFreeSlotsSize);
 200             nextFreeSlots = newNextFreeSlots;




 141     Collection<SharedScopeCall> getScopeCalls() {
 142         return Collections.unmodifiableCollection(scopeCalls.values());
 143     }
 144 
 145     /**
 146      * Get a shared static method representing a dynamic scope callsite.
 147      *
 148      * @param unit current compile unit
 149      * @param symbol the symbol
 150      * @param valueType the value type of the symbol
 151      * @param returnType the return type
 152      * @param paramTypes the parameter types
 153      * @param flags the callsite flags
 154      * @return an object representing a shared scope call
 155      */
 156     SharedScopeCall getScopeCall(final CompileUnit unit, final Symbol symbol, final Type valueType, final Type returnType, final Type[] paramTypes, final int flags) {
 157         final SharedScopeCall scopeCall = new SharedScopeCall(symbol, valueType, returnType, paramTypes, flags);
 158         if (scopeCalls.containsKey(scopeCall)) {
 159             return scopeCalls.get(scopeCall);
 160         }
 161         scopeCall.setClassAndName(unit, getCurrentFunction().uniqueName(":scopeCall"));
 162         scopeCalls.put(scopeCall, scopeCall);
 163         return scopeCall;
 164     }
 165 
 166     /**
 167      * Get a shared static method representing a dynamic scope get access.
 168      *
 169      * @param unit current compile unit
 170      * @param type the type of the variable
 171      * @param symbol the symbol
 172      * @param flags the callsite flags
 173      * @return an object representing a shared scope call
 174      */
 175     SharedScopeCall getScopeGet(final CompileUnit unit, final Type type, final Symbol symbol, final int flags) {
 176         final SharedScopeCall scopeCall = new SharedScopeCall(symbol, type, type, null, flags);
 177         if (scopeCalls.containsKey(scopeCall)) {
 178             return scopeCalls.get(scopeCall);
 179         }
 180         scopeCall.setClassAndName(unit, getCurrentFunction().uniqueName(":scopeCall"));
 181         scopeCalls.put(scopeCall, scopeCall);
 182         return scopeCall;
 183     }
 184 
 185 
 186     void nextFreeSlot(final Block block) {
 187         final boolean isFunctionBody = isFunctionBody();
 188 
 189         final int nextFreeSlot;
 190         if (isFunctionBody) {
 191             // On entry to function, start with slot 0
 192             nextFreeSlot = 0;
 193         } else {
 194             // Otherwise, continue from previous block's first free slot
 195             nextFreeSlot = nextFreeSlots[nextFreeSlotsSize - 1];
 196         }
 197         if (nextFreeSlotsSize == nextFreeSlots.length) {
 198             final int[] newNextFreeSlots = new int[nextFreeSlotsSize * 2];
 199             System.arraycopy(nextFreeSlots, 0, newNextFreeSlots, 0, nextFreeSlotsSize);
 200             nextFreeSlots = newNextFreeSlots;