1/* BEGIN LICENSE BLOCK
2 * Version: CMPL 1.1
3 *
4 * The contents of this file are subject to the Cisco-style Mozilla Public
5 * License Version 1.1 (the "License"); you may not use this file except
6 * in compliance with the License.  You may obtain a copy of the License
7 * at www.eclipse-clp.org/license.
8 *
9 * Software distributed under the License is distributed on an "AS IS"
10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See
11 * the License for the specific language governing rights and limitations
12 * under the License.
13 *
14 * The Original Code is  The ECLiPSe Constraint Logic Programming System.
15 * The Initial Developer of the Original Code is  Cisco Systems, Inc.
16 * Portions created by the Initial Developer are
17 * Copyright (C) 2006 Cisco Systems, Inc.  All Rights Reserved.
18 *
19 * Contributor(s): Pascal Brisset
20 *
21 * END LICENSE BLOCK */
22// $Id: stdecil.h,v 1.1 2006/09/23 01:54:05 snovello Exp $
23
24#ifndef STDECIL_H
25#define STDECIL_H
26
27#include <iostream.h>
28#include <assert.h>
29#include <eclipseclass.h>
30#include <ilsolver/ilcint.h>
31#include <ilsolver/ilcfloat.h>
32
33#include <error.h>
34#define INSTANTIATION_FAULT -4
35#define Error(x) return(x)
36
37#ifdef DEBUG
38#define Assert(x, msg) if (!(x)) { ec_panic(msg, __FILE__) ;}
39#define DTrace(x) { cout << x << endl; }
40#else
41#define DTrace(x)
42#define Assert(x, msg)
43#endif
44
45
46extern t_ext_type *intvar_method;
47extern IlcManager m;
48extern IlcIntExp zero;
49
50inline EC_word
51EC_argument(EC_word t, int i)
52{
53  EC_word e;
54  int x = t.arg(i, e);
55  assert(x == EC_succeed);
56  return e;
57}
58
59extern "C" trail_undo(pword* p, void(*f)(pword*));
60
61
62#define ReturnTryPushTrailCatchPop(to_do, handle) \
63  try { \
64    m.pushState(); \
65    to_do;      \
66    trail_undo(handle, ilog_fail); \
67    return EC_succeed; \
68  } \
69  catch (IlcFailException) { \
70    m.popState();   \
71    return EC_fail; \
72  }
73
74extern void ilog_fail(pword *);
75
76#endif
77
78