public Regexp get(StringValue str)
        {
            int head = _head;

            for (int i = 0; i < MAX_SIZE; i++)
            {
                Regexp regexp = _cache[(head + i) % MAX_SIZE];

                if (regexp == null)
                {
                    break;
                }
                else
                {
                    StringValue rawRegexp = regexp.getRawRegexp();

                    if (rawRegexp == str || rawRegexp.equals(str))
                    {
                        return(regexp);
                    }
                }
            }

            Regexp regexp = RegexpModule.createRegexp(str);

            head = head - 1;

            if (head < 0)
            {
                head = MAX_SIZE - 1;
            }

            _cache[head] = regexp;
            _head        = head;

            return(regexp);
        }
Exemple #2
0
 public override Object marshal(Env env, Value value, Class expectedClass)
 {
     return(RegexpModule.createRegexp(value.ToStringValue(env)));
 }
Exemple #3
0
 public override Object marshal(Env env, Expr expr, Class expectedClass)
 {
     return(RegexpModule.createRegexp(expr.evalStringValue(env)));
 }