本文整理汇总了C#中IronPython.Runtime.Binding.BinderState类的典型用法代码示例。如果您正苦于以下问题:C# BinderState类的具体用法?C# BinderState怎么用?C# BinderState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BinderState类属于IronPython.Runtime.Binding命名空间,在下文中一共展示了BinderState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConversionBinder
public ConversionBinder(BinderState/*!*/ state, Type/*!*/ type, ConversionResultKind resultKind)
: base(type, resultKind == ConversionResultKind.ExplicitCast || resultKind == ConversionResultKind.ExplicitTry) {
Assert.NotNull(state, type);
_state = state;
_kind = resultKind;
}
示例2: AstGenerator
internal AstGenerator(AstGenerator/*!*/ parent, string name, bool generator, bool print)
: this(name, generator, false) {
Assert.NotNull(parent);
_context = parent.Context;
_binderState = parent.BinderState;
_document = _context.SourceUnit.Document;
}
示例3: Convert
/// <summary>
/// Backwards compatible Convert for the old sites that need to flow CodeContext
/// </summary>
public static Expression/*!*/ Convert(Expression/*!*/ codeContext, BinderState/*!*/ binder, Type/*!*/ type, ConversionResultKind resultKind, Expression/*!*/ target) {
return Ast.Dynamic(
binder.Convert(type, resultKind),
type,
target
);
}
示例4: Get
public static Expression/*!*/ Get(Expression/*!*/ codeContext, BinderState/*!*/ binder, Type/*!*/ resultType, string/*!*/ name, Expression/*!*/ target) {
return Ast.Dynamic(
binder.GetMember(name),
resultType,
target,
codeContext
);
}
示例5: Operation
public static Expression/*!*/ Operation(BinderState/*!*/ binder, Type/*!*/ resultType, string/*!*/ operation, Expression arg0) {
return Ast.Dynamic(
new PythonOperationBinder(
binder,
operation
),
resultType,
arg0
);
}
示例6: Convert
public static Expression/*!*/ Convert(BinderState/*!*/ binder, Type/*!*/ type, ConversionResultKind resultKind, Expression/*!*/ target) {
return Ast.Dynamic(
new ConversionBinder(
binder,
type,
resultKind
),
type,
target
);
}
示例7: 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);
}
示例8: MakeTryGetTypeMember
internal static MethodCallExpression MakeTryGetTypeMember(BinderState/*!*/ binderState, PythonTypeSlot dts, ParameterExpression tmp, Expression instance, Expression pythonType) {
return Ast.Call(
TypeInfo._PythonOps.SlotTryGetBoundValue,
Ast.Constant(binderState.Context),
AstUtils.Convert(Utils.WeakConstant(dts), typeof(PythonTypeSlot)),
AstUtils.Convert(instance, typeof(object)),
AstUtils.Convert(
pythonType,
typeof(PythonType)
),
tmp
);
}
示例9: BinaryOperationRetType
public static DynamicMetaObjectBinder/*!*/ BinaryOperationRetType(BinderState/*!*/ state, PythonOperationKind operatorName, Type retType) {
return new ComboBinder(
new BinderMappingInfo(
BinaryOperationBinder(state, operatorName),
ParameterMappingInfo.Parameter(0),
ParameterMappingInfo.Parameter(1)
),
new BinderMappingInfo(
state.Convert(retType, ConversionResultKind.ExplicitCast),
ParameterMappingInfo.Action(0)
)
);
}
示例10: TryGetStaticFunction
/// <summary>
/// Trys to get the BuiltinFunction for the given name on the type of the provided MetaObject.
///
/// Succeeds if the MetaObject is a BuiltinFunction or BuiltinMethodDescriptor.
/// </summary>
internal static bool TryGetStaticFunction(BinderState/*!*/ state, SymbolId op, DynamicMetaObject/*!*/ mo, out BuiltinFunction function) {
PythonType type = MetaPythonObject.GetPythonType(mo);
function = null;
if (op != SymbolId.Empty) {
PythonTypeSlot xSlot;
object val;
if (type.TryResolveSlot(state.Context, op, out xSlot) &&
xSlot.TryGetValue(state.Context, null, type, out val)) {
function = TryConvertToBuiltinFunction(val);
if (function == null) return false;
}
}
return true;
}
示例11: Invoke
public static Expression/*!*/ Invoke(BinderState/*!*/ binder, Type/*!*/ resultType, CallSignature signature, params Expression/*!*/[]/*!*/ args) {
PythonInvokeBinder invoke = new PythonInvokeBinder(binder, signature);
switch(args.Length) {
case 0: return Ast.Dynamic(invoke, resultType, AstUtils.CodeContext());
case 1: return Ast.Dynamic(invoke, resultType, AstUtils.CodeContext(), args[0]);
case 2: return Ast.Dynamic(invoke, resultType, AstUtils.CodeContext(), args[0], args[1]);
case 3: return Ast.Dynamic(invoke, resultType, AstUtils.CodeContext(), args[0], args[1], args[2]);
default:
return Ast.Dynamic(
invoke,
resultType,
new ReadOnlyCollection<Expression>(ArrayUtils.Insert(AstUtils.CodeContext(), args))
);
}
}
示例12: FallbackGetMember
private DynamicMetaObject/*!*/ FallbackGetMember(DynamicMetaObjectBinder member, BinderState state) {
MemberTracker tt = MemberTracker.FromMemberInfo(Value.UnderlyingSystemType);
if (member is IPythonSite) {
// bind the .NET members
string memberName = GetGetMemberName(member);
return state.Binder.GetMember(
memberName,
new DynamicMetaObject(
Ast.Constant(tt),
BindingRestrictions.Empty,
tt
),
Ast.Constant(state.Context),
BindingHelpers.IsNoThrow(member)
);
}
// let the calling language bind the .NET members
return GetMemberFallback(this, member, BinderState.GetCodeContext(member));
}
示例13: GetFallbackGet
private DynamicMetaObject/*!*/ GetFallbackGet(DynamicMetaObjectBinder/*!*/ member, BinderState/*!*/ state, Expression codeContext) {
string memberName = GetGetMemberName(member);
DynamicMetaObject res = new DynamicMetaObject(
FallbackGetMember(member, state).Expression,
BindingRestrictions.GetInstanceRestriction(Expression, Value).Merge(Restrictions)
);
if (codeContext != null && Value.IsHiddenMember(memberName)) {
res = BindingHelpers.FilterShowCls(
codeContext,
member,
res,
Ast.Throw(
Ast.Call(
typeof(PythonOps).GetMethod("AttributeErrorForMissingAttribute", new Type[] { typeof(string), typeof(SymbolId) }),
AstUtils.Constant(Value.Name),
AstUtils.Constant(SymbolTable.StringToId(memberName))
)
)
);
}
return res;
}
示例14: PythonGetMemberBinder
public PythonGetMemberBinder(BinderState/*!*/ binder, string/*!*/ name) {
_state = binder;
_name = name;
}
示例15: CompatibilityGetMember
public CompatibilityGetMember(BinderState/*!*/ binder, string/*!*/ name)
: this(binder, name, false) {
}