1 /********************* */
2 /*! \file node_command.cpp
4 ** Top contributors (to current version):
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2020 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.\endverbatim
12 ** \brief Implementation of NodeCommand functions.
14 ** Implementation of NodeCommand functions.
17 #include "smt/node_command.h"
19 #include "printer/printer.h"
23 /* -------------------------------------------------------------------------- */
24 /* class NodeCommand */
25 /* -------------------------------------------------------------------------- */
27 NodeCommand::~NodeCommand() {}
29 std::string
NodeCommand::toString() const
36 std::ostream
& operator<<(std::ostream
& out
, const NodeCommand
& nc
)
39 Node::setdepth::getDepth(out
),
40 Node::dag::getDag(out
),
41 Node::setlanguage::getLanguage(out
));
45 /* -------------------------------------------------------------------------- */
46 /* class DeclareFunctionNodeCommand */
47 /* -------------------------------------------------------------------------- */
49 DeclareFunctionNodeCommand::DeclareFunctionNodeCommand(const std::string
& id
,
56 d_printInModelSetByUser(false)
60 void DeclareFunctionNodeCommand::toStream(std::ostream
& out
,
63 OutputLanguage language
) const
65 Printer::getPrinter(language
)->toStreamCmdDeclareFunction(out
, d_id
, d_type
);
68 NodeCommand
* DeclareFunctionNodeCommand::clone() const
70 return new DeclareFunctionNodeCommand(d_id
, d_fun
, d_type
);
73 const Node
& DeclareFunctionNodeCommand::getFunction() const { return d_fun
; }
75 bool DeclareFunctionNodeCommand::getPrintInModel() const
77 return d_printInModel
;
80 bool DeclareFunctionNodeCommand::getPrintInModelSetByUser() const
82 return d_printInModelSetByUser
;
85 void DeclareFunctionNodeCommand::setPrintInModel(bool p
)
88 d_printInModelSetByUser
= true;
91 /* -------------------------------------------------------------------------- */
92 /* class DeclareTypeNodeCommand */
93 /* -------------------------------------------------------------------------- */
95 DeclareTypeNodeCommand::DeclareTypeNodeCommand(const std::string
& id
,
98 : d_id(id
), d_arity(arity
), d_type(type
)
102 void DeclareTypeNodeCommand::toStream(std::ostream
& out
,
105 OutputLanguage language
) const
107 Printer::getPrinter(language
)->toStreamCmdDeclareType(
108 out
, d_id
, d_arity
, d_type
);
111 NodeCommand
* DeclareTypeNodeCommand::clone() const
113 return new DeclareTypeNodeCommand(d_id
, d_arity
, d_type
);
116 const std::string
DeclareTypeNodeCommand::getSymbol() const { return d_id
; }
118 const TypeNode
& DeclareTypeNodeCommand::getType() const { return d_type
; }
120 /* -------------------------------------------------------------------------- */
121 /* class DeclareDatatypeNodeCommand */
122 /* -------------------------------------------------------------------------- */
124 DeclareDatatypeNodeCommand::DeclareDatatypeNodeCommand(
125 const std::vector
<TypeNode
>& datatypes
)
126 : d_datatypes(datatypes
)
130 void DeclareDatatypeNodeCommand::toStream(std::ostream
& out
,
133 OutputLanguage language
) const
135 Printer::getPrinter(language
)->toStreamCmdDatatypeDeclaration(out
,
139 NodeCommand
* DeclareDatatypeNodeCommand::clone() const
141 return new DeclareDatatypeNodeCommand(d_datatypes
);
144 /* -------------------------------------------------------------------------- */
145 /* class DefineFunctionNodeCommand */
146 /* -------------------------------------------------------------------------- */
148 DefineFunctionNodeCommand::DefineFunctionNodeCommand(
149 const std::string
& id
,
151 const std::vector
<Node
>& formals
,
153 : d_id(id
), d_fun(fun
), d_formals(formals
), d_formula(formula
)
157 void DefineFunctionNodeCommand::toStream(std::ostream
& out
,
160 OutputLanguage language
) const
162 TypeNode tn
= d_fun
.getType();
164 (tn
.isFunction() || tn
.isConstructor() || tn
.isSelector());
165 Printer::getPrinter(language
)->toStreamCmdDefineFunction(
169 (hasRange
? d_fun
.getType().getRangeType() : tn
),
173 NodeCommand
* DefineFunctionNodeCommand::clone() const
175 return new DefineFunctionNodeCommand(d_id
, d_fun
, d_formals
, d_formula
);