MCPcopy Index your code
hub / github.com/bazelbuild/bazel / getIndexOfGlobal

Method getIndexOfGlobal

src/main/java/net/starlark/java/eval/Module.java:289–299  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 2

getIndicesOfGlobalsMethod · 0.95
setGlobalMethod · 0.95

Calls 2

sizeMethod · 0.45
copyOfMethod · 0.45

Tested by

no test coverage detected