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

Method evalIdentifier

src/main/java/net/starlark/java/eval/Eval.java:796–828  ·  view source on GitHub ↗
(StarlarkThread.Frame fr, Identifier id)

Source from the content-addressed store, hash-verified

794 }
795
796 private static Object evalIdentifier(StarlarkThread.Frame fr, Identifier id)
797 throws EvalException, InterruptedException {
798 Resolver.Binding bind = id.getBinding();
799 Object result;
800 switch (bind.getScope()) {
801 case LOCAL:
802 result = fr.locals[bind.getIndex()];
803 break;
804 case CELL:
805 result = ((StarlarkFunction.Cell) fr.locals[bind.getIndex()]).x;
806 break;
807 case FREE:
808 result = fn(fr).getFreeVar(bind.getIndex()).x;
809 break;
810 case GLOBAL:
811 result = fn(fr).getGlobal(bind.getIndex());
812 break;
813 case PREDECLARED:
814 result = fn(fr).getModule().getPredeclared(id.getName());
815 break;
816 case UNIVERSAL:
817 result = Starlark.UNIVERSE.get(id.getName());
818 break;
819 default:
820 throw new IllegalStateException(bind.toString());
821 }
822 if (result == null) {
823 fr.setErrorLocation(id.getStartLocation());
824 throw Starlark.errorf(
825 "%s variable '%s' is referenced before assignment.", bind.getScope(), id.getName());
826 }
827 return result;
828 }
829
830 private static Object evalIndex(StarlarkThread.Frame fr, IndexExpression index)
831 throws EvalException, InterruptedException {

Callers 1

evalMethod · 0.95

Calls 14

fnMethod · 0.95
errorfMethod · 0.95
getBindingMethod · 0.80
getScopeMethod · 0.80
getFreeVarMethod · 0.80
getPredeclaredMethod · 0.80
setErrorLocationMethod · 0.80
getIndexMethod · 0.65
getNameMethod · 0.65
getMethod · 0.65
getGlobalMethod · 0.45
getModuleMethod · 0.45

Tested by

no test coverage detected