// INITIAL AND FALLBACK METHODS FOR POST BOOTSTRAP
////////////////////////////////////////////////////////////////////////////
public static IRubyObject constantFallback(RubyConstantCallSite site,
AbstractScript script, ThreadContext context, int scopeIndex) {
SwitchPoint switchPoint = (SwitchPoint)context.runtime.getConstantInvalidator().getData();
StaticScope scope = script.getScope(scopeIndex);
IRubyObject value = scope.getConstant(site.name());
if (value != null) {
if (RubyInstanceConfig.LOG_INDY_CONSTANTS) LOG.info("constant " + site.name() + " bound directly");
MethodHandle valueHandle = constant(IRubyObject.class, value);
valueHandle = dropArguments(valueHandle, 0, AbstractScript.class, ThreadContext.class);
MethodHandle fallback = insertArguments(
findStatic(InvokeDynamicSupport.class, "constantFallback",
methodType(IRubyObject.class, RubyConstantCallSite.class, AbstractScript.class, ThreadContext.class, int.class)),
0,
site);
fallback = insertArguments(fallback, 2, scopeIndex);
MethodHandle gwt = switchPoint.guardWithTest(valueHandle, fallback);
site.setTarget(gwt);
} else {
value = scope.getModule()
.callMethod(context, "const_missing", context.runtime.newSymbol(site.name()));
}