Returns the index within this Module of a global variable, given its name, creating a new slot for it if needed. The numbering of globals used by these functions is not the same as the numbering within any compiled Program. Thus each StarlarkFunction must contain a secondary index mapping Program in
(String name)
| 287 | * index mapping Program indices (from Binding.index) to Module indices. |
| 288 | */ |
| 289 | int getIndexOfGlobal(String name) { |
| 290 | int i = globalIndex.size(); |
| 291 | Integer prev = globalIndex.putIfAbsent(name, i); |
| 292 | if (prev != null) { |
| 293 | return prev; |
| 294 | } |
| 295 | if (i == globals.length) { |
| 296 | globals = Arrays.copyOf(globals, globals.length << 1); // grow by doubling |
| 297 | } |
| 298 | return i; |
| 299 | } |
| 300 | |
| 301 | private static final int[] EMPTY_INDICES = new int[0]; |
| 302 |
no test coverage detected