Go to the documentation of this file.00001
00018 package com.microsoft.z3;
00019
00023 public class Constructor extends Z3Object
00024 {
00031 public int getNumFields()
00032 {
00033 return n;
00034 }
00035
00041 public FuncDecl ConstructorDecl()
00042 {
00043 Native.LongPtr constructor = new Native.LongPtr();
00044 Native.LongPtr tester = new Native.LongPtr();
00045 long[] accessors = new long[n];
00046 Native.queryConstructor(getContext().nCtx(), getNativeObject(), n, constructor, tester, accessors);
00047 return new FuncDecl(getContext(), constructor.value);
00048 }
00049
00055 public FuncDecl getTesterDecl()
00056 {
00057 Native.LongPtr constructor = new Native.LongPtr();
00058 Native.LongPtr tester = new Native.LongPtr();
00059 long[] accessors = new long[n];
00060 Native.queryConstructor(getContext().nCtx(), getNativeObject(), n, constructor, tester, accessors);
00061 return new FuncDecl(getContext(), tester.value);
00062 }
00063
00069 public FuncDecl[] getAccessorDecls()
00070 {
00071 Native.LongPtr constructor = new Native.LongPtr();
00072 Native.LongPtr tester = new Native.LongPtr();
00073 long[] accessors = new long[n];
00074 Native.queryConstructor(getContext().nCtx(), getNativeObject(), n, constructor, tester, accessors);
00075 FuncDecl[] t = new FuncDecl[n];
00076 for (int i = 0; i < n; i++)
00077 t[i] = new FuncDecl(getContext(), accessors[i]);
00078 return t;
00079 }
00080
00085 protected void finalize()
00086 {
00087 Native.delConstructor(getContext().nCtx(), getNativeObject());
00088 }
00089
00090 private int n = 0;
00091
00092 Constructor(Context ctx, Symbol name, Symbol recognizer,
00093 Symbol[] fieldNames, Sort[] sorts, int[] sortRefs)
00094
00095 {
00096 super(ctx);
00097
00098 n = AST.arrayLength(fieldNames);
00099
00100 if (n != AST.arrayLength(sorts))
00101 throw new Z3Exception(
00102 "Number of field names does not match number of sorts");
00103 if (sortRefs != null && sortRefs.length != n)
00104 throw new Z3Exception(
00105 "Number of field names does not match number of sort refs");
00106
00107 if (sortRefs == null)
00108 sortRefs = new int[n];
00109
00110 setNativeObject(Native.mkConstructor(ctx.nCtx(), name.getNativeObject(),
00111 recognizer.getNativeObject(), n, Symbol.arrayToNative(fieldNames),
00112 Sort.arrayToNative(sorts), sortRefs));
00113
00114 }
00115 }