Go to the documentation of this file.00001
00018 package com.microsoft.z3;
00019
00025 public class FuncInterp extends Z3Object
00026 {
00031 public class Entry extends Z3Object
00032 {
00039 public Expr getValue()
00040 {
00041 return Expr.create(getContext(),
00042 Native.funcEntryGetValue(getContext().nCtx(), getNativeObject()));
00043 }
00044
00049 public int getNumArgs()
00050 {
00051 return Native.funcEntryGetNumArgs(getContext().nCtx(), getNativeObject());
00052 }
00053
00060 public Expr[] getArgs()
00061 {
00062 int n = getNumArgs();
00063 Expr[] res = new Expr[n];
00064 for (int i = 0; i < n; i++)
00065 res[i] = Expr.create(getContext(), Native.funcEntryGetArg(
00066 getContext().nCtx(), getNativeObject(), i));
00067 return res;
00068 }
00069
00073 public String toString()
00074 {
00075 try
00076 {
00077 int n = getNumArgs();
00078 String res = "[";
00079 Expr[] args = getArgs();
00080 for (int i = 0; i < n; i++)
00081 res += args[i] + ", ";
00082 return res + getValue() + "]";
00083 } catch (Z3Exception e)
00084 {
00085 return new String("Z3Exception: " + e.getMessage());
00086 }
00087 }
00088
00089 Entry(Context ctx, long obj)
00090 {
00091 super(ctx, obj);
00092 }
00093
00094 void incRef(long o)
00095 {
00096 getContext().getFuncEntryDRQ().incAndClear(getContext(), o);
00097 super.incRef(o);
00098 }
00099
00100 void decRef(long o)
00101 {
00102 getContext().getFuncEntryDRQ().add(o);
00103 super.decRef(o);
00104 }
00105 };
00106
00112 public int getNumEntries()
00113 {
00114 return Native.funcInterpGetNumEntries(getContext().nCtx(), getNativeObject());
00115 }
00116
00123 public Entry[] getEntries()
00124 {
00125 int n = getNumEntries();
00126 Entry[] res = new Entry[n];
00127 for (int i = 0; i < n; i++)
00128 res[i] = new Entry(getContext(), Native.funcInterpGetEntry(getContext()
00129 .nCtx(), getNativeObject(), i));
00130 return res;
00131 }
00132
00140 public Expr getElse()
00141 {
00142 return Expr.create(getContext(),
00143 Native.funcInterpGetElse(getContext().nCtx(), getNativeObject()));
00144 }
00145
00151 public int getArity()
00152 {
00153 return Native.funcInterpGetArity(getContext().nCtx(), getNativeObject());
00154 }
00155
00159 public String toString()
00160 {
00161 try
00162 {
00163 String res = "";
00164 res += "[";
00165 for (Entry e : getEntries())
00166 {
00167 int n = e.getNumArgs();
00168 if (n > 1)
00169 res += "[";
00170 Expr[] args = e.getArgs();
00171 for (int i = 0; i < n; i++)
00172 {
00173 if (i != 0)
00174 res += ", ";
00175 res += args[i];
00176 }
00177 if (n > 1)
00178 res += "]";
00179 res += " -> " + e.getValue() + ", ";
00180 }
00181 res += "else -> " + getElse();
00182 res += "]";
00183 return res;
00184 } catch (Z3Exception e)
00185 {
00186 return new String("Z3Exception: " + e.getMessage());
00187 }
00188 }
00189
00190 FuncInterp(Context ctx, long obj)
00191 {
00192 super(ctx, obj);
00193 }
00194
00195 void incRef(long o)
00196 {
00197 getContext().getFuncInterpDRQ().incAndClear(getContext(), o);
00198 super.incRef(o);
00199 }
00200
00201 void decRef(long o)
00202 {
00203 getContext().getFuncInterpDRQ().add(o);
00204 super.decRef(o);
00205 }
00206 }