本文整理汇总了C#中IronRuby.Runtime.Calls.CallArguments类的典型用法代码示例。如果您正苦于以下问题:C# CallArguments类的具体用法?C# CallArguments怎么用?C# CallArguments使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CallArguments类属于IronRuby.Runtime.Calls命名空间,在下文中一共展示了CallArguments类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildCallNoFlow
internal override void BuildCallNoFlow(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ name) {
metaBuilder.Result = Methods.GetInstanceVariable.OpCall(
args.ScopeExpression,
AstFactory.Box(args.TargetExpression),
AstUtils.Constant(InstanceVariableName)
);
}
示例2: Build
protected override bool Build(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, bool defaultFallback) {
if (TryImplicitConversion(metaBuilder, args)) {
metaBuilder.AddObjectTypeRestriction(args.Target, args.TargetExpression);
return true;
}
// TODO: this is our meta object, should we add IRubyMetaConvertible interface instead of using interop-binder?
if (args.Target is IDynamicMetaObjectProvider) {
metaBuilder.SetMetaResult(args.MetaTarget.BindConvert(new InteropBinder.Convert(args.RubyContext, _type, true)), false);
return true;
}
if (defaultFallback) {
metaBuilder.AddObjectTypeRestriction(args.Target, args.TargetExpression);
metaBuilder.SetError(Methods.MakeTypeConversionError.OpCall(
args.MetaContext.Expression,
AstUtils.Convert(args.TargetExpression, typeof(object)),
Ast.Constant(_type)
));
return true;
}
return false;
}
示例3: BuildCallNoFlow
internal override void BuildCallNoFlow(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ name) {
Expression instance = _fieldInfo.IsStatic ? null : Ast.Convert(args.TargetExpression, _fieldInfo.DeclaringType);
if (_isSetter) {
var actualArgs = RubyOverloadResolver.NormalizeArguments(metaBuilder, args, 1, 1);
if (!metaBuilder.Error) {
metaBuilder.Result = Ast.Assign(
Ast.Field(instance, _fieldInfo),
Converter.ConvertExpression(
actualArgs[0].Expression,
_fieldInfo.FieldType,
args.RubyContext,
args.MetaContext.Expression,
true
)
);
}
} else {
RubyOverloadResolver.NormalizeArguments(metaBuilder, args, 0, 0);
if (!metaBuilder.Error) {
if (_fieldInfo.IsLiteral) {
// TODO: seems like Compiler should correctly handle the literal field case
// (if you emit a read to a literal field, you get a NotSupportedExpception from
// FieldHandle when we try to emit)
metaBuilder.Result = AstUtils.Constant(_fieldInfo.GetValue(null));
} else {
metaBuilder.Result = Ast.Field(instance, _fieldInfo);
}
}
}
}
示例4: InteropBind
private DynamicMetaObject/*!*/ InteropBind(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args) {
// TODO: argument count limit depends on the binder!
// TODO: pass block as the last (before RHS arg?) parameter/ignore block if args not accepting block:
var normalizedArgs = RubyOverloadResolver.NormalizeArguments(metaBuilder, args, 0, Int32.MaxValue);
if (!metaBuilder.Error) {
MethodInfo postConverter;
var interopBinder = GetInteropBinder(args.RubyContext, normalizedArgs, out postConverter);
if (interopBinder != null) {
Type resultType;
var result = interopBinder.Bind(args.MetaTarget, ArrayUtils.MakeArray(normalizedArgs));
metaBuilder.SetMetaResult(result, args);
if (postConverter != null) {
// TODO: do better?
var paramType = postConverter.GetParameters()[0].ParameterType;
metaBuilder.Result = Ast.Call(null, postConverter, AstUtils.Convert(metaBuilder.Result, paramType));
resultType = postConverter.ReturnType;
} else {
resultType = ((IInteropBinder)interopBinder).ResultType;
}
return metaBuilder.CreateMetaObject(interopBinder, resultType);
} else {
metaBuilder.SetError(Ast.New(
typeof(NotSupportedException).GetConstructor(new[] { typeof(string) }),
Ast.Constant(String.Format("{0} not supported on foreign meta-objects", this))
));
}
}
return metaBuilder.CreateMetaObject(this);
}
示例5: BuildCallNoFlow
internal override void BuildCallNoFlow(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ name) {
Proc.BuildCall(
metaBuilder,
AstUtils.Constant(_lambda), // proc object
args.TargetExpression, // self
args
);
}
示例6: RubyOverloadResolver
internal RubyOverloadResolver(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, SelfCallConvention callConvention,
bool implicitProtocolConversions)
: base(args.RubyContext.Binder) {
_args = args;
_metaBuilder = metaBuilder;
_callConvention = callConvention;
_implicitProtocolConversions = implicitProtocolConversions;
}
示例7: Build
protected override bool Build(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, bool defaultFallback) {
// TODO: this is our meta object, should we add IRubyMetaConvertible interface instead of using interop-binder?
if (args.Target is IDynamicMetaObjectProvider) {
metaBuilder.SetMetaResult(args.MetaTarget.BindConvert(new InteropBinder.Convert(args.RubyContext, _type, true)), false);
return true;
}
return BuildConversion(metaBuilder, args.MetaTarget, args.MetaContext.Expression, _type, defaultFallback);
}
示例8: BuildCallNoFlow
internal override void BuildCallNoFlow(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ name) {
RubyOverloadResolver.NormalizeArguments(metaBuilder, args, 0, 0);
if (!metaBuilder.Error) {
metaBuilder.Result = Methods.GetInstanceVariable.OpCall(
AstUtils.Convert(args.MetaScope.Expression, typeof(RubyScope)),
AstUtils.Box(args.TargetExpression),
AstUtils.Constant(InstanceVariableName)
);
}
}
示例9: BuildCallNoFlow
internal override void BuildCallNoFlow(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ name) {
var visibleOverloads = GetVisibleOverloads(args, MethodBases, false);
if (visibleOverloads.Count == 0) {
metaBuilder.SetError(Methods.MakeClrProtectedMethodCalledError.OpCall(
args.MetaContext.Expression, args.MetaTarget.Expression, Ast.Constant(name)
));
} else {
BuildCallNoFlow(metaBuilder, args, name, visibleOverloads, CallConvention, ImplicitProtocolConversions);
}
}
示例10: Build
protected override bool Build(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, bool defaultFallback) {
RubyModule currentDeclaringModule;
string currentMethodName;
var scope = args.Scope;
object target;
scope.GetSuperCallTarget(out currentDeclaringModule, out currentMethodName, out target);
var targetExpression = metaBuilder.GetTemporary(typeof(object), "#super-self");
metaBuilder.AddCondition(
Methods.IsSuperCallTarget.OpCall(
AstUtils.Convert(args.MetaScope.Expression, typeof(RubyScope)),
AstUtils.Constant(currentDeclaringModule),
AstUtils.Constant(currentMethodName),
targetExpression
)
);
args.SetTarget(targetExpression, target);
Debug.Assert(currentDeclaringModule != null);
RubyMemberInfo method;
RubyMemberInfo methodMissing = null;
// we need to lock the hierarchy of the target class:
var targetClass = scope.RubyContext.GetImmediateClassOf(target);
using (targetClass.Context.ClassHierarchyLocker()) {
// initialize all methods in ancestors:
targetClass.InitializeMethodsNoLock();
// target is stored in a local, therefore it cannot be part of the restrictions:
metaBuilder.TreatRestrictionsAsConditions = true;
metaBuilder.AddTargetTypeTest(target, targetClass, targetExpression, args.MetaContext,
new[] { Symbols.MethodMissing } // currentMethodName is resolved for super, which cannot be an instance singleton
);
metaBuilder.TreatRestrictionsAsConditions = false;
method = targetClass.ResolveSuperMethodNoLock(currentMethodName, currentDeclaringModule).InvalidateSitesOnOverride().Info;
if (method == null) {
// MRI: method_missing is called for the targetClass, not for the super:
methodMissing = targetClass.ResolveMethodMissingForSite(currentMethodName, RubyMethodVisibility.None);
}
}
if (method != null) {
method.BuildSuperCall(metaBuilder, args, currentMethodName, currentDeclaringModule);
} else {
return RubyCallAction.BuildMethodMissingCall(metaBuilder, args, currentMethodName, methodMissing, RubyMethodVisibility.None, true, defaultFallback);
}
return true;
}
示例11: BuildCallNoFlow
internal override void BuildCallNoFlow(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ name) {
Debug.Assert(!args.Signature.HasBlock);
Proc.SetProcCallRule(
metaBuilder,
Ast.Constant(_lambda), // proc object
args.TargetExpression, // self
Ast.Constant(this), // this method for super and class_eval
args
);
}
示例12: Bind
public override DynamicMetaObject/*!*/ Bind(DynamicMetaObject/*!*/ scopeOrContextOrTarget, DynamicMetaObject/*!*/[]/*!*/ args) {
var callArgs = new CallArguments(_context, scopeOrContextOrTarget, args, Signature);
var metaBuilder = new MetaObjectBuilder(this, args);
if (IsForeignMetaObject(callArgs.MetaTarget)) {
return InteropBind(metaBuilder, callArgs);
}
Build(metaBuilder, callArgs, true);
return metaBuilder.CreateMetaObject(this);
}
示例13: 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);
}
}
示例14: BuildCallNoFlow
internal override void BuildCallNoFlow(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ name) {
if (args.Signature.HasBlock) {
metaBuilder.Result = Methods.HookupEvent.OpCall(
Ast.Convert(Ast.Constant(_eventInfo), typeof(EventInfo)),
args.TargetExpression,
Ast.Convert(args.GetBlockExpression(), typeof(Proc))
);
} else {
// TODO: make error
throw new NotImplementedError("no block given");
}
}
示例15: Bind
public override DynamicMetaObject/*!*/ Bind(DynamicMetaObject/*!*/ context, DynamicMetaObject/*!*/[]/*!*/ args) {
var callArgs = new CallArguments(context, args, Signature);
// TODO: COM interop
if (IsForeignMetaObject(callArgs.MetaTarget)) {
return InteropBind(callArgs);
}
var metaBuilder = new MetaObjectBuilder();
Build(metaBuilder, callArgs);
return metaBuilder.CreateMetaObject(this);
}