Exemple #1
0
    @Specialization
    public RubyRegexp initialize(RubyRegexp regexp, RubyRegexp from) {
      notDesignedForCompilation();

      regexp.initialize(this, from.getSource()); // TODO: is copying needed?
      return regexp;
    }
Exemple #2
0
 @Specialization
 public RubyString to_s(RubyRegexp regexp) {
   return new RubyString(
       getContext().getCoreLibrary().getStringClass(),
       ((org.jruby.RubyString)
               org.jruby.RubyRegexp.newRegexp(
                       getContext().getRuntime(),
                       regexp.getSource(),
                       regexp.getRegex().getOptions())
                   .to_s())
           .getByteList());
 }
Exemple #3
0
    @Specialization
    public Object initializeCopy(RubyRegexp self, RubyRegexp from) {
      notDesignedForCompilation();

      if (self == from) {
        return self;
      }

      self.initialize(this, from.getSource()); // TODO: is copying needed?

      return self;
    }
Exemple #4
0
    @Specialization
    public boolean equal(RubyRegexp a, RubyRegexp b) {
      notDesignedForCompilation();

      return ((org.jruby.RubyString)
              org.jruby.RubyRegexp.newRegexp(
                      getContext().getRuntime(), a.getSource(), a.getRegex().getOptions())
                  .to_s())
          .getByteList()
          .equals(
              ((org.jruby.RubyString)
                      org.jruby.RubyRegexp.newRegexp(
                              getContext().getRuntime(), b.getSource(), b.getRegex().getOptions())
                          .to_s())
                  .getByteList());
    }
Exemple #5
0
    @Specialization
    public RubyRegexp initialize(RubyRegexp regexp, RubyString string) {
      notDesignedForCompilation();

      regexp.initialize(this, string.getBytes());
      return regexp;
    }
Exemple #6
0
    @Specialization
    public Object match(RubyRegexp regexp, RubyString string) {
      notDesignedForCompilation();

      return regexp.matchCommon(string.getBytes(), true, false)
          != getContext().getCoreLibrary().getNilObject();
    }
Exemple #7
0
 @Specialization
 public RubyString source(RubyRegexp regexp) {
   return getContext().makeString(regexp.getSource().toString());
 }
Exemple #8
0
 @Specialization
 public Object match(RubyRegexp regexp, RubyString string) {
   return regexp.matchCommon(string.getBytes(), false, false);
 }
Exemple #9
0
 @Specialization
 public RubyEncoding encoding(RubyRegexp regexp) {
   notDesignedForCompilation();
   return regexp.getEncoding();
 }