summaryrefslogtreecommitdiff
path: root/src/util/array_store_all.h
blob: bccefdd58699350cc71a4f57803037ef69606a43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*********************                                                        */
/*! \file array_store_all.h
 ** \verbatim
 ** Original author: Morgan Deters
 ** Major contributors: none
 ** Minor contributors (to current version): none
 ** This file is part of the CVC4 project.
 ** Copyright (c) 2009-2014  New York University and The University of Iowa
 ** See the file COPYING in the top-level source directory for licensing
 ** information.\endverbatim
 **
 ** \brief Representation of a constant array (an array in which the
 ** element is the same for all indices)
 **
 ** Representation of a constant array (an array in which the element is
 ** the same for all indices).
 **/

#include "cvc4_public.h"

#pragma once

namespace CVC4 {
  // messy; Expr needs ArrayStoreAll (because it's the payload of a
  // CONSTANT-kinded expression), and ArrayStoreAll needs Expr.
  class CVC4_PUBLIC ArrayStoreAll;
}/* CVC4 namespace */

#include "expr/expr.h"
#include "expr/type.h"
#include <iostream>

namespace CVC4 {

class CVC4_PUBLIC ArrayStoreAll {
  const ArrayType d_type;
  const Expr d_expr;

public:

  ArrayStoreAll(ArrayType type, Expr expr) throw(IllegalArgumentException) :
    d_type(type),
    d_expr(expr) {

    // this check is stronger than the assertion check in the expr manager that ArrayTypes are actually array types
    // because this check is done in production builds too
    CheckArgument(type.isArray(), type, "array store-all constants can only be created for array types, not `%s'", type.toString().c_str());

    CheckArgument(expr.getType().isSubtypeOf(type.getConstituentType()), expr, "expr type `%s' does not match constituent type of array type `%s'", expr.getType().toString().c_str(), type.toString().c_str());
    CheckArgument(expr.isConst(), expr, "ArrayStoreAll requires a constant expression");
  }

  ~ArrayStoreAll() throw() {
  }

  ArrayType getType() const throw() {
    return d_type;
  }
  Expr getExpr() const throw() {
    return d_expr;
  }

  bool operator==(const ArrayStoreAll& asa) const throw() {
    return d_type == asa.d_type && d_expr == asa.d_expr;
  }
  bool operator!=(const ArrayStoreAll& asa) const throw() {
    return !(*this == asa);
  }

  bool operator<(const ArrayStoreAll& asa) const throw() {
    return d_type < asa.d_type ||
           (d_type == asa.d_type && d_expr < asa.d_expr);
  }
  bool operator<=(const ArrayStoreAll& asa) const throw() {
    return d_type < asa.d_type ||
           (d_type == asa.d_type && d_expr <= asa.d_expr);
  }
  bool operator>(const ArrayStoreAll& asa) const throw() {
    return !(*this <= asa);
  }
  bool operator>=(const ArrayStoreAll& asa) const throw() {
    return !(*this < asa);
  }

};/* class ArrayStoreAll */

std::ostream& operator<<(std::ostream& out, const ArrayStoreAll& asa) CVC4_PUBLIC;

/**
 * Hash function for the ArrayStoreAll constants.
 */
struct CVC4_PUBLIC ArrayStoreAllHashFunction {
  inline size_t operator()(const ArrayStoreAll& asa) const {
    return TypeHashFunction()(asa.getType()) * ExprHashFunction()(asa.getExpr());
  }
};/* struct ArrayStoreAllHashFunction */

}/* CVC4 namespace */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback