本文整理汇总了C#中UnaryOpStorage.GetCallSite方法的典型用法代码示例。如果您正苦于以下问题:C# UnaryOpStorage.GetCallSite方法的具体用法?C# UnaryOpStorage.GetCallSite怎么用?C# UnaryOpStorage.GetCallSite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnaryOpStorage
的用法示例。
在下文中一共展示了UnaryOpStorage.GetCallSite方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Abs
public static object Abs(BinaryOpStorage/*!*/ lessThanStorage, UnaryOpStorage/*!*/ minusStorage, object self)
{
var lessThan = lessThanStorage.GetCallSite("<");
if (RubyOps.IsTrue(lessThan.Target(lessThan, self, 0))) {
var minus = minusStorage.GetCallSite("[email protected]");
return minus.Target(minus, self);
}
return self;
}
示例2: GetHashCode
public static int GetHashCode(UnaryOpStorage/*!*/ hashStorage, Range/*!*/ self) {
// MRI: Ruby treatment of hash return value is inconsistent.
// No conversions happen here (unlike e.g. Array.hash).
var hashSite = hashStorage.GetCallSite("hash");
return unchecked(
Protocols.ToHashCode(hashSite.Target(hashSite, self.Begin)) ^
Protocols.ToHashCode(hashSite.Target(hashSite, self.End)) ^
(self.ExcludeEnd ? 179425693 : 1794210891)
);
}
示例3: ToYamlNode
public static Node ToYamlNode(UnaryOpStorage/*!*/ messageStorage, Exception/*!*/ self, [NotNull]RubyRepresenter/*!*/ rep)
{
var site = messageStorage.GetCallSite("message", 0);
var map = new Dictionary<object, object>();
rep.AddYamlProperties(map, self, false);
return rep.Map(
new Dictionary<Node, Node> {
{ rep.Scalar(null, "message", ScalarQuotingStyle.None), rep.RepresentItem(site.Target(site, self)) }
},
rep.GetTagUri(self),
map,
FlowStyle.Block
);
}
示例4: ToInt
public static object ToInt(UnaryOpStorage/*!*/ toiStorage, RubyContext/*!*/ context, object self) {
var site = toiStorage.GetCallSite("to_i");
return site.Target(site, context, self);
}
示例5: ToYaml
public static Node/*!*/ ToYaml(UnaryOpStorage/*!*/ beginStorage, UnaryOpStorage/*!*/ endStorage, UnaryOpStorage/*!*/ exclStorage,
Range/*!*/ self, [NotNull]RubyRepresenter/*!*/ rep) {
var begin = beginStorage.GetCallSite("begin");
var end = endStorage.GetCallSite("end");
var map = new Dictionary<MutableString, object>() {
{ MutableString.Create("begin"), begin.Target(begin, rep.Context, self) },
{ MutableString.Create("end"), end.Target(end, rep.Context, self) },
{ MutableString.Create("excl"), self.ExcludeEnd },
};
rep.AddYamlProperties(self, map);
return rep.Map(self, map);
}
示例6: IsBinaryData
public static object IsBinaryData(UnaryOpStorage/*!*/ isEmptyStorage, RubyContext/*!*/ context, MutableString/*!*/ self) {
var site = isEmptyStorage.GetCallSite("empty?");
if (RubyOps.IsTrue(site.Target(site, context, self))) {
return null;
}
return ScriptingRuntimeHelpers.BooleanToObject((self.IsBinary ? self.IndexOf(0) : self.IndexOf('\0')) >= 0);
}
示例7: CreateExceptionToRaise
internal static Exception/*!*/ CreateExceptionToRaise(RespondToStorage/*!*/ respondToStorage, UnaryOpStorage/*!*/ storage0, BinaryOpStorage/*!*/ storage1,
CallSiteStorage<Action<CallSite, Exception, RubyArray>>/*!*/ setBackTraceStorage,
object/*!*/ obj, object arg, RubyArray backtrace) {
if (Protocols.RespondTo(respondToStorage, obj, "exception")) {
Exception e = null;
if (arg != Missing.Value) {
var site = storage1.GetCallSite("exception");
e = site.Target(site, obj, arg) as Exception;
} else {
var site = storage0.GetCallSite("exception");
e = site.Target(site, obj) as Exception;
}
if (e != null) {
if (backtrace != null) {
var site = setBackTraceStorage.GetCallSite("set_backtrace", 1);
site.Target(site, e, backtrace);
}
return e;
}
}
throw RubyExceptions.CreateTypeError("exception class/object expected");
}
示例8: PrintInspect
public static void PrintInspect(BinaryOpStorage/*!*/ writeStorage, UnaryOpStorage/*!*/ inspectStorage, ConversionStorage<MutableString>/*!*/ tosConversion,
object self, [NotNull]params object[]/*!*/ args) {
var inspect = inspectStorage.GetCallSite("inspect");
var inspectedArgs = new object[args.Length];
for (int i = 0; i < args.Length; i++) {
inspectedArgs[i] = inspect.Target(inspect, args[i]);
}
// no dynamic dispatch to "puts":
RubyIOOps.Puts(writeStorage, tosConversion, writeStorage.Context.StandardOutput, inspectedArgs);
}
示例9: Flush
public void Flush(UnaryOpStorage/*!*/ flushStorage, RubyContext/*!*/ context) {
Flush();
if (_canFlush) {
var site = flushStorage.GetCallSite("flush");
site.Target(site, _obj);
}
}
示例10: Reopen
public static StringIO/*!*/ Reopen(RespondToStorage/*!*/ respondToStorage, UnaryOpStorage/*!*/ toStringIoStorage,
StringIO/*!*/ self, [NotNull]object/*!*/ other) {
if (!Protocols.RespondTo(respondToStorage, other, "to_strio")) {
throw RubyExceptions.CreateTypeConversionError(respondToStorage.Context.GetClassName(other), "StringIO");
}
var site = toStringIoStorage.GetCallSite("to_strio", 0);
var strio = site.Target(site, other) as StringIO;
if (strio == null) {
throw RubyExceptions.CreateTypeError("C#to_strio should return StringIO");
}
return Reopen(respondToStorage.Context, self, strio);
}
示例11: CreateExceptionToRaise
internal static Exception CreateExceptionToRaise(RespondToStorage/*!*/ respondToStorage, UnaryOpStorage/*!*/ storage0, BinaryOpStorage/*!*/ storage1, SetBacktraceStorage/*!*/ setBackTraceStorage,
RubyContext/*!*/ context, object/*!*/ obj, object arg, RubyArray backtrace) {
if (Protocols.RespondTo(respondToStorage, context, obj, "exception")) {
Exception e = null;
if (arg != Missing.Value) {
var site = storage1.GetCallSite("exception");
e = site.Target(site, context, obj, arg) as Exception;
} else {
var site = storage0.GetCallSite("exception");
e = site.Target(site, context, obj) as Exception;
}
if (e != null) {
if (backtrace != null) {
RubyExceptionData.GetInstance(e).SetBacktrace(setBackTraceStorage.GetCallSite(), context, backtrace);
}
return e;
}
}
throw RubyExceptions.CreateTypeError("exception class/object expected");
}
示例12: PrintInspect
public static void PrintInspect(BinaryOpStorage/*!*/ writeStorage, UnaryOpStorage/*!*/ inspectStorage, UnaryOpStorage/*!*/ tosStorage,
RubyContext/*!*/ context, object self, [NotNull]params object[]/*!*/ args) {
var inspect = inspectStorage.GetCallSite("inspect");
for (int i = 0; i < args.Length; i++) {
args[i] = inspect.Target(inspect, context, args[i]);
}
// no dynamic dispatch to "puts":
RubyIOOps.Puts(writeStorage, tosStorage, context, context.StandardOutput, args);
}
示例13: GetMessage
public static object GetMessage(UnaryOpStorage/*!*/ stringReprStorage, Exception/*!*/ self) {
var site = stringReprStorage.GetCallSite("to_s");
return site.Target(site, self);
}
示例14: ToYaml
public static Node ToYaml(UnaryOpStorage/*!*/ beginStorage, UnaryOpStorage/*!*/ endStorage, UnaryOpStorage/*!*/ exclStorage,
Range/*!*/ self, [NotNull]RubyRepresenter/*!*/ rep)
{
var begin = beginStorage.GetCallSite("begin");
var end = endStorage.GetCallSite("end");
var map = new Dictionary<object, object>();
rep.AddYamlProperties(map, self, false);
return rep.Map(
new Dictionary<Node, Node> {
{ rep.Scalar(null, "begin", ScalarQuotingStyle.None), rep.RepresentItem(begin.Target(begin, self)) },
{ rep.Scalar(null, "end", ScalarQuotingStyle.None), rep.RepresentItem(end.Target(end, self)) },
{ rep.Scalar(null, "excl", ScalarQuotingStyle.None), rep.Scalar(self.ExcludeEnd) },
},
rep.GetTagUri(self),
map,
FlowStyle.Block
);
}
示例15: StepString
/// <summary>
/// Step through a Range of Strings.
/// </summary>
/// <remarks>
/// This method requires step to be a Fixnum.
/// It uses a hybrid string comparison to prevent infinite loops and calls String#succ to get each item in the range.
/// </remarks>
private static object StepString(
ConversionStorage<MutableString>/*!*/ stringCast,
BinaryOpStorage/*!*/ comparisonStorage,
BinaryOpStorage/*!*/ lessThanStorage,
BinaryOpStorage/*!*/ greaterThanStorage,
UnaryOpStorage/*!*/ succStorage,
BlockParam block, Range/*!*/ self, MutableString begin, MutableString end, int step) {
CheckStep(step);
object result;
MutableString item = begin;
int comp;
var succSite = succStorage.GetCallSite("succ");
while ((comp = Protocols.Compare(comparisonStorage, lessThanStorage, greaterThanStorage, item, end)) < 0) {
if (block == null) {
throw RubyExceptions.NoBlockGiven();
}
if (block.Yield(item, out result)) {
return result;
}
for (int i = 0; i < step; i++) {
item = Protocols.CastToString(stringCast, succSite.Target(succSite, item));
}
if (item.Length > end.Length) {
return self;
}
}
if (comp == 0 && !self.ExcludeEnd) {
if (block == null) {
throw RubyExceptions.NoBlockGiven();
}
if (block.Yield(item, out result)) {
return result;
}
}
return self;
}