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


C# CallSiteStorage类代码示例

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


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

示例1: PrecInteger

        public static object PrecInteger(
            CallSiteStorage<Func<CallSite, RubyContext, object, RubyClass, object>>/*!*/ precStorage,
            RubyContext/*!*/ context, object self) {

            var prec = precStorage.GetCallSite("prec", 1);
            return prec.Target(prec, context, self, context.GetClass(typeof(Integer)));
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:7,代码来源:Precision.cs

示例2: Count

 public static int Count(CallSiteStorage<EachSite>/*!*/ each, object self)
 {
     int result = 0;
     Each(each, self, Proc.Create(each.Context, delegate(BlockParam/*!*/ selfBlock, object _, object item) {
         result++;
         return null;
     }));
     return result;
 }
开发者ID:TerabyteX,项目名称:main,代码行数:9,代码来源:Enumerable.cs

示例3: Each

 private static object Each(CallSiteStorage<EachSite>/*!*/ each, RubyContext/*!*/ context, object self, Proc/*!*/ block) {
     var enumerator = self as Enumerator;
     if (enumerator != null) {
         return enumerator.Each(context, block);
     } else {
         var site = each.GetCallSite("each", RubyCallSignature.WithBlock(0));
         return site.Target(site, context, self, block);
     }
 }
开发者ID:joshholmes,项目名称:ironruby,代码行数:9,代码来源:Enumerable.cs

示例4: Map

 public static RubyArray Map(CallSiteStorage<EachSite>/*!*/ each, BlockParam collector, object self) {
     RubyArray result = new RubyArray();
     Each(each, self, Proc.Create(each.Context, delegate(BlockParam/*!*/ selfBlock, object _, object item) {
         if (collector != null) {
             if (collector.Yield(item, out item)) {
                 return item;
             }
         }
         result.Add(item);
         return null;
     }));
     return result;
 }
开发者ID:Hank923,项目名称:ironruby,代码行数:13,代码来源:Enumerable.cs

示例5: Contains

        public static object Contains(CallSiteStorage<EachSite>/*!*/ each, BinaryOpStorage/*!*/ equals, object self, object value)
        {
            object result = ScriptingRuntimeHelpers.BooleanToObject(false);

            Each(each, self, Proc.Create(each.Context, delegate(BlockParam/*!*/ selfBlock, object _, object item) {
                if (Protocols.IsEqual(equals, item, value)) {
                    result = ScriptingRuntimeHelpers.BooleanToObject(true);
                    return selfBlock.Break(result);
                }
                return null;
            }));

            return result;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:14,代码来源:Enumerable.cs

示例6: Include

        public static RubyModule/*!*/ Include(
            CallSiteStorage<Func<CallSite, RubyModule, RubyModule, object>>/*!*/ appendFeaturesStorage,
            CallSiteStorage<Func<CallSite, RubyModule, RubyModule, object>>/*!*/ includedStorage,
            RubyModule/*!*/ self, [NotNullItems]params RubyModule/*!*/[]/*!*/ modules) {

            RubyUtils.RequireMixins(self, modules);

            var appendFeatures = appendFeaturesStorage.GetCallSite("append_features", 1);
            var included = includedStorage.GetCallSite("included", 1);

            // Kernel#append_features inserts the module at the beginning of ancestors list;
            // ancestors after include: [modules[0], modules[1], ..., modules[N-1], self, ...]
            for (int i = modules.Length - 1; i >= 0; i--) {
                appendFeatures.Target(appendFeatures, modules[i], self);
                included.Target(included, modules[i], self);
            }

            return self;
        }
开发者ID:yarrow2,项目名称:ironruby,代码行数:19,代码来源:ModuleOps.cs

示例7: TrueForItems

        private static object TrueForItems(CallSiteStorage<EachSite>/*!*/ each, BlockParam predicate, object self, bool expected) {
            bool result = expected;
            Each(each, self, Proc.Create(each.Context, delegate(BlockParam/*!*/ selfBlock, object _, object item) {
                if (predicate != null) {
                    if (predicate.Yield(item, out item)) {
                        return item;
                    }
                }

                bool isTrue = Protocols.IsTrue(item);
                if (isTrue != result) {
                    result = isTrue;
                    return selfBlock.Break(ScriptingRuntimeHelpers.BooleanToObject(isTrue));
                }

                return null;
            }));

            return ScriptingRuntimeHelpers.BooleanToObject(result);
        }
开发者ID:Hank923,项目名称:ironruby,代码行数:20,代码来源:Enumerable.cs

示例8: TrueForItems

        private static object TrueForItems(CallSiteStorage<EachSite>/*!*/ each, BlockParam predicate, object self, bool stop, bool positiveResult) {
            object result = ScriptingRuntimeHelpers.BooleanToObject(!positiveResult);
            Each(each, self, Proc.Create(each.Context, delegate(BlockParam/*!*/ selfBlock, object _, object item) {
                if (predicate != null) {
                    object blockResult;
                    if (predicate.Yield(item, out blockResult)) {
                        result = blockResult;
                        return selfBlock.PropagateFlow(predicate, blockResult);
                    }
                    item = blockResult;
                }

                bool isTrue = Protocols.IsTrue(item);
                if (isTrue == stop) {
                    result = ScriptingRuntimeHelpers.BooleanToObject(positiveResult); 
                    return selfBlock.Break(result);
                }

                return null;
            }));

            return result;
        }
开发者ID:rafacv,项目名称:iron_languages,代码行数:23,代码来源:Enumerable.cs

示例9: Sort

        public static object Sort(
            CallSiteStorage<EachSite>/*!*/ each, 
            BinaryOpStorage/*!*/ comparisonStorage,
            BinaryOpStorage/*!*/ lessThanStorage,
            BinaryOpStorage/*!*/ greaterThanStorage,
            BlockParam keySelector, object self) {

            return ArrayOps.SortInPlace(comparisonStorage, lessThanStorage, greaterThanStorage, keySelector, ToArray(each, self));
        }
开发者ID:Hank923,项目名称:ironruby,代码行数:9,代码来源:Enumerable.cs

示例10: Partition

        public static RubyArray/*!*/ Partition(CallSiteStorage<EachSite>/*!*/ each, BlockParam predicate, object self) {
            RubyArray trueSet = new RubyArray();
            RubyArray falseSet = new RubyArray();

            Each(each, self, Proc.Create(each.Context, delegate(BlockParam/*!*/ selfBlock, object _, object item) {
                if (predicate == null) {
                    throw RubyExceptions.NoBlockGiven();
                }

                object blockResult;
                if (predicate.Yield(item, out blockResult)) {
                    return blockResult;
                }

                if (Protocols.IsTrue(blockResult)) {
                    trueSet.Add(item);
                } else {
                    falseSet.Add(item);
                }

                return null;
            }));

            RubyArray pair = new RubyArray(2);
            pair.Add(trueSet);
            pair.Add(falseSet);
            return pair;
        }
开发者ID:Hank923,项目名称:ironruby,代码行数:28,代码来源:Enumerable.cs

示例11: Each

 internal static object Each(CallSiteStorage<EachSite>/*!*/ each, object self, Proc/*!*/ block) {
     var site = each.GetCallSite("each", new RubyCallSignature(0, RubyCallFlags.HasImplicitSelf | RubyCallFlags.HasBlock));
     return site.Target(site, self, block);
 }
开发者ID:Hank923,项目名称:ironruby,代码行数:4,代码来源:Enumerable.cs

示例12: GetExtreme

        private static object GetExtreme(
            CallSiteStorage<EachSite>/*!*/ each, 
            BinaryOpStorage/*!*/ compareStorage,
            BinaryOpStorage/*!*/ lessThanStorage,
            BinaryOpStorage/*!*/ greaterThanStorage,
            BlockParam comparer, object self, int comparisonValue) {

            bool firstItem = true;
            object result = null;

            Each(each, self, Proc.Create(each.Context, delegate(BlockParam/*!*/ selfBlock, object _, object item) {
                // Check for first element
                if (firstItem) {
                    result = item;
                    firstItem = false;
                    return null;
                }

                int compareResult;
                if (comparer != null) {
                    object blockResult;
                    if (comparer.Yield(result, item, out blockResult)) {
                        return blockResult;
                    }

                    if (blockResult == null) {
                        throw RubyExceptions.MakeComparisonError(selfBlock.RubyContext, result, item);
                    }

                    compareResult = Protocols.ConvertCompareResult(lessThanStorage, greaterThanStorage, blockResult);
                } else {
                    compareResult = Protocols.Compare(compareStorage, lessThanStorage, greaterThanStorage, result, item);
                }

                // Check if we have found the new minimum or maximum (-1 to select max, 1 to select min)
                if (compareResult == comparisonValue) {
                    result = item;
                }

                return null;
            }));
            return result;
        }
开发者ID:Hank923,项目名称:ironruby,代码行数:43,代码来源:Enumerable.cs

示例13: GetMinimum

 public static object GetMinimum(
     CallSiteStorage<EachSite>/*!*/ each, 
     BinaryOpStorage/*!*/ compareStorage,
     BinaryOpStorage/*!*/ lessThanStorage,
     BinaryOpStorage/*!*/ greaterThanStorage,
     BlockParam comparer, object self) {
     return GetExtreme(each, compareStorage, lessThanStorage, greaterThanStorage, comparer, self, 1/*look for min*/);
 }
开发者ID:Hank923,项目名称:ironruby,代码行数:8,代码来源:Enumerable.cs

示例14: EachCons

 public static object EachCons(CallSiteStorage<EachSite>/*!*/ each, RubyContext/*!*/ context, BlockParam/*!*/ block, object self, [DefaultProtocol]int sliceSize) {
     return EachSlice(each, context, block, self, sliceSize, false, (slice) => {
         RubyArray newSlice = new RubyArray(slice.Count);
         for (int i = 1; i < slice.Count; i++) {
             newSlice.Add(slice[i]);
         }
         return newSlice;
     });
 }
开发者ID:tnachen,项目名称:ironruby,代码行数:9,代码来源:Enumerator.cs

示例15: Zip

        public static RubyArray/*!*/ Zip(CallSiteStorage<EachSite>/*!*/ each, ConversionStorage<IList>/*!*/ tryToA, BlockParam block,
            object self, [NotNull]params object[] args) {
            RubyArray results = (block == null) ? new RubyArray() : null;

            // Call to_a on each argument
            IList[] otherArrays = new IList[args.Length];
            for (int i = 0; i < args.Length; i++) {
                otherArrays[i] = Protocols.TryConvertToArray(tryToA, args[i]);
            }

            int index = 0;
            Each(each, self, Proc.Create(each.Context, delegate(BlockParam/*!*/ selfBlock, object _, object item) {
                // Collect items
                RubyArray array = new RubyArray(otherArrays.Length + 1);
                array.Add(item);
                foreach (IList otherArray in otherArrays) {
                    if (index < otherArray.Count) {
                        array.Add(otherArray[index]);
                    } else {
                        array.Add(null);
                    }
                }

                index += 1;

                if (block != null) {
                    object blockResult;
                    if (block.Yield(array, out blockResult)) {
                        return blockResult;
                    }
                } else {
                    results.Add(array);
                }
                return null;
            }));

            return results;
        }
开发者ID:Hank923,项目名称:ironruby,代码行数:38,代码来源:Enumerable.cs


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