本文整理汇总了C#中Boo.Lang.Compiler.Ast.BinaryExpression类的典型用法代码示例。如果您正苦于以下问题:C# BinaryExpression类的具体用法?C# BinaryExpression怎么用?C# BinaryExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BinaryExpression类属于Boo.Lang.Compiler.Ast命名空间,在下文中一共展示了BinaryExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LeaveBinaryExpression
public override void LeaveBinaryExpression(BinaryExpression node)
{
if (IsAssignmentToSpecialMember(node))
{
ProcessAssignmentToSpecialMember(node);
}
}
示例2: ComparisonFor
public static Expression ComparisonFor(Expression local, IEnumerable<Expression> expressions)
{
BinaryExpression expression;
IEnumerator<Expression> enumerator = expressions.GetEnumerator();
if (!enumerator.MoveNext())
{
throw new AssertionFailedException("e.MoveNext()");
}
BinaryExpression expression1 = expression = new BinaryExpression(LexicalInfo.Empty);
expression.set_Operator(11);
expression.set_Left(Expression.Lift(local));
expression.set_Right(Expression.Lift(enumerator.Current));
Expression expression2 = expression;
while (enumerator.MoveNext())
{
BinaryExpression expression3;
BinaryExpression expression4;
BinaryExpression expression11 = expression4 = new BinaryExpression(LexicalInfo.Empty);
expression4.set_Operator(0x1c);
expression4.set_Left(Expression.Lift(expression2));
BinaryExpression expression12 = expression3 = new BinaryExpression(LexicalInfo.Empty);
expression3.set_Operator(11);
expression3.set_Left(Expression.Lift(local));
expression3.set_Right(Expression.Lift(enumerator.Current));
expression4.set_Right(expression3);
expression2 = expression4;
}
return expression2;
}
示例3: AddDependency
protected virtual void AddDependency(ArrayLiteralExpression dependencies, BinaryExpression binaryExpression)
{
StringLiteralExpression dependency;
//HACK: replace with proper AST method invocation
if (binaryExpression.Left is StringLiteralExpression)
{
dependency = new StringLiteralExpression(string.Format("{0}|{1}",
binaryExpression.Left.ToString().Trim('\''),
binaryExpression.Right.ToString().Trim('\'')));
}
else if(binaryExpression.Left is BinaryExpression)
{
var left = (BinaryExpression) binaryExpression.Left;
var package = left.Left.ToString().Trim('\'');
var version = left.Right.ToString().Trim('\'');
var dll = binaryExpression.Right.ToString().Trim('\'');
dependency = new StringLiteralExpression(string.Format("{0}|{1}|{2}",
package,
dll,
version));
}
else
throw new ArgumentOutOfRangeException(string.Format("Unknown Expression type {0} passed to RightShiftToMethodCompilerStep.AddDependency", binaryExpression.Left.GetType().Name));
dependencies.Items.Add(dependency);
}
示例4: ExpandImpl
protected override Statement ExpandImpl(MacroStatement macro){
var result = new Block();
foreach (Statement st in macro.Body.Statements){
var decl = st as DeclarationStatement;
var refer = st as ExpressionStatement;
if(null==decl){
var ex = refer.Expression;
if (ex is MethodInvocationExpression){
decl =
new DeclarationStatement(
new Declaration(((MethodInvocationExpression) refer.Expression).Target.ToCodeString(),
null), null);
}
if(ex is BinaryExpression){
var b = ex as BinaryExpression;
decl = new DeclarationStatement(
new Declaration(b.Left.ToCodeString(),null),b.Right
);
}
}
var bin = new BinaryExpression(BinaryOperatorType.Assign,
new TryCastExpression(new ReferenceExpression(decl.Declaration.Name),
decl.Declaration.Type),
decl.Initializer);
var def = new MacroStatement("definebrailproperty");
def.Arguments.Add(bin);
result.Add(def);
}
return result;
}
示例5: LeaveBinaryExpression
public override void LeaveBinaryExpression(BinaryExpression node)
{
if (CheckExpressionType(node.Right))
CheckExpressionType(node.Left);
if (BinaryOperatorType.ReferenceEquality == node.Operator)
{
if (IsTypeReference(node.Right))
{
Warnings.Add(
CompilerWarningFactory.IsInsteadOfIsa(node));
}
}
//check that the assignment or comparison is meaningful
if (BinaryOperatorType.Assign == node.Operator
|| AstUtil.GetBinaryOperatorKind(node) == BinaryOperatorKind.Comparison)
{
if (AreSameExpressions(node.Left, node.Right))
{
Warnings.Add(
(BinaryOperatorType.Assign == node.Operator)
? CompilerWarningFactory.AssignmentToSameVariable(node)
: CompilerWarningFactory.ComparisonWithSameVariable(node)
);
}
else if (BinaryOperatorType.Assign != node.Operator
&& AreConstantExpressions(node.Left, node.Right))
{
WarnAboutConstantExpression(node);
}
}
}
示例6: ProcessAssignment
override protected void ProcessAssignment(BinaryExpression node)
{
if (TypeSystemServices.IsQuackBuiltin(node.Left.Entity))
BindDuck(node);
else
ProcessStaticallyTypedAssignment(node);
}
示例7: LeaveBinaryExpression
public override void LeaveBinaryExpression(BinaryExpression node)
{
if (BinaryOperatorType.Assign == node.Operator
&& (node.Right.NodeType != NodeType.TryCastExpression)
&& (IsTopLevelOfConditional(node)))
{
Warnings.Add(CompilerWarningFactory.EqualsInsteadOfAssign(node));
}
}
示例8: LeaveBinaryExpression
public override void LeaveBinaryExpression(BinaryExpression node)
{
if (BinaryOperatorType.Assign != node.Operator)
return;
Expression newRight = Convert(node.Left.ExpressionType, node.Right);
if (null != newRight)
node.Right = newRight;
}
示例9: MethodInvocationForEventSubscription
private MethodInvocationExpression MethodInvocationForEventSubscription(BinaryExpression node, IMethod method)
{
var methodTarget = CodeBuilder.CreateMemberReference(node.Left.LexicalInfo,
((MemberReferenceExpression)node.Left).Target, method);
var mie = new MethodInvocationExpression(methodTarget);
mie.Arguments.Add(node.Right);
BindExpressionType(mie, method.ReturnType);
return mie;
}
示例10: LeaveBinaryExpression
public override void LeaveBinaryExpression(BinaryExpression node)
{
switch (node.Operator)
{
case BinaryOperatorType.And:
case BinaryOperatorType.Or:
BindLogicalOperator(node);
break;
}
}
示例11: OnBinaryExpression
public override void OnBinaryExpression(BinaryExpression node)
{
var lhs = node.Left.ExpressionType;
var rhs = node.Right.ExpressionType;
base.OnBinaryExpression(node);
var expression = GetLinqExpressionForOperator(node.Operator);
ReplaceCurrentNode(new MethodInvocationExpression(
ReferenceExpression.Lift(expression),
AddOptionalConvert(rhs, lhs, node.Left),
AddOptionalConvert(lhs, rhs, node.Right)));
}
示例12: OnBinaryExpression
public override void OnBinaryExpression(BinaryExpression node)
{
base.OnBinaryExpression(node);
BinaryOperatorType type = node.get_Operator();
if (((type == 0x1f) || (type == 30)) && (this.IsBoolean(node.get_Left()) && this.IsBoolean(node.get_Right())))
{
string[] strArray = (node.get_Operator() != 0x1f) ? new string[] { "||", "|" } : new string[] { "&&", "&" };
string expectedOperator = strArray[0];
string actualOperator = strArray[1];
this.get_Warnings().Add(UnityScriptWarnings.BitwiseOperatorWithBooleanOperands(node.get_LexicalInfo(), expectedOperator, actualOperator));
}
}
示例13: IsAssignmentToSpecialMember
protected bool IsAssignmentToSpecialMember(BinaryExpression node)
{
if (BinaryOperatorType.Assign == node.Operator &&
NodeType.MemberReferenceExpression == node.Left.NodeType)
{
MemberReferenceExpression memberRef = node.Left as MemberReferenceExpression;
Expression target = memberRef.Target;
return !IsTerminalReferenceNode(target)
&& IsSpecialMemberTarget(target);
}
return false;
}
示例14: OnBinaryExpression
public override void OnBinaryExpression(BinaryExpression node)
{
if (acceptImplicit) {
ReferenceExpression reference = node.Left as ReferenceExpression;
if (node.Operator == BinaryOperatorType.Assign && reference != null) {
if (!(reference is MemberReferenceExpression)) {
DeclarationFound(reference.Name, null, node.Right, reference.LexicalInfo);
}
}
}
base.OnBinaryExpression(node);
}
示例15: LeaveBinaryExpression
public override void LeaveBinaryExpression(BinaryExpression node)
{
CheckExpressionType(node.Right);
if (BinaryOperatorType.ReferenceEquality == node.Operator)
{
if (IsTypeReference(node.Right))
{
Warnings.Add(
CompilerWarningFactory.IsInsteadOfIsa(node));
}
}
}