1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
Jip J. Dekker f2a1c4e389 Squashed 'software/mza/' content from commit f970a59b17
git-subtree-dir: software/mza
git-subtree-split: f970a59b177c13ca3dd8aaef8cc6681d83b7e813
2021-07-11 16:34:30 +10:00

75 lines
2.2 KiB
C++

/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Guido Tack <guido.tack@monash.edu>
*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __MINIZINC_COPY_HH__
#define __MINIZINC_COPY_HH__
#include <minizinc/model.hh>
namespace MiniZinc {
class CopyMap {
protected:
typedef std::unordered_map<Model*, Model*> ModelMap;
ModelMap model_m;
ASTNodeWeakMap node_m;
public:
void insert(Expression* e0, Expression* e1);
Expression* find(Expression* e);
void insert(Item* e0, Item* e1);
Item* find(Item* e);
void insert(Model* e0, Model* e1);
Model* find(Model* e);
void insert(const ASTString& e0, const ASTString& e1);
ASTStringO* find(const ASTString& e);
void insert(IntSetVal* e0, IntSetVal* e1);
IntSetVal* find(IntSetVal* e);
void insert(FloatSetVal* e0, FloatSetVal* e1);
FloatSetVal* find(FloatSetVal* e);
template <class T>
void insert(ASTExprVec<T> e0, ASTExprVec<T> e1) {
node_m.insert(e0.vec(), e1.vec());
}
template <class T>
ASTExprVecO<T*>* find(ASTExprVec<T> e) {
ASTNode* n = node_m.find(e.vec());
return static_cast<ASTExprVecO<T*>*>(n);
}
void clear() {
model_m.clear();
node_m.clear();
}
};
/// Create a deep copy of expression \a e
Expression* copy(EnvI& env, Expression* e, bool followIds = false, bool copyFundecls = false,
bool isFlatModel = false);
/// Create a deep copy of item \a i
Item* copy(EnvI& env, Item* i, bool followIds = false, bool copyFundecls = false,
bool isFlatModel = false);
/// Create a deep copy of model \a m
Model* copy(EnvI& env, Model* m);
/// Create a deep copy of expression \a e
Expression* copy(EnvI& env, CopyMap& map, Expression* e, bool followIds = false,
bool copyFundecls = false, bool isFlatModel = false);
/// Create a deep copy of item \a i
Item* copy(EnvI& env, CopyMap& map, Item* i, bool followIds = false, bool copyFundecls = false,
bool isFlatModel = false);
/// Create a deep copy of model \a m
Model* copy(EnvI& env, CopyMap& map, Model* m, bool isFlatModel = false);
} // namespace MiniZinc
#endif