GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/expr/dtype_selector.h Lines: 1 1 100.0 %
Date: 2021-08-17 Branches: 3 6 50.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Morgan Deters, Tim King
4
 *
5
 * This file is part of the cvc5 project.
6
 *
7
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
8
 * in the top-level source directory and their institutional affiliations.
9
 * All rights reserved.  See the file COPYING in the top-level source
10
 * directory for licensing information.
11
 * ****************************************************************************
12
 *
13
 * A class representing a datatype selector.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__EXPR__DTYPE_SELECTOR_H
19
#define CVC5__EXPR__DTYPE_SELECTOR_H
20
21
#include <string>
22
#include "expr/node.h"
23
#include "expr/type_node.h"
24
25
namespace cvc5 {
26
27
class DatatypeConstructorArg;
28
class DType;
29
class DTypeConstructor;
30
31
/**
32
 * A datatype selector for a constructor argument (i.e., a datatype field).
33
 */
34
21306
class DTypeSelector
35
{
36
  friend class DatatypeConstructorArg;
37
  friend class DTypeConstructor;
38
  friend class DType;
39
40
 public:
41
  /** constructor */
42
  DTypeSelector(std::string name, Node selector, Node updater);
43
44
  /** Get the name of this constructor argument. */
45
  const std::string& getName() const;
46
47
  /**
48
   * Get the selector for this constructor argument; this call is
49
   * only permitted after resolution.
50
   */
51
  Node getSelector() const;
52
  /**
53
   * Get the upater for this constructor argument; this call is
54
   * only permitted after resolution.
55
   */
56
  Node getUpdater() const;
57
58
  /**
59
   * Get the associated constructor for this constructor argument;
60
   * this call is only permitted after resolution.
61
   */
62
  Node getConstructor() const;
63
64
  /**
65
   * Get the type of the selector for this constructor argument.
66
   */
67
  TypeNode getType() const;
68
69
  /**
70
   * Get the range type of this argument.
71
   */
72
  TypeNode getRangeType() const;
73
74
  /**
75
   * Returns true iff this constructor argument has been resolved.
76
   */
77
  bool isResolved() const;
78
79
  /** prints this datatype constructor argument to stream */
80
  void toStream(std::ostream& out) const;
81
82
 private:
83
  /** the name of this selector */
84
  std::string d_name;
85
  /** the selector expression */
86
  Node d_selector;
87
  /** the updater expression */
88
  Node d_updater;
89
  /**
90
   * The constructor associated with this selector. This field is initialized
91
   * by the constructor of this selector during a call to
92
   * DTypeConstructor::resolve.
93
   */
94
  Node d_constructor;
95
  /** whether this class has been resolved */
96
  bool d_resolved;
97
};
98
99
std::ostream& operator<<(std::ostream& os, const DTypeSelector& arg);
100
101
}  // namespace cvc5
102
103
#endif