public static CallSite bootstrap(MethodHandles.Lookup lookup, String name, MethodType type, int options) { return new DRegexpObjectSite(type, options).bootstrap(lookup); }
public RubyRegexp construct(ThreadContext context, RubyString[] pieces) throws Throwable { RubyString pattern = RubyRegexp.preprocessDRegexp(context.runtime, pieces, options); RubyRegexp re = RubyRegexp.newDRegexp(context.runtime, pattern, options); re.setLiteral(); if (options.isOnce()) { if (cache != null) { // we cached a value, so re-call this site's target handle to get it return cache; } // we don't care if this succeeds, just that it only gets set once UPDATER.compareAndSet(this, null, cache); setTarget(Binder.from(type()).dropAll().constant(cache)); } return re; } }
@Override public Binder prepareBinder() { // collect dregexp args into an array String[] argNames = new String[type().parameterCount()]; Class[] argTypes = new Class[argNames.length]; argNames[0] = "context"; argTypes[0] = ThreadContext.class; for (int i = 1; i < argNames.length; i++) { argNames[i] = "part" + i; argTypes[i] = RubyString.class; } // "once" deregexp must be handled on the call side return SmartBinder .from(RubyRegexp.class, argNames, argTypes) .collect("parts", "part.*") .binder(); }
public RubyRegexp construct(ThreadContext context, RubyString[] pieces) throws Throwable { RubyString pattern = RubyRegexp.preprocessDRegexp(context.runtime, pieces, options); RubyRegexp re = RubyRegexp.newDRegexp(context.runtime, pattern, options); re.setLiteral(); if (options.isOnce()) { if (cache != null) { // we cached a value, so re-call this site's target handle to get it return cache; } // we don't care if this succeeds, just that it only gets set once UPDATER.compareAndSet(this, null, cache); setTarget(Binder.from(type()).dropAll().constant(cache)); } return re; } }
@Override public Binder prepareBinder() { // collect dregexp args into an array String[] argNames = new String[type().parameterCount()]; Class[] argTypes = new Class[argNames.length]; argNames[0] = "context"; argTypes[0] = ThreadContext.class; for (int i = 1; i < argNames.length; i++) { argNames[i] = "part" + i; argTypes[i] = RubyString.class; } // "once" deregexp must be handled on the call side return SmartBinder .from(RubyRegexp.class, argNames, argTypes) .collect("parts", "part.*") .binder(); }
public static CallSite bootstrap(MethodHandles.Lookup lookup, String name, MethodType type, int options) { return new DRegexpObjectSite(type, options).bootstrap(lookup); }