Example #1
0
 public override void AfterVisit(UnaryExpression node)
 {
     switch (node.Operator.Operation)
     {
         case OperationKind.Not:
             _expressionStack.Push(node, Expression.MakeUnary(ToExpressionType(node.Operator), Expression.Convert(_expressionStack.Pop(), typeof(bool)), typeof(object)));
             break;
         default:
             throw new UnhandledCaseException("Semantic checking should have prevented this unhandled case");
     }
     base.AfterVisit(node);
 }
Example #2
0
 public override void BeforeVisit(UnaryExpression expression)
 {
     base.BeforeVisit(expression);
     switch(expression.Operator.Operation)
     {
     case OperationKind.Not:
         break;
     default:
         _errorCollector.OperatorIsNotUnary(expression.Location, expression.Operator.ToString());
         break;
     }
 }
Example #3
0
 public virtual void BeforeVisit(UnaryExpression node)
 {
     this.BeforeVisitCatchAll(node);
 }
Example #4
0
 public virtual void AfterVisit(UnaryExpression node)
 {
     this.AfterVisitCatchAll(node);
 }
Example #5
0
        private ExpressionNodeBase RecurseExp(Stack<AstNodeBase> expStack)
        {
            ExpressionNodeBase retval;

            //If there was only one item in the stack, then we must be parsing
            //an expression (or part of an expression) with only a single term.
            if (expStack.Count == 1)
                retval = (ExpressionNodeBase)expStack.Pop();
            else
            {
                ExpressionNodeBase rval;
                AstNodeBase node = expStack.Pop();
                if (!(node is Operator))
                    _errorCollector.ExpectedOperator(node.Location);

                Operator oper = (Operator)node;
                if (expStack.Peek() is Operator)
                    rval = this.RecurseExp(expStack);
                else
                    rval = expStack.Pop() as ExpressionNodeBase;

                if (oper.IsUnary)
                    retval = new UnaryExpression(rval, oper);
                else
                {
                    //DebugAssert.IsNonZero(expStack.Count, "expStack.Count == 0");
                    if(expStack.Count == 0)
                        _errorCollector.SyntaxErrorInExpression(rval.Location);

                    ExpressionNodeBase lval;
                    if(expStack.Peek() is Operator)
                        lval = this.RecurseExp(expStack);
                    else
                        lval = expStack.Pop() as ExpressionNodeBase;

                    retval = new BinaryExpression(lval, oper, rval);
                }
            }
            return retval;
        }