示例#1
0
 public LexerCache GetLexerCache()
 {
     if (lexcache == null)
     {
         lexcache = new LexerCache(this);
     }
     return(lexcache);
 }
示例#2
0
文件: Cursor.cs 项目: nbrown/niecza
 public LexerCache(STable mo)
 {
     this.mo = mo;
     if (mo.mo.superclasses.Count == 1) {
         parent = mo.mo.superclasses[0].GetLexerCache();
         repl_methods = new HashSet<string>();
         foreach (P6how.MethodInfo mi in mo.mo.lmethods) {
             if ((mi.flags & P6how.V_MASK) != P6how.V_PUBLIC)
                 continue;
             string mn = mi.short_name;
             int ix = mn.IndexOf(':');
             if (ix >= 0) repl_methods.Add(mn.Substring(0,ix));
             else repl_methods.Add(mn);
         }
     }
 }
示例#3
0
文件: Cursor.cs 项目: pmurias/niecza
 public LexerCache(DynMetaObject mo)
 {
     this.mo = mo;
     if (mo.superclasses.Count == 1) {
         parent = mo.superclasses[0].GetLexerCache();
         repl_methods = new HashSet<string>();
         foreach (string mn in mo.local.Keys) {
             int ix = mn.IndexOf(':');
             if (ix >= 0) repl_methods.Add(mn.Substring(0,ix));
             else repl_methods.Add(mn);
         }
     }
 }
示例#4
0
文件: Cursor.cs 项目: pmurias/niecza
    public static DynObject[] ResolveProtoregex(LexerCache lc,
            string name)
    {
        DynObject[] ret;
        DynMetaObject cursor_class = lc.mo;
        if (lc.protorx_fns.TryGetValue(name, out ret)) {
            if (LtmTrace)
                Console.WriteLine("+ Protoregex method list HIT on {0}.{1}",
                        cursor_class.name, name);
            return ret;
        }
        if (LtmTrace)
            Console.WriteLine("+ Protoregex method list MISS on {0}.{1}",
                    cursor_class.name, name);
        if (lc.parent != null && !lc.repl_methods.Contains(name)) {
            if (LtmTrace)
                Console.WriteLine("+ Stealing from parent");
            return lc.protorx_fns[name] = ResolveProtoregex(lc.parent, name);
        }

        IP6 proto = cursor_class.Can(name);
        string filter = name + ":";

        List<DynObject> raword = new List<DynObject>();

        foreach (DynMetaObject k in cursor_class.mro) {
            if (proto != k.Can(name))
                continue;
            foreach (KeyValuePair<string,IP6> o in k.ord_methods) {
                if (!Utils.StartsWithInvariant(filter, o.Key))
                    continue;
                if (cursor_class.Can(o.Key) == o.Value) {
                    raword.Add((DynObject) o.Value);
                }
            }
        }

        ret = raword.ToArray();
        cursor_class.GetLexerCache().protorx_fns[name] = ret;
        return ret;
    }