示例#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);
                }
            }
        }
示例#2
0
 public override void Visit(BinOpExpression expression)
 {
     throw new NotImplementedException();
 }
示例#3
0
 public abstract void Visit(BinOpExpression expression);