本文整理汇总了C#中Mono.CSharp.Operator类的典型用法代码示例。如果您正苦于以下问题:C# Operator类的具体用法?C# Operator怎么用?C# Operator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Operator类属于Mono.CSharp命名空间,在下文中一共展示了Operator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PredefinedOperator
public PredefinedOperator (Type ltype, Type rtype, Operator op_mask, Type return_type)
{
if ((op_mask & Operator.ValuesOnlyMask) != 0)
throw new InternalErrorException ("Only masked values can be used");
this.left = ltype;
this.right = rtype;
this.OperatorsMask = op_mask;
this.ReturnType = return_type;
}
示例2: Visit
public override void Visit(Operator o)
{
var newOperator = new OperatorDeclaration();
newOperator.OperatorType = (OperatorType)o.OperatorType;
var location = LocationsBag.GetMemberLocation(o);
AddAttributeSection(newOperator, o);
AddModifiers(newOperator, location);
if (o.OperatorType == Operator.OpType.Implicit) {
if (location != null && location.Count > 0) {
newOperator.AddChild(new CSharpTokenNode(Convert(location [0]), OperatorDeclaration.ImplicitRole), OperatorDeclaration.ImplicitRole);
if (location.Count > 1)
newOperator.AddChild(new CSharpTokenNode(Convert(location [1]), OperatorDeclaration.OperatorKeywordRole), OperatorDeclaration.OperatorKeywordRole);
}
newOperator.AddChild(ConvertToType(o.TypeExpression), Roles.Type);
} else if (o.OperatorType == Operator.OpType.Explicit) {
if (location != null && location.Count > 0) {
newOperator.AddChild(new CSharpTokenNode(Convert(location [0]), OperatorDeclaration.ExplicitRole), OperatorDeclaration.ExplicitRole);
if (location.Count > 1)
newOperator.AddChild(new CSharpTokenNode(Convert(location [1]), OperatorDeclaration.OperatorKeywordRole), OperatorDeclaration.OperatorKeywordRole);
}
newOperator.AddChild(ConvertToType(o.TypeExpression), Roles.Type);
} else {
newOperator.AddChild(ConvertToType(o.TypeExpression), Roles.Type);
if (location != null && location.Count > 0)
newOperator.AddChild(new CSharpTokenNode(Convert(location [0]), OperatorDeclaration.OperatorKeywordRole), OperatorDeclaration.OperatorKeywordRole);
if (location != null && location.Count > 1) {
var r = OperatorDeclaration.GetRole(newOperator.OperatorType);
newOperator.AddChild(new CSharpTokenNode(Convert(location [1]), r), r);
}
}
if (location != null && location.Count > 2)
newOperator.AddChild(new CSharpTokenNode(Convert(location [2]), Roles.LPar), Roles.LPar);
AddParameter(newOperator, o.ParameterInfo);
if (location != null && location.Count > 3)
newOperator.AddChild(new CSharpTokenNode(Convert(location [3]), Roles.RPar), Roles.RPar);
if (o.Block != null) {
newOperator.AddChild((BlockStatement)o.Block.Accept(this), Roles.Body);
} else {
if (location != null && location.Count >= 5)
newOperator.AddChild(new CSharpTokenNode(Convert(location [4]), Roles.Semicolon), Roles.Semicolon);
}
typeStack.Peek().AddChild(newOperator, Roles.TypeMemberRole);
}
示例3: AddOperator
public void AddOperator (Operator op)
{
if (!AddMember (op))
return;
if (operators == null)
operators = new List<MemberCore> ();
operators.Add (op);
}
示例4: IsUnaryOperator
static bool IsUnaryOperator (Operator.OpType op)
{
switch (op) {
case Operator.OpType.LogicalNot:
case Operator.OpType.OnesComplement:
case Operator.OpType.Increment:
case Operator.OpType.Decrement:
case Operator.OpType.True:
case Operator.OpType.False:
case Operator.OpType.UnaryPlus:
case Operator.OpType.UnaryNegation:
return true;
}
return false;
}
示例5: Visit
public override void Visit (Operator o)
{
OperatorDeclaration newOperator = new OperatorDeclaration ();
newOperator.OperatorType = (OperatorType)o.OperatorType;
var location = LocationsBag.GetMemberLocation (o);
AddAttributeSection (newOperator, o);
AddModifiers (newOperator, location);
if (o.OperatorType == Operator.OpType.Implicit) {
if (location != null) {
newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "implicit".Length), OperatorDeclaration.OperatorTypeRole);
newOperator.AddChild (new CSharpTokenNode (Convert (location[1]), "operator".Length), OperatorDeclaration.OperatorKeywordRole);
}
newOperator.AddChild (ConvertToType (o.TypeName), AstNode.Roles.Type);
} else if (o.OperatorType == Operator.OpType.Explicit) {
if (location != null) {
newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "explicit".Length), OperatorDeclaration.OperatorTypeRole);
newOperator.AddChild (new CSharpTokenNode (Convert (location[1]), "operator".Length), OperatorDeclaration.OperatorKeywordRole);
}
newOperator.AddChild (ConvertToType (o.TypeName), AstNode.Roles.Type);
} else {
newOperator.AddChild (ConvertToType (o.TypeName), AstNode.Roles.Type);
if (location != null)
newOperator.AddChild (new CSharpTokenNode (Convert (location[0]), "operator".Length), OperatorDeclaration.OperatorKeywordRole);
int opLength = OperatorDeclaration.GetToken(newOperator.OperatorType).Length;
if (location != null)
newOperator.AddChild (new CSharpTokenNode (Convert (location[1]), opLength), OperatorDeclaration.OperatorTypeRole);
}
if (location != null)
newOperator.AddChild (new CSharpTokenNode (Convert (location[2]), 1), OperatorDeclaration.Roles.LPar);
AddParameter (newOperator, o.ParameterInfo);
if (location != null)
newOperator.AddChild (new CSharpTokenNode (Convert (location[3]), 1), OperatorDeclaration.Roles.RPar);
if (o.Block != null) {
newOperator.AddChild ((BlockStatement)o.Block.Accept (this), OperatorDeclaration.Roles.Body);
} else {
if (location != null && location.Count >= 5)
newOperator.AddChild (new CSharpTokenNode (Convert (location[4]), 1), MethodDeclaration.Roles.Semicolon);
}
typeStack.Peek ().AddChild (newOperator, TypeDeclaration.MemberRole);
}
示例6: yyparse
//.........这里部分代码省略.........
{
Report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants");
}
break;
case 236:
#line 1928 "cs-parser.jay"
{
Report.Error (567, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain operators");
}
break;
case 237:
#line 1932 "cs-parser.jay"
{
Report.Error (526, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain contructors");
}
break;
case 238:
#line 1936 "cs-parser.jay"
{
Report.Error (524, GetLocation (yyVals[0+yyTop]), "Interfaces cannot declare classes, structs, interfaces, delegates, or enumerations");
}
break;
case 239:
#line 1943 "cs-parser.jay"
{
}
break;
case 240:
#line 1946 "cs-parser.jay"
{
if (yyVals[-2+yyTop] == null)
break;
OperatorDeclaration decl = (OperatorDeclaration) yyVals[-2+yyTop];
Operator op = new Operator (
current_class, decl.optype, decl.ret_type, (Modifiers) yyVals[-3+yyTop],
current_local_parameters,
(ToplevelBlock) yyVals[0+yyTop], (Attributes) yyVals[-4+yyTop], decl.location);
if (RootContext.Documentation != null) {
op.DocComment = tmpComment;
Lexer.doc_state = XmlCommentState.Allowed;
}
/* Note again, checking is done in semantic analysis*/
current_container.AddOperator (op);
current_local_parameters = null;
}
break;
case 242:
#line 1970 "cs-parser.jay"
{ yyVal = null; }
break;
case 244:
#line 1976 "cs-parser.jay"
{
Report.Error (590, GetLocation (yyVals[0+yyTop]), "User-defined operators cannot return void");
yyVal = TypeManager.system_void_expr;
}
break;
case 245:
#line 1984 "cs-parser.jay"
{
valid_param_mod = ParameterModifierType.DefaultValue;
}
示例7: Visit
public virtual void Visit (Operator o)
{
}
示例8: Binary
public Binary (Operator oper, Expression left, Expression right, bool isCompound)
: this (oper, left, right)
{
this.is_compound = isCompound;
}
示例9: PredefinedPointerOperator
public PredefinedPointerOperator (Type ltype, Type rtype, Operator op_mask, Type retType)
: base (ltype, rtype, op_mask, retType)
{
}
示例10: PredefinedShiftOperator
public PredefinedShiftOperator (Type ltype, Operator op_mask) :
base (ltype, TypeManager.int32_type, op_mask)
{
}
示例11: PredefinedStringOperator
public PredefinedStringOperator (Type ltype, Type rtype, Operator op_mask)
: base (ltype, rtype, op_mask)
{
ReturnType = TypeManager.string_type;
}
示例12: OperatorEntry
public OperatorEntry (int f, Operator o)
{
flags = f;
ret_type = o.OperatorMethod.GetReturnType ();
Type [] pt = o.OperatorMethod.ParameterTypes;
type1 = pt [0];
type2 = pt [1];
op = o;
ot = o.OperatorType;
}
示例13: OperName
/// <summary>
/// Returns a stringified representation of the Operator
/// </summary>
string OperName (Operator oper)
{
string s;
switch (oper){
case Operator.Multiply:
s = "*";
break;
case Operator.Division:
s = "/";
break;
case Operator.Modulus:
s = "%";
break;
case Operator.Addition:
s = "+";
break;
case Operator.Subtraction:
s = "-";
break;
case Operator.LeftShift:
s = "<<";
break;
case Operator.RightShift:
s = ">>";
break;
case Operator.LessThan:
s = "<";
break;
case Operator.GreaterThan:
s = ">";
break;
case Operator.LessThanOrEqual:
s = "<=";
break;
case Operator.GreaterThanOrEqual:
s = ">=";
break;
case Operator.Equality:
s = "==";
break;
case Operator.Inequality:
s = "!=";
break;
case Operator.BitwiseAnd:
s = "&";
break;
case Operator.BitwiseOr:
s = "|";
break;
case Operator.ExclusiveOr:
s = "^";
break;
case Operator.LogicalOr:
s = "||";
break;
case Operator.LogicalAnd:
s = "&&";
break;
default:
s = oper.ToString ();
break;
}
if (is_compound)
return s + "=";
return s;
}
示例14: AddOperator
public AdditionResult AddOperator (Operator op)
{
if (operators == null)
operators = new ArrayList ();
operators.Add (op);
return AdditionResult.Success;
}
示例15: Error_OperatorCannotBeApplied
public static void Error_OperatorCannotBeApplied (ResolveContext ec, Expression left, Expression right, Operator oper, Location loc)
{
new Binary (oper, left, right).Error_OperatorCannotBeApplied (ec, left, right);
}