Exemplo n.º 1
0
        public override void Visit(BinOpExpression expression)
        {
            expression.Left.AcceptVisitor(this);
            var type1 = ResultType;
            expression.Right.AcceptVisitor(this);
            var type2 = ResultType;

            if (expression.Operation == BinOps.Add ||
                expression.Operation == BinOps.Div ||
                expression.Operation == BinOps.Mul ||
                expression.Operation == BinOps.Sub)
            {
                if (type1 == typeof (int))
                {
                    if(type2 == typeof(long))
                        throw new InvalidProgramException("Operation types are invalid");

                    ResultType = typeof (int);
                }
                else if (type1 == typeof (long))
                {
                    if (type2 == typeof (int))
                        throw new InvalidProgramException("Operation types are invalid");

                    ResultType = typeof (long);
                }
            }
        }
Exemplo n.º 2
0
 public override void Visit(BinOpExpression expression)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 3
0
 public abstract void Visit(BinOpExpression expression);