A set of benchmarks to compare a new prototype MiniZinc implementation
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
3/*
4 * Main authors:
5 * Guido Tack <guido.tack@monash.edu>
6 */
7
8/* This Source Code Form is subject to the terms of the Mozilla Public
9 * License, v. 2.0. If a copy of the MPL was not distributed with this
10 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
11
12#ifndef __MINIZINC_COPY_HH__
13#define __MINIZINC_COPY_HH__
14
15#include <minizinc/model.hh>
16
17namespace MiniZinc {
18
19class CopyMap {
20protected:
21 typedef std::unordered_map<Model*, Model*> ModelMap;
22 ModelMap model_m;
23
24 ASTNodeWeakMap node_m;
25
26public:
27 void insert(Expression* e0, Expression* e1);
28 Expression* find(Expression* e);
29 void insert(Item* e0, Item* e1);
30 Item* find(Item* e);
31 void insert(Model* e0, Model* e1);
32 Model* find(Model* e);
33 void insert(const ASTString& e0, const ASTString& e1);
34 ASTStringO* find(const ASTString& e);
35 void insert(IntSetVal* e0, IntSetVal* e1);
36 IntSetVal* find(IntSetVal* e);
37 void insert(FloatSetVal* e0, FloatSetVal* e1);
38 FloatSetVal* find(FloatSetVal* e);
39 template <class T>
40 void insert(ASTExprVec<T> e0, ASTExprVec<T> e1) {
41 node_m.insert(e0.vec(), e1.vec());
42 }
43 template <class T>
44 ASTExprVecO<T*>* find(ASTExprVec<T> e) {
45 ASTNode* n = node_m.find(e.vec());
46 return static_cast<ASTExprVecO<T*>*>(n);
47 }
48 void clear() {
49 model_m.clear();
50 node_m.clear();
51 }
52};
53
54/// Create a deep copy of expression \a e
55Expression* copy(EnvI& env, Expression* e, bool followIds = false, bool copyFundecls = false,
56 bool isFlatModel = false);
57/// Create a deep copy of item \a i
58Item* copy(EnvI& env, Item* i, bool followIds = false, bool copyFundecls = false,
59 bool isFlatModel = false);
60/// Create a deep copy of model \a m
61Model* copy(EnvI& env, Model* m);
62
63/// Create a deep copy of expression \a e
64Expression* copy(EnvI& env, CopyMap& map, Expression* e, bool followIds = false,
65 bool copyFundecls = false, bool isFlatModel = false);
66/// Create a deep copy of item \a i
67Item* copy(EnvI& env, CopyMap& map, Item* i, bool followIds = false, bool copyFundecls = false,
68 bool isFlatModel = false);
69/// Create a deep copy of model \a m
70Model* copy(EnvI& env, CopyMap& map, Model* m, bool isFlatModel = false);
71
72} // namespace MiniZinc
73
74#endif