36 lines
708 B
C++

#include "stmt.hh"
#include <cassert>
#include <utility>
Stmt::Stmt(StmtType type, StmtVariant value) : type{type}, value{value} {}
// Copy constructor
Stmt::Stmt(const Stmt &other) : type{other.type}, value{other.value} {}
// Move constructor
Stmt::Stmt(Stmt &&other) noexcept : type{other.type}, value{std::move(other.value)} {}
// Copy assignment
Stmt &Stmt::operator=(const Stmt &other) {
if (this == &other) {
return *this;
}
type = other.type;
value = other.value;
return *this;
}
// Move assignment
Stmt &Stmt::operator=(Stmt &&other) noexcept {
if (this == &other) {
return *this;
}
type = std::move(other.type);
value = std::move(other.value);
return *this;
}