| 927 | |
| 928 | #ifdef GECODE_HAS_SET_VARS |
| 929 | void |
| 930 | FlatZincSpace::newSetVar(SetVarSpec* vs) { |
| 931 | if (vs->alias) { |
| 932 | sv[setVarCount++] = sv[vs->i]; |
| 933 | } else if (vs->assigned) { |
| 934 | assert(vs->upperBound()); |
| 935 | AST::SetLit* vsv = vs->upperBound.some(); |
| 936 | if (vsv->interval) { |
| 937 | IntSet d(vsv->min, vsv->max); |
| 938 | sv[setVarCount++] = SetVar(*this, d, d); |
| 939 | } else { |
| 940 | int* is = heap.alloc<int>(static_cast<unsigned long int>(vsv->s.size())); |
| 941 | for (int i=vsv->s.size(); i--; ) |
| 942 | is[i] = vsv->s[i]; |
| 943 | IntSet d(is, vsv->s.size()); |
| 944 | heap.free(is,static_cast<unsigned long int>(vsv->s.size())); |
| 945 | sv[setVarCount++] = SetVar(*this, d, d); |
| 946 | } |
| 947 | } else if (vs->upperBound()) { |
| 948 | AST::SetLit* vsv = vs->upperBound.some(); |
| 949 | if (vsv->interval) { |
| 950 | IntSet d(vsv->min, vsv->max); |
| 951 | sv[setVarCount++] = SetVar(*this, IntSet::empty, d); |
| 952 | } else { |
| 953 | int* is = heap.alloc<int>(static_cast<unsigned long int>(vsv->s.size())); |
| 954 | for (int i=vsv->s.size(); i--; ) |
| 955 | is[i] = vsv->s[i]; |
| 956 | IntSet d(is, vsv->s.size()); |
| 957 | heap.free(is,static_cast<unsigned long int>(vsv->s.size())); |
| 958 | sv[setVarCount++] = SetVar(*this, IntSet::empty, d); |
| 959 | } |
| 960 | } else { |
| 961 | sv[setVarCount++] = SetVar(*this, IntSet::empty, |
| 962 | IntSet(Set::Limits::min, |
| 963 | Set::Limits::max)); |
| 964 | } |
| 965 | sv_introduced[2*(setVarCount-1)] = vs->introduced; |
| 966 | sv_introduced[2*(setVarCount-1)+1] = vs->funcDep; |
| 967 | } |
| 968 | #else |
| 969 | void |
| 970 | FlatZincSpace::newSetVar(SetVarSpec*) { |