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


C# RakudoObject类代码示例

本文整理汇总了C#中RakudoObject的典型用法代码示例。如果您正苦于以下问题:C# RakudoObject类的具体用法?C# RakudoObject怎么用?C# RakudoObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: instance_of

 /// <summary>
 /// Create an instance of the given object.
 /// </summary>
 /// <param name="WHAT"></param>
 /// <returns></returns>
 public override RakudoObject instance_of(ThreadContext TC, RakudoObject WHAT)
 {
     var Object = new KnowHOWInstance(WHAT.STable);
     Object.Methods = new Dictionary<string, RakudoObject>();
     Object.Attributes = new List<RakudoObject>();
     return Object;
 }
开发者ID:jnthn,项目名称:6model,代码行数:12,代码来源:KnowHOWREPR.cs

示例2: bind_attribute

        /// <summary>
        /// 
        /// </summary>
        /// <param name="Object"></param>
        /// <param name="ClassHandle"></param>
        /// <param name="Name"></param>
        /// <param name="Value"></param>
        public override void bind_attribute(ThreadContext TC, RakudoObject Object, RakudoObject ClassHandle, string Name, RakudoObject Value)
        {
            var I = (Instance)Object;

            // Try the slot allocation first.
            Dictionary<string, int> ClassAllocation;
            int Position;
            if (SlotAllocation != null && SlotAllocation.TryGetValue(ClassHandle, out ClassAllocation))
                if (ClassAllocation.TryGetValue(Name, out Position))
                {
                    I.SlotStorage[Position] = Value;
                    return;
                }

            // Fall back to the spill storage.
            if (I.SpillStorage == null)
                I.SpillStorage = new Dictionary<RakudoObject, Dictionary<string, RakudoObject>>();
            if (!I.SpillStorage.ContainsKey(ClassHandle))
                I.SpillStorage.Add(ClassHandle, new Dictionary<string, RakudoObject>());
            var ClassStore = I.SpillStorage[ClassHandle];
            if (ClassStore.ContainsKey(Name))
                ClassStore[Name] = Value;
            else
                ClassStore.Add(Name, Value);
        }
开发者ID:jnthn,项目名称:6model,代码行数:32,代码来源:P6opaque.cs

示例3: get_attribute

 /// <summary>
 /// Gets the attribute with the given value.
 /// </summary>
 /// <param name="ClassHandle"></param>
 /// <param name="Name"></param>
 /// <returns></returns>
 public override RakudoObject get_attribute(ThreadContext TC, RakudoObject Object, RakudoObject ClassHandle, string Name)
 {
     // If no storage ever allocated, trivially no value. Otherwise,
     // return what we find.
     var I = (Instance)Object;
     if (I.Storage == null || !I.Storage.ContainsKey(ClassHandle))
         return null;
     var ClassStore = I.Storage[ClassHandle];
     return ClassStore.ContainsKey(Name) ? ClassStore[Name] : null;
 }
开发者ID:Util,项目名称:6model,代码行数:16,代码来源:P6hash.cs

示例4: bind_attribute

        /// <summary>
        /// Binds an attribute to the given value.
        /// </summary>
        /// <param name="Object"></param>
        /// <param name="ClassHandle"></param>
        /// <param name="Name"></param>
        /// <param name="Value"></param>
        public override void bind_attribute(ThreadContext TC, RakudoObject Object, RakudoObject ClassHandle, string Name, RakudoObject Value)
        {
            // If no storage at all, allocate some.
            var I = (Instance)Object;
            if (I.Storage == null)
                I.Storage = new Dictionary<RakudoObject, Dictionary<string, RakudoObject>>();
            if (!I.Storage.ContainsKey(ClassHandle))
                I.Storage.Add(ClassHandle, new Dictionary<string, RakudoObject>());

            // Now stick in the name slot for the class storage, creating if it
            // needed.
            var ClassStore = I.Storage[ClassHandle];
            if (ClassStore.ContainsKey(Name))
                ClassStore[Name] = Value;
            else
                ClassStore.Add(Name, Value);
        }
开发者ID:Util,项目名称:6model,代码行数:24,代码来源:P6hash.cs

示例5: bind_attribute_with_hint

 /// <summary>
 /// Bind the attribute, using the hint if possible.
 /// </summary>
 /// <param name="Object"></param>
 /// <param name="ClassHandle"></param>
 /// <param name="Name"></param>
 /// <param name="Hint"></param>
 /// <param name="Value"></param>
 public override void bind_attribute_with_hint(ThreadContext TC, RakudoObject Object, RakudoObject ClassHandle, string Name, int Hint, RakudoObject Value)
 {
     var I = (Instance)Object;
     if (Hint < I.SlotStorage.Length)
     {
         I.SlotStorage[Hint] = Value;
     }
     else if ((Hint = hint_for(TC, ClassHandle, Name)) != Hints.NO_HINT && Hint < I.SlotStorage.Length)
     {
         I.SlotStorage[Hint] = Value;
     }
     else
     {
         if (I.SpillStorage == null)
             I.SpillStorage = new Dictionary<RakudoObject, Dictionary<string, RakudoObject>>();
         if (!I.SpillStorage.ContainsKey(ClassHandle))
             I.SpillStorage.Add(ClassHandle, new Dictionary<string, RakudoObject>());
         var ClassStore = I.SpillStorage[ClassHandle];
         if (ClassStore.ContainsKey(Name))
             ClassStore[Name] = Value;
         else
             ClassStore.Add(Name, Value);
     }
 }
开发者ID:jnthn,项目名称:6model,代码行数:32,代码来源:P6opaque.cs

示例6: get_attribute_with_hint

 public override RakudoObject get_attribute_with_hint(ThreadContext TC, RakudoObject Object, RakudoObject ClassHandle, string Name, int Hint)
 {
     throw new InvalidOperationException("Native captures cannot store additional attributes.");
 }
开发者ID:jnthn,项目名称:6model,代码行数:4,代码来源:P6capture.cs

示例7: defined

 /// <summary>
 /// Determines if the representation is defined or not.
 /// </summary>
 /// <param name="Obj"></param>
 /// <returns></returns>
 public override bool defined(ThreadContext TC, RakudoObject O)
 {
     var Obj = (Instance)O;
     return Obj.Positionals != null || Obj.Nameds != null;
 }
开发者ID:jnthn,项目名称:6model,代码行数:10,代码来源:P6capture.cs

示例8: get_num

 public override double get_num(ThreadContext TC, RakudoObject Object)
 {
     throw new NotImplementedException();
 }
开发者ID:jnthn,项目名称:6model,代码行数:4,代码来源:P6mapping.cs

示例9: defined

 /// <summary>
 /// Checks if the object is defined, which boils down to "is
 /// this a type object", which in trun means "did we allocate
 /// any storage".
 /// </summary>
 /// <param name="Object"></param>
 /// <returns></returns>
 public override bool defined(ThreadContext TC, RakudoObject Object)
 {
     return ((Instance)Object).Storage != null;
 }
开发者ID:Util,项目名称:6model,代码行数:11,代码来源:P6hash.cs

示例10: set_str

 public override void set_str(ThreadContext TC, RakudoObject Object, string Value)
 {
     throw new InvalidOperationException("This type of representation cannot box a native string");
 }
开发者ID:Util,项目名称:6model,代码行数:4,代码来源:P6hash.cs

示例11: instance_of

 /// <summary>
 /// Allocates and returns a new object based upon the type object
 /// supplied.
 /// </summary>
 /// <param name="HOW"></param>
 /// <returns></returns>
 public override RakudoObject instance_of(ThreadContext TC, RakudoObject WHAT)
 {
     var Object = new Instance(WHAT.STable);
     Object.Storage = new Dictionary<RakudoObject, Dictionary<string, RakudoObject>>();
     return Object;
 }
开发者ID:Util,项目名称:6model,代码行数:12,代码来源:P6hash.cs

示例12: bind_attribute_with_hint

 public override void bind_attribute_with_hint(ThreadContext TC, RakudoObject Object, RakudoObject ClassHandle, string Name, int Hint, RakudoObject Value)
 {
     throw new InvalidOperationException("Boxed native types cannot store additional attributes.");
 }
开发者ID:jnthn,项目名称:6model,代码行数:4,代码来源:P6int.cs

示例13: SetupKnowHOWAttribute

        /// <summary>
        /// Sets up the KnowHOWAttribute object/class, which actually is a
        /// KnowHOW.
        /// </summary>
        /// <returns></returns>
        public static RakudoObject SetupKnowHOWAttribute(RakudoObject KnowHOW)
        {
            // Create a new HOW instance.
            var HOW = KnowHOW.STable.REPR.instance_of(null, KnowHOW) as KnowHOWREPR.KnowHOWInstance;

            // We base the attribute on P6str, since we just want to store an
            // attribute name for now.
            var KnowHOWAttribute = REPRRegistry.get_REPR_by_name("P6str").type_object_for(null, HOW);

            // Add methods new and Str.
            HOW.Methods.Add("new", CodeObjectUtility.WrapNativeMethod((TC, Code, Cap) =>
                {
                    var WHAT = CaptureHelper.GetPositional(Cap, 0).STable.WHAT;
                    var Name = Ops.unbox_str(TC, CaptureHelper.GetNamed(Cap, "name"));
                    return Ops.box_str(TC, Name, WHAT);
                }));
            HOW.Methods.Add("name", CodeObjectUtility.WrapNativeMethod((TC, Code, Cap) =>
                {
                    var self = CaptureHelper.GetPositional(Cap, 0);
                    return Ops.box_str(TC, Ops.unbox_str(TC, self), TC.DefaultStrBoxType);
                }));

            return KnowHOWAttribute;
        }
开发者ID:jnthn,项目名称:6model,代码行数:29,代码来源:KnowHOWBootstrapper.cs

示例14: set_str

 public override void set_str(ThreadContext TC, RakudoObject Object, string Value)
 {
     throw new NotImplementedException();
 }
开发者ID:jnthn,项目名称:6model,代码行数:4,代码来源:P6mapping.cs

示例15: set_num

 public override void set_num(ThreadContext TC, RakudoObject Object, double Value)
 {
     throw new NotImplementedException();
 }
开发者ID:jnthn,项目名称:6model,代码行数:4,代码来源:P6mapping.cs


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