本文整理汇总了C#中IronPython.Runtime.Binding.BinderState.Operation方法的典型用法代码示例。如果您正苦于以下问题:C# BinderState.Operation方法的具体用法?C# BinderState.Operation怎么用?C# BinderState.Operation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IronPython.Runtime.Binding.BinderState
的用法示例。
在下文中一共展示了BinderState.Operation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnaryOperationBinder
public static DynamicMetaObjectBinder UnaryOperationBinder(BinderState state, PythonOperationKind operatorName) {
ExpressionType? et = GetExpressionTypeFromUnaryOperator(operatorName);
if (et == null) {
return state.Operation(
operatorName
);
}
return state.UnaryOperation(et.Value);
}
示例2: DoCoerce
/// <summary>
/// calls __coerce__ for old-style classes and performs the operation if the coercion is successful.
/// </summary>
private static void DoCoerce(BinderState/*!*/ state, ConditionalBuilder/*!*/ bodyBuilder, PythonOperationKind op, DynamicMetaObject/*!*/[]/*!*/ types, bool reverse, Func<Expression, Expression> returnTransform) {
ParameterExpression coerceResult = Ast.Variable(typeof(object), "coerceResult");
ParameterExpression coerceTuple = Ast.Variable(typeof(PythonTuple), "coerceTuple");
if (!bodyBuilder.TestCoercionRecursionCheck) {
// during coercion we need to enforce recursion limits if
// they're enabled and the rule's test needs to reflect this.
bodyBuilder.Restrictions = bodyBuilder.Restrictions.Merge(
BindingRestrictions.GetExpressionRestriction(
Ast.Equal(
Ast.Call(typeof(PythonOps).GetMethod("ShouldEnforceRecursion")),
AstUtils.Constant(PythonFunction.EnforceRecursion)
)
)
);
bodyBuilder.TestCoercionRecursionCheck = true;
}
// tmp = self.__coerce__(other)
// if tmp != null && tmp != NotImplemented && (tuple = PythonOps.ValidateCoerceResult(tmp)) != null:
// return operation(tuple[0], tuple[1])
SlotOrFunction slot = SlotOrFunction.GetSlotOrFunction(state, Symbols.Coerce, types);
if (slot.Success) {
bodyBuilder.AddCondition(
Ast.AndAlso(
Ast.Not(
Ast.TypeIs(
Ast.Assign(
coerceResult,
slot.Target.Expression
),
typeof(OldInstance)
)
),
Ast.NotEqual(
Ast.Assign(
coerceTuple,
Ast.Call(
typeof(PythonOps).GetMethod("ValidateCoerceResult"),
coerceResult
)
),
AstUtils.Constant(null)
)
),
BindingHelpers.AddRecursionCheck(
returnTransform(
Ast.Dynamic(
state.Operation(op | PythonOperationKind.DisableCoerce),
typeof(object),
reverse ? CoerceTwo(coerceTuple) : CoerceOne(coerceTuple),
reverse ? CoerceOne(coerceTuple) : CoerceTwo(coerceTuple)
)
)
)
);
bodyBuilder.AddVariable(coerceResult);
bodyBuilder.AddVariable(coerceTuple);
}
}