本文整理汇总了C#中Mono.CSharp.Argument类的典型用法代码示例。如果您正苦于以下问题:C# Argument类的具体用法?C# Argument怎么用?C# Argument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Argument类属于Mono.CSharp命名空间,在下文中一共展示了Argument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BetterConversion
/// <summary>
/// Determines "better conversion" as specified in 7.4.2.3
/// Returns : 1 if a->p is better
/// 0 if a->q or neither is better
/// </summary>
static int BetterConversion (EmitContext ec, Argument a, Type p, Type q, Location loc)
{
Type argument_type = a.Type;
Expression argument_expr = a.Expr;
if (argument_type == null)
throw new Exception ("Expression of type " + a.Expr + " does not resolve its type");
//
// This is a special case since csc behaves this way. I can't find
// it anywhere in the spec but oh well ...
//
if (argument_expr is NullLiteral && p == TypeManager.string_type && q == TypeManager.object_type)
return 1;
else if (argument_expr is NullLiteral && p == TypeManager.object_type && q == TypeManager.string_type)
return 0;
if (p == q)
return 0;
if (argument_type == p)
return 1;
if (argument_type == q)
return 0;
//
// Now probe whether an implicit constant expression conversion
// can be used.
//
// An implicit constant expression conversion permits the following
// conversions:
//
// * A constant-expression of type `int' can be converted to type
// sbyte, byute, short, ushort, uint, ulong provided the value of
// of the expression is withing the range of the destination type.
//
// * A constant-expression of type long can be converted to type
// ulong, provided the value of the constant expression is not negative
//
// FIXME: Note that this assumes that constant folding has
// taken place. We dont do constant folding yet.
//
if (argument_expr is IntConstant){
IntConstant ei = (IntConstant) argument_expr;
int value = ei.Value;
if (p == TypeManager.sbyte_type){
if (value >= SByte.MinValue && value <= SByte.MaxValue)
return 1;
} else if (p == TypeManager.byte_type){
if (q == TypeManager.sbyte_type &&
value >= SByte.MinValue && value <= SByte.MaxValue)
return 0;
else if (Byte.MinValue >= 0 && value <= Byte.MaxValue)
return 1;
} else if (p == TypeManager.short_type){
if (value >= Int16.MinValue && value <= Int16.MaxValue)
return 1;
} else if (p == TypeManager.ushort_type){
if (q == TypeManager.short_type &&
value >= Int16.MinValue && value <= Int16.MaxValue)
return 0;
else if (value >= UInt16.MinValue && value <= UInt16.MaxValue)
return 1;
} else if (p == TypeManager.int32_type){
if (value >= Int32.MinValue && value <= Int32.MaxValue)
return 1;
} else if (p == TypeManager.uint32_type){
//
// we can optimize this case: a positive int32
// always fits on a uint32
//
if (value >= 0)
return 1;
} else if (p == TypeManager.uint64_type){
//
// we can optimize this case: a positive int32
// always fits on a uint64
//
if (q == TypeManager.int64_type)
return 0;
else if (value >= 0)
return 1;
} else if (p == TypeManager.int64_type){
return 1;
}
} else if (argument_type == TypeManager.int64_type && argument_expr is LongConstant){
LongConstant lc = (LongConstant) argument_expr;
if (p == TypeManager.uint64_type){
if (lc.Value > 0)
return 1;
}
//.........这里部分代码省略.........
示例2:
bool OverloadResolver.IErrorHandler.ArgumentMismatch (ResolveContext rc, MemberSpec best, Argument arg, int index)
{
Error_ConversionFailed (rc, best as MethodSpec, null);
return true;
}
示例3: Insert
public void Insert (int index, Argument arg)
{
args.Insert (index, arg);
}
示例4: case_477
void case_477()
#line 3492 "cs-parser.jay"
{
yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Out);
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
}
示例5: case_479
void case_479()
#line 3502 "cs-parser.jay"
{
yyVal = new Argument (new Arglist (GetLocation (yyVals[-2+yyTop])));
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop]));
}
示例6: AsTryResolveDynamicArgs
// Resolve any dynamic params to the type of the target parameters list (for PlayScript only).
public bool AsTryResolveDynamicArgs (ResolveContext ec, System.Collections.IEnumerable candidates)
{
MethodSpec ms = null;
foreach (MethodSpec possibleMs in candidates) {
if (possibleMs.Parameters.FixedParameters.Length <= args.Count &&
possibleMs.Parameters.Count >= args.Count) {
if (ms != null) {
ms = null; // Can't be more than one - or we give up and do a dynamic call..
break;
}
ms = possibleMs;
}
}
if (ms != null) {
var parameters = ms.Parameters;
for (var i = 0; i < args.Count; i++) {
var arg = args [i];
var paramType = parameters.Types [i];
if (arg.Expr.Type == ec.BuiltinTypes.Dynamic) {
var parCastType = paramType.BuiltinType == BuiltinTypeSpec.Type.Dynamic ? ec.BuiltinTypes.Object : paramType;
var new_arg = new Argument (new Cast (
new TypeExpression (parCastType, arg.Expr.Location),
arg.Expr, arg.Expr.Location), arg.ArgType);
new_arg.Resolve (ec);
args [i] = new_arg;
}
}
return true;
}
return false;
}
示例7: AsTryResolveDynamicArgs
// Resolve any dynamic params to the type of the target parameters list (for PlayScript only).
public bool AsTryResolveDynamicArgs (ResolveContext ec, System.Collections.IEnumerable candidates)
{
AParametersCollection parameters = null;
foreach (MemberSpec memberSpec in candidates) {
AParametersCollection possibleParams = null;
int fixedArgsLen = 0;
if (memberSpec is MethodSpec) {
MethodSpec methodSpec = memberSpec as MethodSpec;
possibleParams = methodSpec.Parameters;
fixedArgsLen = possibleParams.FixedParameters.Length;
if (methodSpec.IsExtensionMethod)
fixedArgsLen--;
} else if (memberSpec is IndexerSpec) {
IndexerSpec indexerSpec = memberSpec as IndexerSpec;
possibleParams = indexerSpec.Parameters;
fixedArgsLen = possibleParams.FixedParameters.Length;
}
if (fixedArgsLen == args.Count) {
if (parameters != null) {
parameters = null; // Can't be more than one - or we give up and do a dynamic call..
break;
}
parameters = possibleParams;
}
}
if (parameters != null) {
for (var i = 0; i < args.Count; i++) {
var arg = args [i];
var paramType = parameters.Types [i];
if (arg.Expr.Type == ec.BuiltinTypes.Dynamic) {
var parCastType = paramType.BuiltinType == BuiltinTypeSpec.Type.Dynamic ? ec.BuiltinTypes.Object : paramType;
var new_arg = new Argument (new Cast (
new TypeExpression (parCastType, arg.Expr.Location),
arg.Expr, arg.Expr.Location), arg.ArgType);
new_arg.Resolve (ec);
args [i] = new_arg;
}
}
return true;
}
return false;
}
示例8: ResolveUserOperator
//
// Performs user-operator overloading
//
protected virtual Expression ResolveUserOperator (ResolveContext ec, Type l, Type r)
{
Operator user_oper;
if (oper == Operator.LogicalAnd)
user_oper = Operator.BitwiseAnd;
else if (oper == Operator.LogicalOr)
user_oper = Operator.BitwiseOr;
else
user_oper = oper;
string op = GetOperatorMetadataName (user_oper);
MethodGroupExpr left_operators = MemberLookup (ec.Compiler, ec.CurrentType, l, op, MemberTypes.Method, AllBindingFlags, loc) as MethodGroupExpr;
MethodGroupExpr right_operators = null;
if (!TypeManager.IsEqual (r, l)) {
right_operators = MemberLookup (ec.Compiler, ec.CurrentType, r, op, MemberTypes.Method, AllBindingFlags, loc) as MethodGroupExpr;
if (right_operators == null && left_operators == null)
return null;
} else if (left_operators == null) {
return null;
}
Arguments args = new Arguments (2);
Argument larg = new Argument (left);
args.Add (larg);
Argument rarg = new Argument (right);
args.Add (rarg);
MethodGroupExpr union;
//
// User-defined operator implementations always take precedence
// over predefined operator implementations
//
if (left_operators != null && right_operators != null) {
if (IsPredefinedUserOperator (l, user_oper)) {
union = right_operators.OverloadResolve (ec, ref args, true, loc);
if (union == null)
union = left_operators;
} else if (IsPredefinedUserOperator (r, user_oper)) {
union = left_operators.OverloadResolve (ec, ref args, true, loc);
if (union == null)
union = right_operators;
} else {
union = MethodGroupExpr.MakeUnionSet (left_operators, right_operators, loc);
}
} else if (left_operators != null) {
union = left_operators;
} else {
union = right_operators;
}
union = union.OverloadResolve (ec, ref args, true, loc);
if (union == null)
return null;
Expression oper_expr;
// TODO: CreateExpressionTree is allocated every time
if (user_oper != oper) {
oper_expr = new ConditionalLogicalOperator (union, args, CreateExpressionTree,
oper == Operator.LogicalAnd, loc).Resolve (ec);
} else {
oper_expr = new UserOperatorCall (union, args, CreateExpressionTree, loc);
//
// This is used to check if a test 'x == null' can be optimized to a reference equals,
// and not invoke user operator
//
if ((oper & Operator.EqualityMask) != 0) {
if ((left is NullLiteral && IsBuildInEqualityOperator (r)) ||
(right is NullLiteral && IsBuildInEqualityOperator (l))) {
type = TypeManager.bool_type;
if (left is NullLiteral || right is NullLiteral)
oper_expr = ReducedExpression.Create (this, oper_expr).Resolve (ec);
} else if (l != r) {
MethodInfo mi = (MethodInfo) union;
//
// Two System.Delegate(s) are never equal
//
if (mi.DeclaringType == TypeManager.multicast_delegate_type)
return null;
}
}
}
left = larg.Expr;
right = rarg.Expr;
return oper_expr;
}
示例9: CreateExpressionAddCall
//
// Creates nested calls tree from an array of arguments used for IL emit
//
Expression CreateExpressionAddCall (ResolveContext ec, Argument left, Expression left_etree, int pos)
{
Arguments concat_args = new Arguments (2);
Arguments add_args = new Arguments (3);
concat_args.Add (left);
add_args.Add (new Argument (left_etree));
concat_args.Add (arguments [pos]);
add_args.Add (new Argument (arguments [pos].CreateExpressionTree (ec)));
MethodGroupExpr method = CreateConcatMemberExpression ().Resolve (ec) as MethodGroupExpr;
if (method == null)
return null;
method = method.OverloadResolve (ec, ref concat_args, false, loc);
if (method == null)
return null;
add_args.Add (new Argument (method.CreateExpressionTree (ec)));
Expression expr = CreateExpressionFactoryCall (ec, "Add", add_args);
if (++pos == arguments.Count)
return expr;
left = new Argument (new EmptyExpression (((MethodInfo)method).ReturnType));
return CreateExpressionAddCall (ec, left, expr, pos);
}
示例10: Add
public int Add (Argument arg)
{
return args.Add (arg);
}
示例11: Arglist
public Arglist (Argument[] args, Location l)
{
Arguments = args;
loc = l;
}
示例12: case_470
void case_470()
{
yyVal = new Argument (new Arglist (GetLocation (yyVals[-2+yyTop])));
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop]));
}
示例13: case_469
void case_469()
{
yyVal = new Argument (new Arglist ((Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop])));
lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
}
示例14: case_468
void case_468()
{
yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Out);
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
}
示例15: yyparse
//.........这里部分代码省略.........
case 71:
#line 788 "cs-parser.jay"
{ /* reserved attribute name or identifier: 17.4 */ }
break;
case 72:
#line 792 "cs-parser.jay"
{ yyVal = null; }
break;
case 73:
#line 796 "cs-parser.jay"
{
yyVal = yyVals[-1+yyTop];
}
break;
case 74:
#line 801 "cs-parser.jay"
{ yyVal = null; }
break;
case 75:
case_75();
break;
case 76:
case_76();
break;
case 77:
case_77();
break;
case 78:
case_78();
break;
case 79:
#line 845 "cs-parser.jay"
{
yyVal = new Argument ((Expression) yyVals[0+yyTop]);
}
break;
case 81:
#line 853 "cs-parser.jay"
{
++lexer.parsing_block;
}
break;
case 82:
case_82();
break;
case 83:
case_83();
break;
case 84:
#line 877 "cs-parser.jay"
{ yyVal = null; }
break;
case 85:
#line 881 "cs-parser.jay"
{
yyVal = Argument.AType.Ref;
}
break;
case 86:
#line 885 "cs-parser.jay"
{
yyVal = Argument.AType.Out;
}
break;
case 101:
case_101();