当前位置: 首页>>代码示例>>C#>>正文


C# P6any.GetSlot方法代码示例

本文整理汇总了C#中P6any.GetSlot方法的典型用法代码示例。如果您正苦于以下问题:C# P6any.GetSlot方法的具体用法?C# P6any.GetSlot怎么用?C# P6any.GetSlot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在P6any的用法示例。


在下文中一共展示了P6any.GetSlot方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: get_count

 public static int get_count(P6any fcni)
 {
     if (!fcni.Isa(Kernel.CodeMO))
         return 1; // can't introspect fake subs (?)
     return get_count((SubInfo) fcni.GetSlot("info"));
 }
开发者ID:ebassi,项目名称:niecza,代码行数:6,代码来源:Builtins.cs

示例2: code_accepts_capture

 public static Frame code_accepts_capture(Frame th, P6any code, P6any cap)
 {
     var setting = th.info.setting;
     return Kernel.GetInfo(code).SetupCall(th, Kernel.GetOuter(code), code,
         (Variable[])cap.GetSlot(setting.CaptureMO, "$!positionals"),
         (VarHash)cap.GetSlot(setting.CaptureMO, "$!named"),
         true, null);
 }
开发者ID:o-fun,项目名称:niecza,代码行数:8,代码来源:Builtins.cs

示例3: arity

 public static Variable arity(P6any fcni)
 {
     if (!fcni.Isa(Kernel.CodeMO))
         return MakeInt(1); // can't introspect fake subs (?)
     SubInfo si = (SubInfo) fcni.GetSlot("info");
     if (si.sig == null)
         return MakeInt(1);
     int arity = 0;
     foreach (Parameter p in si.sig.parms) {
         int fl = p.flags;
         if ((fl & (Parameter.SLURPY_CAP | Parameter.SLURPY_POS |
                 Parameter.SLURPY_PCL | Parameter.SLURPY_NAM |
                 Parameter.OPTIONAL | Parameter.DEFOUTER |
                 Parameter.HASDEFAULT)) != 0)
             continue;
         if ((fl & Parameter.POSITIONAL) == 0) continue;
         arity++;
     }
     return MakeInt(arity);
 }
开发者ID:ebassi,项目名称:niecza,代码行数:20,代码来源:Builtins.cs

示例4: mixin

    public static Variable mixin(Constants c, P6any obj, Variable role_list, Variable init,
            Variable newtype)
    {
        VarDeque iter = start_iter(role_list);
        List<STable> roles = new List<STable>();
        while (Kernel.IterHasFlat(iter, true))
            roles.Add(iter.Shift().Fetch().mo);

        STable n = new STable(c.setting, obj.mo.name + "+" + Kernel.JoinS(",", roles));

        n.how = Kernel.BoxAny<STable>(n, obj.mo.how).Fetch();
        n.typeObj = n.initObj = new P6opaque(n);
        ((P6opaque)n.typeObj).slots = null;

        n.mo.superclasses.Add(obj.mo);
        n.mo.local_roles = roles;
        n.mo.Compose();
        newtype.Store(n.typeObj);

        string aname = null;
        if (init != c.setting.AnyP) {
            if (!obj.IsDefined())
                throw new NieczaException("Cannot initialize a slot when mixing into a type object");
            if (n.mo.local_attr.Count != 1 || (n.mo.local_attr[0].flags & P6how.A_PUBLIC) == 0)
                throw new NieczaException("Role(s) being mixed in do not define precisely one, public attribute");
            aname = n.mo.local_attr[0].name;
        }

        if (obj.IsDefined()) {
            obj.ChangeType(n);

            BuildMostDerived(obj);
            if (aname != null)
                Kernel.Assign((Variable)obj.GetSlot(n, aname), init);
            return obj;
        } else {
            return n.typeObj;
        }
    }
开发者ID:o-fun,项目名称:niecza,代码行数:39,代码来源:Builtins.cs

示例5: ind_method_call

    public static Frame ind_method_call(Frame th, StashCursor root,
            string nm, P6any cap)
    {
        int cut = nm.LastIndexOf("::");
        var setting = th.info.setting;
        var pos = (Variable[]) cap.GetSlot(setting.CaptureMO, "$!positionals");
        var nam = (VarHash)    cap.GetSlot(setting.CaptureMO, "$!named");

        if (cut < 0) {
            return pos[0].Fetch().InvokeMethod(th, nm, pos, nam);
        } else {
            var from = root.Indirect(nm.Substring(0, cut), false, null)
                .Fetch().mo;
            var name = nm.Substring(cut+2);

            // some code copied from dispatch_fromtype
            if (!pos[0].Fetch().Does(from)) {
                return Kernel.Die(th, "Cannot dispatch to a method on " +
                    from.name + " because it is not inherited or done by " +
                    pos[0].Fetch().mo.name);
            }

            var de = from.FindMethod(name);
            if (de != null) {
                return de.info.SetupCall(th, de.outer, de.ip6,
                            pos, nam, false, de);
            } else {
                return Kernel.Die(th, "Unable to resolve method " + name +
                        " via " + from.name);
            }
        }
    }
开发者ID:o-fun,项目名称:niecza,代码行数:32,代码来源:Builtins.cs

示例6: get_count

 public static int get_count(P6any fcni)
 {
     if (!fcni.Isa(Kernel.CodeMO))
         return 1; // can't introspect fake subs (?)
     SubInfo si = (SubInfo) fcni.GetSlot("info");
     int[] sig = si.sig_i;
     if (sig == null)
         return 1;
     int arity = 0;
     for (int i = 0; i < sig.Length; i += SubInfo.SIG_I_RECORD) {
         int fl = sig[i + SubInfo.SIG_I_FLAGS];
         if ((fl & (SubInfo.SIG_F_SLURPY_CAP | SubInfo.SIG_F_SLURPY_POS |
                 SubInfo.SIG_F_SLURPY_PCL)) != 0)
             return int.MaxValue;
         if ((fl & SubInfo.SIG_F_POSITIONAL) == 0) continue;
         arity++;
     }
     return arity;
 }
开发者ID:Util,项目名称:niecza,代码行数:19,代码来源:Builtins.cs

示例7: arity

 public static Variable arity(P6any fcni)
 {
     if (!fcni.Isa(Kernel.CodeMO))
         return MakeInt(1); // can't introspect fake subs (?)
     SubInfo si = (SubInfo) fcni.GetSlot("info");
     int[] sig = si.sig_i;
     if (sig == null)
         return MakeInt(1);
     int arity = 0;
     for (int i = 0; i < sig.Length; i += SubInfo.SIG_I_RECORD) {
         int fl = sig[i + SubInfo.SIG_I_FLAGS];
         if ((fl & (SubInfo.SIG_F_SLURPY_CAP | SubInfo.SIG_F_SLURPY_POS |
                 SubInfo.SIG_F_SLURPY_PCL | SubInfo.SIG_F_SLURPY_NAM |
                 SubInfo.SIG_F_OPTIONAL | SubInfo.SIG_F_DEFOUTER |
                 SubInfo.SIG_F_HASDEFAULT)) != 0)
             continue;
         if ((fl & SubInfo.SIG_F_POSITIONAL) == 0) continue;
         arity++;
     }
     return MakeInt(arity);
 }
开发者ID:Util,项目名称:niecza,代码行数:21,代码来源:Builtins.cs

示例8: MakeDispatcher

 public static P6any MakeDispatcher(string name, P6any proto, P6any[] cands)
 {
     if (proto != null) {
         SubInfo si = new SubInfo((SubInfo)proto.GetSlot("info"));
         si.param = new object[] { cands, null };
         return Kernel.MakeSub(si, (Frame)proto.GetSlot("outer"));
     } else {
         SubInfo si = new SubInfo(name, StandardProtoC);
         si.param = new object[] { cands, null };
         si.ltm = new LADDispatcher();
         return Kernel.MakeSub(si, null);
     }
 }
开发者ID:ebassi,项目名称:niecza,代码行数:13,代码来源:Cursor.cs


注:本文中的P6any.GetSlot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。