本文整理汇总了C#中Microsoft.Scripting.Actions.Calls.RestrictedArguments类的典型用法代码示例。如果您正苦于以下问题:C# RestrictedArguments类的具体用法?C# RestrictedArguments怎么用?C# RestrictedArguments使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RestrictedArguments类属于Microsoft.Scripting.Actions.Calls命名空间,在下文中一共展示了RestrictedArguments类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToExpression
internal override Expression ToExpression(OverloadResolver resolver, IList<ArgBuilder> builders, RestrictedArguments args, Expression ret) {
if (_returnArgs.Count == 1) {
if (_returnArgs[0] == -1) {
return ret;
}
return Ast.Block(ret, builders[_returnArgs[0]].ToReturnExpression(resolver));
}
Expression[] retValues = new Expression[_returnArgs.Count];
int rIndex = 0;
bool usesRet = false;
foreach (int index in _returnArgs) {
if (index == -1) {
usesRet = true;
retValues[rIndex++] = ret;
} else {
retValues[rIndex++] = builders[index].ToReturnExpression(resolver);
}
}
Expression retArray = AstUtils.NewArrayHelper(typeof(object), retValues);
if (!usesRet) {
retArray = Ast.Block(ret, retArray);
}
return resolver.GetByRefArrayExpression(retArray);
}
示例2: ToExpression
internal protected override Expression ToExpression(OverloadResolver resolver, RestrictedArguments args, bool[] hasBeenUsed) {
if (_tmp == null) {
_tmp = resolver.GetTemporary(_elementType, "outParam");
}
Debug.Assert(!hasBeenUsed[Index]);
hasBeenUsed[Index] = true;
Expression arg = args.GetObject(Index).Expression;
return Expression.Condition(
Expression.TypeIs(arg, Type),
Expression.Assign(
_tmp,
Expression.Field(
AstUtils.Convert(arg, Type),
Type.GetField("Value")
)
),
Expression.Throw(
Expression.Call(
new Func<Type, object, Exception>(RuntimeHelpers.MakeIncorrectBoxTypeError).Method,
AstUtils.Constant(_elementType),
AstUtils.Convert(arg, typeof(object))
),
_elementType
)
);
}
示例3: ToExpression
internal protected override Expression ToExpression(OverloadResolver resolver, RestrictedArguments args, bool[] hasBeenUsed) {
if (_tmp == null) {
_tmp = resolver.GetTemporary(Type, "outParam");
}
return Ast.Block(Ast.Assign(_tmp, base.ToExpression(resolver, args, hasBeenUsed)), _tmp);
}
示例4: BindingTarget
private readonly int _actualArgs; // gets the actual number of arguments provided
/// <summary>
/// Creates a new BindingTarget when the method binding has succeeded.
/// </summary>
internal BindingTarget(string name, int actualArgumentCount, MethodCandidate candidate, NarrowingLevel level, RestrictedArguments restrictedArgs) {
_name = name;
_candidate = candidate;
_restrictedArgs = restrictedArgs;
_level = level;
_actualArgs = actualArgumentCount;
}
示例5: ToExpression
internal protected override Expression ToExpression(OverloadResolver resolver, RestrictedArguments args, bool[] hasBeenUsed) {
if (_tmp == null) {
_tmp = resolver.GetTemporary(_elementType, "outParam");
}
Debug.Assert(!hasBeenUsed[Index]);
hasBeenUsed[Index] = true;
Type boxType = typeof(StrongBox<>).MakeGenericType(_elementType);
Expression arg = args.GetObject(Index).Expression;
return Expression.Condition(
Expression.TypeIs(arg, Type),
Expression.Assign(
_tmp,
Expression.Field(
AstUtils.Convert(arg, boxType),
boxType.GetField("Value")
)
),
Expression.Call(
typeof(RuntimeHelpers).GetMethod("IncorrectBoxType").MakeGenericMethod(_elementType),
AstUtils.Convert(arg, typeof(object))
)
);
}
示例6: ToExpression
internal protected override Expression ToExpression(OverloadResolver resolver, RestrictedArguments args, bool[] hasBeenUsed) {
Debug.Assert(BuilderExpectsSingleParameter(_builder));
int index = GetKeywordIndex(args.Length);
Debug.Assert(!hasBeenUsed[index]);
hasBeenUsed[index] = true;
return _builder.ToExpression(resolver, MakeRestrictedArg(args, index), new bool[1]);
}
示例7: ToExpression
internal protected override Expression ToExpression(OverloadResolver resolver, RestrictedArguments args, bool[] hasBeenUsed) {
Expression res = Ast.Call(
typeof(BinderOps).GetMethod("MakeSymbolDictionary"),
Ast.NewArrayInit(typeof(string), ConstantNames()),
AstUtils.NewArrayHelper(typeof(object), GetParameters(args, hasBeenUsed))
);
return res;
}
示例8: ToExpression
internal protected override Expression ToExpression(OverloadResolver resolver, RestrictedArguments args, bool[] hasBeenUsed) {
Type dictType = ParameterInfo.ParameterType;
return Ast.Call(
GetCreationDelegate(dictType).Method,
Ast.NewArrayInit(typeof(string), ConstantNames()),
AstUtils.NewArrayHelper(typeof(object), GetParameters(args, hasBeenUsed))
);
}
示例9: UpdateFromReturn
internal override Expression UpdateFromReturn(OverloadResolver resolver, RestrictedArguments args) {
return Expression.Assign(
Expression.Field(
Expression.Convert(args.GetObject(Index).Expression, Type),
Type.GetField("Value")
),
_tmp
);
}
示例10: GetCallableMethod
private void GetCallableMethod(RestrictedArguments args, ref MethodInfo method) {
// If we have a non-visible method see if we can find a better method which
// will call the same thing but is visible. If this fails we still bind anyway - it's
// the callers responsibility to filter out non-visible methods.
//
// We use limit type of the meta instance so that we can access methods inherited to that type
// as accessible via an interface implemented by the type. The type might be internal and the methods
// might not be accessible otherwise.
method = CompilerHelpers.TryGetCallableMethod(args.GetObject(_index).LimitType, method);
}
示例11: ToExpression
internal protected override Expression ToExpression(OverloadResolver resolver, RestrictedArguments args, bool[] hasBeenUsed) {
if (_isRef) {
if (_tmp == null) {
_tmp = resolver.GetTemporary(_parameterType, "outParam");
}
return _tmp;
}
return GetDefaultValue();
}
示例12: GetParameters
private List<Expression> GetParameters(RestrictedArguments args, bool[] hasBeenUsed) {
List<Expression> res = new List<Expression>(_nameIndexes.Length);
for (int i = 0; i < _nameIndexes.Length; i++) {
int parameterIndex = _nameIndexes[i] + _argIndex;
if (!hasBeenUsed[parameterIndex]) {
res.Add(args.GetObject(parameterIndex).Expression);
hasBeenUsed[parameterIndex] = true;
}
}
return res;
}
示例13: ToExpression
internal protected virtual Expression ToExpression(ref MethodInfo method, OverloadResolver resolver, RestrictedArguments args, bool[] hasBeenUsed) {
if (_index == -1) {
return AstUtils.Constant(null);
}
Debug.Assert(hasBeenUsed.Length == args.Length);
Debug.Assert(_index < args.Length);
Debug.Assert(!hasBeenUsed[_index]);
hasBeenUsed[_index] = true;
GetCallableMethod(args, ref method);
return resolver.Convert(args.GetObject(_index), args.GetType(_index), null, method.DeclaringType);
}
示例14: ToExpression
internal protected override Expression ToExpression(OverloadResolver resolver, RestrictedArguments args, bool[] hasBeenUsed) {
object value = ParameterInfo.DefaultValue;
if (value is Missing) {
value = CompilerHelpers.GetMissingValue(ParameterInfo.ParameterType);
}
if (ParameterInfo.ParameterType.IsByRef) {
return AstUtils.Constant(value, ParameterInfo.ParameterType.GetElementType());
}
var metaValue = new DynamicMetaObject(AstUtils.Constant(value), BindingRestrictions.Empty, value);
return resolver.Convert(metaValue, CompilerHelpers.GetType(value), ParameterInfo, ParameterInfo.ParameterType);
}
示例15: ToDelegate
protected internal override Func<object[], object> ToDelegate(OverloadResolver resolver, RestrictedArguments args, bool[] hasBeenUsed) {
if (ParameterInfo.ParameterType.IsByRef) {
return null;
} else if (ParameterInfo.DefaultValue is Missing && CompilerHelpers.GetMissingValue(ParameterInfo.ParameterType) is Missing) {
// reflection throws when we do this
return null;
}
object val = ParameterInfo.DefaultValue;
if (val is Missing) {
val = CompilerHelpers.GetMissingValue(ParameterInfo.ParameterType);
}
Debug.Assert(val != Missing.Value);
return (_) => val;
}