コード例 #1
0
        public void Visit(Ast.Expr.UnOp u)
        {
            Visit(u.Item.Lhs);
            u.ActualType = u.Item.Lhs.ActualType;
            // check if op is defined for type params
            var op = u.Item.Op;

            if (op.IsOpDecr || op.IsOpIncr || op.IsOpValNegate)
            {
                if (u.ActualType != Ast.Type.FloatType && u.ActualType != Ast.Type.IntType)
                {
                    m_errorList.Add("Type Error: Operator " + op + " is not defined for operand of type " +
                                    u.ActualType);
                }
            }
            else
            {
                if (u.ActualType != Ast.Type.BoolType)
                {
                    m_errorList.Add("Type Error: Operator " + op + " is not defined for operand of type " +
                                    u.ActualType);
                }
            }
        }
コード例 #2
0
 public void Visit(Ast.Expr.UnOp u)
 {
     Visit(u.Item.Lhs);
 }