本文整理汇总了C#中Mono.CSharp.Binary类的典型用法代码示例。如果您正苦于以下问题:C# Binary类的具体用法?C# Binary怎么用?C# Binary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Binary类属于Mono.CSharp命名空间,在下文中一共展示了Binary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: case_580
void case_580()
#line 4166 "cs-parser.jay"
{
yyVal = new Binary (Binary.Operator.Multiply, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
}
示例2: CompoundAssign
public CompoundAssign (Binary.Operator op, Expression target, Expression source, Expression left)
: this (op, target, source)
{
this.left = left;
}
示例3: Visit
public override object Visit (Binary binaryExpression)
{
var result = new BinaryOperatorExpression ();
int opLength = 1;
switch (binaryExpression.Oper) {
case Binary.Operator.Multiply:
result.BinaryOperatorType = BinaryOperatorType.Multiply;
break;
case Binary.Operator.Division:
result.BinaryOperatorType = BinaryOperatorType.Divide;
break;
case Binary.Operator.Modulus:
result.BinaryOperatorType = BinaryOperatorType.Modulus;
break;
case Binary.Operator.Addition:
result.BinaryOperatorType = BinaryOperatorType.Add;
break;
case Binary.Operator.Subtraction:
result.BinaryOperatorType = BinaryOperatorType.Subtract;
break;
case Binary.Operator.LeftShift:
result.BinaryOperatorType = BinaryOperatorType.ShiftLeft;
opLength = 2;
break;
case Binary.Operator.RightShift:
result.BinaryOperatorType = BinaryOperatorType.ShiftRight;
opLength = 2;
break;
case Binary.Operator.LessThan:
result.BinaryOperatorType = BinaryOperatorType.LessThan;
break;
case Binary.Operator.GreaterThan:
result.BinaryOperatorType = BinaryOperatorType.GreaterThan;
break;
case Binary.Operator.LessThanOrEqual:
result.BinaryOperatorType = BinaryOperatorType.LessThanOrEqual;
opLength = 2;
break;
case Binary.Operator.GreaterThanOrEqual:
result.BinaryOperatorType = BinaryOperatorType.GreaterThanOrEqual;
opLength = 2;
break;
case Binary.Operator.Equality:
result.BinaryOperatorType = BinaryOperatorType.Equality;
opLength = 2;
break;
case Binary.Operator.Inequality:
result.BinaryOperatorType = BinaryOperatorType.InEquality;
opLength = 2;
break;
case Binary.Operator.BitwiseAnd:
result.BinaryOperatorType = BinaryOperatorType.BitwiseAnd;
break;
case Binary.Operator.ExclusiveOr:
result.BinaryOperatorType = BinaryOperatorType.ExclusiveOr;
break;
case Binary.Operator.BitwiseOr:
result.BinaryOperatorType = BinaryOperatorType.BitwiseOr;
break;
case Binary.Operator.LogicalAnd:
result.BinaryOperatorType = BinaryOperatorType.LogicalAnd;
opLength = 2;
break;
case Binary.Operator.LogicalOr:
result.BinaryOperatorType = BinaryOperatorType.LogicalOr;
opLength = 2;
break;
}
result.AddChild ((INode)binaryExpression.Left.Accept (this), BinaryOperatorExpression.LeftExpressionRole);
result.AddChild (new CSharpTokenNode (Convert (binaryExpression.Location), opLength), BinaryOperatorExpression.OperatorRole);
result.AddChild ((INode)binaryExpression.Right.Accept (this), BinaryOperatorExpression.RightExpressionRole);
return result;
}
示例4: Convert
static CodeBinaryOperatorType Convert (Binary.Operator o)
{
switch (o) {
case Binary.Operator.Multiply:
return CodeBinaryOperatorType.Multiply;
case Binary.Operator.Division:
return CodeBinaryOperatorType.Divide;
case Binary.Operator.Modulus:
return CodeBinaryOperatorType.Modulus;
case Binary.Operator.Addition:
return CodeBinaryOperatorType.Add;
case Binary.Operator.Subtraction:
return CodeBinaryOperatorType.Subtract;
case Binary.Operator.LeftShift:
case Binary.Operator.RightShift:
return CodeBinaryOperatorType.Multiply; // unsupported
case Binary.Operator.LessThan:
return CodeBinaryOperatorType.LessThan;
case Binary.Operator.GreaterThan:
return CodeBinaryOperatorType.GreaterThan;
case Binary.Operator.LessThanOrEqual:
return CodeBinaryOperatorType.LessThanOrEqual;
case Binary.Operator.GreaterThanOrEqual:
return CodeBinaryOperatorType.GreaterThanOrEqual;
case Binary.Operator.Equality:
return CodeBinaryOperatorType.IdentityEquality;
case Binary.Operator.Inequality:
return CodeBinaryOperatorType.IdentityInequality;
case Binary.Operator.BitwiseAnd:
return CodeBinaryOperatorType.BitwiseAnd;
case Binary.Operator.ExclusiveOr:
return CodeBinaryOperatorType.BitwiseOr; // unsupported
case Binary.Operator.BitwiseOr:
return CodeBinaryOperatorType.BitwiseOr;
case Binary.Operator.LogicalAnd:
return CodeBinaryOperatorType.BooleanAnd;
case Binary.Operator.LogicalOr:
return CodeBinaryOperatorType.BooleanOr;
}
return CodeBinaryOperatorType.Add;
}
示例5: Visit
public override object Visit(Binary binaryExpression)
{
var result = new BinaryOperatorExpression();
switch (binaryExpression.Oper) {
case Binary.Operator.Multiply:
result.Operator = BinaryOperatorType.Multiply;
break;
case Binary.Operator.Division:
result.Operator = BinaryOperatorType.Divide;
break;
case Binary.Operator.Modulus:
result.Operator = BinaryOperatorType.Modulus;
break;
case Binary.Operator.Addition:
result.Operator = BinaryOperatorType.Add;
break;
case Binary.Operator.Subtraction:
result.Operator = BinaryOperatorType.Subtract;
break;
case Binary.Operator.LeftShift:
result.Operator = BinaryOperatorType.ShiftLeft;
break;
case Binary.Operator.RightShift:
result.Operator = BinaryOperatorType.ShiftRight;
break;
case Binary.Operator.LessThan:
result.Operator = BinaryOperatorType.LessThan;
break;
case Binary.Operator.GreaterThan:
result.Operator = BinaryOperatorType.GreaterThan;
break;
case Binary.Operator.LessThanOrEqual:
result.Operator = BinaryOperatorType.LessThanOrEqual;
break;
case Binary.Operator.GreaterThanOrEqual:
result.Operator = BinaryOperatorType.GreaterThanOrEqual;
break;
case Binary.Operator.Equality:
result.Operator = BinaryOperatorType.Equality;
break;
case Binary.Operator.Inequality:
result.Operator = BinaryOperatorType.InEquality;
break;
case Binary.Operator.BitwiseAnd:
result.Operator = BinaryOperatorType.BitwiseAnd;
break;
case Binary.Operator.ExclusiveOr:
result.Operator = BinaryOperatorType.ExclusiveOr;
break;
case Binary.Operator.BitwiseOr:
result.Operator = BinaryOperatorType.BitwiseOr;
break;
case Binary.Operator.LogicalAnd:
result.Operator = BinaryOperatorType.ConditionalAnd;
break;
case Binary.Operator.LogicalOr:
result.Operator = BinaryOperatorType.ConditionalOr;
break;
}
if (binaryExpression.Left != null)
result.AddChild((Expression)binaryExpression.Left.Accept(this), BinaryOperatorExpression.LeftRole);
var location = LocationsBag.GetLocations(binaryExpression);
if (location != null) {
var r = BinaryOperatorExpression.GetOperatorRole(result.Operator);
result.AddChild(new CSharpTokenNode(Convert(location [0]), r), r);
}
if (binaryExpression.Right != null)
result.AddChild((Expression)binaryExpression.Right.Accept(this), BinaryOperatorExpression.RightRole);
return result;
}
示例6: case_621
void case_621()
#line 4397 "cs-parser.jay"
{
yyVal = new Binary (Binary.Operator.BitwiseOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
}
示例7: case_628
void case_628()
#line 4434 "cs-parser.jay"
{
Error_SyntaxError (yyToken);
yyVal = new Binary (Binary.Operator.LogicalOr, (Expression) yyVals[-2+yyTop], null);
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
}
示例8: case_597
void case_597()
#line 4262 "cs-parser.jay"
{
yyVal = new Binary (Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
}
示例9: case_599
void case_599()
#line 4274 "cs-parser.jay"
{
Error_SyntaxError (yyToken);
yyVal = new Binary (Binary.Operator.RightShift, (Expression) yyVals[-2+yyTop], null);
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
}
示例10: case_585
void case_585()
#line 4198 "cs-parser.jay"
{
Error_SyntaxError (yyToken);
yyVal = new Binary (Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], null);
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
}
示例11: case_588
void case_588()
#line 4214 "cs-parser.jay"
{
yyVal = new Binary (Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
}
示例12: case_582
void case_582()
#line 4179 "cs-parser.jay"
{
yyVal = new Binary (Binary.Operator.Modulus, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
}
示例13: CreateDynamicBinderArguments
public ArrayInitializer CreateDynamicBinderArguments (ResolveContext rc)
{
Location loc = Location.Null;
var all = new ArrayInitializer (args.Count, loc);
MemberAccess binder = DynamicExpressionStatement.GetBinderNamespace (rc, loc);
foreach (Argument a in args) {
Arguments dargs = new Arguments (2);
// CSharpArgumentInfoFlags.None = 0
const string info_flags_enum = "CSharpArgumentInfoFlags";
Expression info_flags = new IntLiteral (rc.BuiltinTypes, 0, loc);
if (a.Expr is Constant) {
info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags,
new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "Constant", loc));
} else if (a.ArgType == Argument.AType.Ref) {
info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags,
new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "IsRef", loc));
info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags,
new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "UseCompileTimeType", loc));
} else if (a.ArgType == Argument.AType.Out) {
info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags,
new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "IsOut", loc));
info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags,
new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "UseCompileTimeType", loc));
} else if (a.ArgType == Argument.AType.DynamicTypeName) {
info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags,
new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "IsStaticType", loc));
}
TypeSpec arg_type;
if (rc.FileType == SourceFileType.PlayScript &&
a.Expr is ArrayInitializer || a.Expr is AsObjectInitializer) {
if (a.Expr is ArrayInitializer) {
arg_type = rc.Module.PredefinedTypes.AsArray.Resolve();
} else {
arg_type = rc.Module.PredefinedTypes.AsObject.Resolve();
}
} else {
arg_type = a.Expr.Type;
}
if (arg_type.BuiltinType != BuiltinTypeSpec.Type.Dynamic && arg_type != InternalType.NullLiteral) {
MethodGroupExpr mg = a.Expr as MethodGroupExpr;
bool wasConverted = false;
// In PlayScript, we try to implicity convert to dynamic, which handles conversions of method groups to delegates, and
// anon methods to delegates.
if (rc.FileType == SourceFileType.PlayScript && (mg != null || arg_type == InternalType.AnonymousMethod)) {
var expr = Convert.ImplicitConversion (rc, a.Expr, rc.BuiltinTypes.Dynamic, loc);
if (expr != null) {
a.Expr = expr;
arg_type = rc.BuiltinTypes.Dynamic;
wasConverted = true;
}
}
// Failed.. check the C# error
if (!wasConverted) {
if (mg != null) {
rc.Report.Error (1976, a.Expr.Location,
"The method group `{0}' cannot be used as an argument of dynamic operation. Consider using parentheses to invoke the method",
mg.Name);
} else if (arg_type == InternalType.AnonymousMethod) {
rc.Report.Error (1977, a.Expr.Location,
"An anonymous method or lambda expression cannot be used as an argument of dynamic operation. Consider using a cast");
} else if (arg_type.Kind == MemberKind.Void || arg_type == InternalType.Arglist || arg_type.IsPointer) {
rc.Report.Error (1978, a.Expr.Location,
"An expression of type `{0}' cannot be used as an argument of dynamic operation",
arg_type.GetSignatureForError ());
}
}
info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags,
new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "UseCompileTimeType", loc));
}
string named_value;
NamedArgument na = a as NamedArgument;
if (na != null) {
info_flags = new Binary (Binary.Operator.BitwiseOr, info_flags,
new MemberAccess (new MemberAccess (binder, info_flags_enum, loc), "NamedArgument", loc));
named_value = na.Name;
} else {
named_value = null;
}
dargs.Add (new Argument (info_flags));
dargs.Add (new Argument (new StringLiteral (rc.BuiltinTypes, named_value, loc)));
all.Add (new Invocation (new MemberAccess (new MemberAccess (binder, "CSharpArgumentInfo", loc), "Create", loc), dargs));
}
return all;
}
示例14: case_592
void case_592()
#line 4231 "cs-parser.jay"
{
Error_SyntaxError (yyToken);
yyVal = new Binary (Binary.Operator.Subtraction, (Expression) yyVals[-2+yyTop], null);
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
}
示例15: case_618
void case_618()
#line 4381 "cs-parser.jay"
{
yyVal = new Binary (Binary.Operator.ExclusiveOr, (Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop]);
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
}