本文整理汇总了C#中ArgumentValues类的典型用法代码示例。如果您正苦于以下问题:C# ArgumentValues类的具体用法?C# ArgumentValues怎么用?C# ArgumentValues使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArgumentValues类属于命名空间,在下文中一共展示了ArgumentValues类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SlotInitAdapter
public SlotInitAdapter(PythonTypeSlot/*!*/ slot, ArgumentValues/*!*/ ai, PythonContext/*!*/ state, Expression/*!*/ codeContext)
: base(ai, state, codeContext) {
_slot = slot;
}
示例2: BuiltinInitAdapter
public BuiltinInitAdapter(ArgumentValues/*!*/ ai, BuiltinFunction/*!*/ method, PythonContext/*!*/ state, Expression/*!*/ codeContext)
: base(ai, state, codeContext) {
_method = method;
}
示例3: ConstructorNewAdapter
public ConstructorNewAdapter(ArgumentValues/*!*/ ai, PythonType/*!*/ creating, PythonContext/*!*/ state, Expression/*!*/ codeContext)
: base(ai, state, codeContext) {
_creating = creating;
}
示例4: BuiltinNewAdapter
public BuiltinNewAdapter(ArgumentValues/*!*/ ai, PythonType/*!*/ creating, BuiltinFunction/*!*/ ctor, PythonContext/*!*/ state, Expression/*!*/ codeContext)
: base(ai, state, codeContext) {
_creating = creating;
_ctor = ctor;
}
示例5: GetErrorRestrictions
private BindingRestrictions/*!*/ GetErrorRestrictions(ArgumentValues/*!*/ ai) {
BindingRestrictions res = Restrict(this.GetRuntimeType()).Restrictions;
res = res.Merge(GetInstanceRestriction(ai));
foreach (DynamicMetaObject mo in ai.Arguments) {
if (mo.HasValue) {
res = res.Merge(mo.Restrict(mo.GetRuntimeType()).Restrictions);
}
}
return res;
}
示例6: DefaultNewAdapter
public DefaultNewAdapter(ArgumentValues/*!*/ ai, PythonType/*!*/ creating, BinderState/*!*/ state, Expression/*!*/ codeContext)
: base(ai, state, codeContext) {
_creating = creating;
}
示例7: GetAdapters
private void GetAdapters(ArgumentValues/*!*/ ai, DynamicMetaObjectBinder/*!*/ call, Expression/*!*/ codeContext, out NewAdapter/*!*/ newAdapter, out InitAdapter/*!*/ initAdapter) {
PythonTypeSlot newInst, init;
Value.TryResolveSlot(PythonContext.GetPythonContext(call).SharedContext, "__new__", out newInst);
Value.TryResolveSlot(PythonContext.GetPythonContext(call).SharedContext, "__init__", out init);
// these are never null because we always resolve to __new__ or __init__ somewhere.
Assert.NotNull(newInst, init);
newAdapter = GetNewAdapter(ai, newInst, call, codeContext);
initAdapter = GetInitAdapter(ai, init, call, codeContext);
}
示例8: MakeGenericTypeDefinitionError
private DynamicMetaObject/*!*/ MakeGenericTypeDefinitionError(DynamicMetaObjectBinder/*!*/ call, ArgumentValues/*!*/ ai, ValidationInfo/*!*/ valInfo) {
Debug.Assert(Value.IsSystemType);
string message = "cannot create instances of " + Value.Name + " because it is a generic type definition";
return BindingHelpers.AddDynamicTestAndDefer(
call,
new DynamicMetaObject(
call.Throw(
Ast.New(
typeof(TypeErrorException).GetConstructor(new Type[] { typeof(string) }),
AstUtils.Constant(message)
),
typeof(object)
),
GetErrorRestrictions(ai)
),
ai.Arguments,
valInfo
);
}
示例9: CallAdapter
public CallAdapter(ArgumentValues/*!*/ ai, PythonContext/*!*/ state, Expression/*!*/ codeContext) {
_argInfo = ai;
_state = state;
_restrictions = BindingRestrictions.Empty;
_context = codeContext;
}
示例10: MakePythonTypeCall
/// <summary>
/// Creating a Python type involves calling __new__ and __init__. We resolve them
/// and generate calls to either the builtin funcions directly or embed sites which
/// call the slots at runtime.
/// </summary>
private DynamicMetaObject/*!*/ MakePythonTypeCall(DynamicMetaObjectBinder/*!*/ call, Expression/*!*/ codeContext, DynamicMetaObject/*!*/[]/*!*/ args) {
ValidationInfo valInfo = MakeVersionCheck();
DynamicMetaObject self = new RestrictedMetaObject(
AstUtils.Convert(Expression, LimitType),
BindingRestrictionsHelpers.GetRuntimeTypeRestriction(Expression, LimitType),
Value
);
CallSignature sig = BindingHelpers.GetCallSignature(call);
ArgumentValues ai = new ArgumentValues(sig, self, args);
NewAdapter newAdapter;
InitAdapter initAdapter;
if (TooManyArgsForDefaultNew(call, args)) {
return MakeIncorrectArgumentsForCallError(call, ai, valInfo);
} else if (Value.UnderlyingSystemType.IsGenericTypeDefinition()) {
return MakeGenericTypeDefinitionError(call, ai, valInfo);
} else if (Value.HasAbstractMethods(PythonContext.GetPythonContext(call).SharedContext)) {
return MakeAbstractInstantiationError(call, ai, valInfo);
}
DynamicMetaObject translated = BuiltinFunction.TranslateArguments(call, codeContext, self, args, false, Value.Name);
if (translated != null) {
return translated;
}
GetAdapters(ai, call, codeContext, out newAdapter, out initAdapter);
PythonContext state = PythonContext.GetPythonContext(call);
// get the expression for calling __new__
DynamicMetaObject createExpr = newAdapter.GetExpression(state.Binder);
if (createExpr.Expression.Type == typeof(void)) {
return BindingHelpers.AddDynamicTestAndDefer(
call,
createExpr,
args,
valInfo
);
}
Expression res;
BindingRestrictions additionalRestrictions = BindingRestrictions.Empty;
if (!Value.IsSystemType && (!(newAdapter is DefaultNewAdapter) || HasFinalizer(call))) {
// we need to dynamically check the return value to see if it's a subtype of
// the type that we are calling. If it is then we need to call __init__/__del__
// for the actual returned type.
res = DynamicExpression.Dynamic(
Value.GetLateBoundInitBinder(sig),
typeof(object),
ArrayUtils.Insert(
codeContext,
Expression.Convert(createExpr.Expression, typeof(object)),
DynamicUtils.GetExpressions(args)
)
);
additionalRestrictions = createExpr.Restrictions;
} else {
// just call the __init__ method, built-in types currently have
// no wacky return values which don't return the derived type.
// then get the statement for calling __init__
ParameterExpression allocatedInst = Ast.Variable(createExpr.GetLimitType(), "newInst");
Expression tmpRead = allocatedInst;
DynamicMetaObject initCall = initAdapter.MakeInitCall(
state.Binder,
new RestrictedMetaObject(
AstUtils.Convert(allocatedInst, Value.UnderlyingSystemType),
createExpr.Restrictions
)
);
List<Expression> body = new List<Expression>();
Debug.Assert(!HasFinalizer(call));
// add the call to init if we need to
if (initCall.Expression != tmpRead) {
// init can fail but if __new__ returns a different type
// no exception is raised.
DynamicMetaObject initStmt = initCall;
if (body.Count == 0) {
body.Add(
Ast.Assign(allocatedInst, createExpr.Expression)
);
}
if (!Value.UnderlyingSystemType.IsAssignableFrom(createExpr.Expression.Type)) {
// return type of object, we need to check the return type before calling __init__.
body.Add(
AstUtils.IfThen(
Ast.TypeIs(allocatedInst, Value.UnderlyingSystemType),
initStmt.Expression
)
);
} else {
//.........这里部分代码省略.........
示例11: DefaultInitAdapter
public DefaultInitAdapter(ArgumentValues/*!*/ ai, BinderState/*!*/ state, Expression/*!*/ codeContext)
: base(ai, state, codeContext) {
}
示例12: InitAdapter
protected InitAdapter(ArgumentValues/*!*/ ai, BinderState/*!*/ state, Expression/*!*/ codeContext)
: base(ai, state, codeContext) {
}
示例13: MixedNewAdapter
public MixedNewAdapter(ArgumentValues/*!*/ ai, BinderState/*!*/ state, Expression/*!*/ codeContext)
: base(ai, state, codeContext) {
}
示例14: MixedInitAdapter
public MixedInitAdapter(ArgumentValues/*!*/ ai, PythonContext/*!*/ state, Expression/*!*/ codeContext)
: base(ai, state, codeContext) {
}
示例15: GetInitAdapter
private InitAdapter/*!*/ GetInitAdapter(ArgumentValues/*!*/ ai, PythonTypeSlot/*!*/ init, DynamicMetaObjectBinder/*!*/ call, Expression/*!*/ codeContext) {
PythonContext state = PythonContext.GetPythonContext(call);
if (Value.IsMixedNewStyleOldStyle()) {
return new MixedInitAdapter(ai, state, codeContext);
} else if ((init == InstanceOps.Init && !HasFinalizer(call)) || (Value == TypeCache.PythonType && ai.Arguments.Length == 2)) {
return new DefaultInitAdapter(ai, state, codeContext);
} else if (init is BuiltinMethodDescriptor) {
return new BuiltinInitAdapter(ai, ((BuiltinMethodDescriptor)init).Template, state, codeContext);
} else if (init is BuiltinFunction) {
return new BuiltinInitAdapter(ai, (BuiltinFunction)init, state, codeContext);
} else {
return new SlotInitAdapter(init, ai, state, codeContext);
}
}