本文整理汇总了C#中IronRuby.Runtime.Calls.MetaObjectBuilder.SetWrongNumberOfArgumentsError方法的典型用法代码示例。如果您正苦于以下问题:C# MetaObjectBuilder.SetWrongNumberOfArgumentsError方法的具体用法?C# MetaObjectBuilder.SetWrongNumberOfArgumentsError怎么用?C# MetaObjectBuilder.SetWrongNumberOfArgumentsError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IronRuby.Runtime.Calls.MetaObjectBuilder
的用法示例。
在下文中一共展示了MetaObjectBuilder.SetWrongNumberOfArgumentsError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildCallNoFlow
internal override void BuildCallNoFlow(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ name) {
var actualArgs = RubyMethodGroupInfo.NormalizeArguments(metaBuilder, args, SelfCallConvention.NoSelf, false, false);
if (actualArgs.Length == 0) {
metaBuilder.Result = Methods.GetInstanceVariable.OpCall(
args.ScopeExpression,
AstFactory.Box(args.TargetExpression),
AstUtils.Constant(InstanceVariableName)
);
} else {
metaBuilder.SetWrongNumberOfArgumentsError(actualArgs.Length, 0);
}
}
示例2: AddCallArguments
public void AddCallArguments(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args) {
// simple args:
for (int i = 0; i < args.SimpleArgumentCount; i++) {
Add(args.GetSimpleArgumentExpression(i));
}
// splat arg:
if (args.Signature.HasSplattedArgument) {
AddSplatted(metaBuilder, args);
}
// rhs arg:
if (args.Signature.HasRhsArgument) {
Add(args.GetRhsArgumentExpression());
}
if (HasTooFewArguments) {
metaBuilder.SetWrongNumberOfArgumentsError(_explicitArgCount, _mandatoryParamCount);
return;
}
if (HasTooManyArguments) {
metaBuilder.SetWrongNumberOfArgumentsError(_explicitArgCount, _mandatoryParamCount);
return;
}
// add optional placeholders:
FillMissingArguments();
if (_hasUnsplatParameter) {
AddUnsplat();
}
}
示例3: NormalizeArguments
public static IList<DynamicMetaObject/*!*/> NormalizeArguments(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, int minCount, int maxCount) {
int lastSplattedArg;
IList list;
ParameterExpression listVariable;
// 2 hidden arguments: block and self
var actualArgs = CreateActualArguments(new List<DynamicMetaObject>(), metaBuilder, args, 2, maxCount, maxCount,
out lastSplattedArg, out list, out listVariable);
int actualCount = actualArgs.Count + actualArgs.CollapsedCount;
if (actualCount < minCount) {
metaBuilder.SetWrongNumberOfArgumentsError(actualCount, minCount);
return null;
} else if (actualCount > maxCount) {
metaBuilder.SetWrongNumberOfArgumentsError(actualCount, maxCount);
return null;
}
// any collapsed args are out of limits:
return actualArgs.Arguments;
}
示例4: AddCallArguments
public void AddCallArguments(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args) {
_callArguments = args;
// calculate actual argument count:
_actualArgumentCount = args.SimpleArgumentCount;
if (args.Signature.HasSplattedArgument) {
var splattedArg = args.GetSplattedMetaArgument();
metaBuilder.AddSplattedArgumentTest((IList)splattedArg.Value, splattedArg.Expression, out _listLength, out _listVariable);
_actualArgumentCount += _listLength;
}
if (args.Signature.HasRhsArgument) {
_actualArgumentCount++;
}
// check:
if (HasTooFewArguments) {
metaBuilder.SetWrongNumberOfArgumentsError(_actualArgumentCount, _mandatoryParamCount);
return;
}
if (HasTooManyArguments) {
metaBuilder.SetWrongNumberOfArgumentsError(_actualArgumentCount, _mandatoryParamCount);
return;
}
bool isSplatted;
// leading mandatory:
for (int i = 0; i < _leadingMandatoryParamCount; i++) {
_arguments[LeadingMandatoryIndex + i] = GetArgument(i, out isSplatted);
}
// trailing mandatory:
for (int i = 0; i < TrailingMandatoryCount; i++) {
_arguments[TrailingMandatoryIndex + i] = GetArgument(_actualArgumentCount - TrailingMandatoryCount + i, out isSplatted);
}
int start = _leadingMandatoryParamCount;
int end = _actualArgumentCount - TrailingMandatoryCount;
// optional:
for (int i = 0; i < _optionalParamCount; i++) {
_arguments[OptionalParameterIndex + i] = (start < end) ? GetArgument(start++, out isSplatted) : Ast.Field(null, Fields.DefaultArgument);
}
// unsplat:
if (_hasUnsplatParameter) {
Expression array;
if (args.Signature.HasSplattedArgument) {
// simple:
var argsToUnsplat = new List<Expression>();
while (start < end) {
var arg = GetArgument(start, out isSplatted);
if (isSplatted) {
break;
}
argsToUnsplat.Add(AstUtils.Box(arg));
start++;
}
array = Methods.MakeArrayOpCall(argsToUnsplat);
int rangeStart = start - args.SimpleArgumentCount;
int rangeLength = Math.Min(end - start, _listLength - rangeStart);
// splatted:
if (rangeLength > 0) {
array = Methods.AddSubRange.OpCall(array, _listVariable, Ast.Constant(rangeStart), Ast.Constant(rangeLength));
start += rangeLength;
}
// rhs:
while (start < end) {
array = Methods.AddItem.OpCall(array, AstUtils.Box(GetArgument(start, out isSplatted)));
start++;
}
} else {
var argsToUnsplat = new List<Expression>(end - start);
while (start < end) {
argsToUnsplat.Add(AstUtils.Box(GetArgument(start++, out isSplatted)));
}
array = Methods.MakeArrayOpCall(argsToUnsplat);
}
_arguments[UnsplatParameterIndex] = array;
}
_callArguments = null;
_listVariable = null;
Debug.Assert(CollectionUtils.TrueForAll(_arguments, (e) => e != null));
}