29 super(ctx, nativeObj);
51 Native.LongPtr constructor =
new Native.LongPtr();
52 Native.LongPtr tester =
new Native.LongPtr();
53 long[] accessors =
new long[n];
54 Native.queryConstructor(getContext().nCtx(), getNativeObject(), n, constructor, tester, accessors);
55 return new FuncDecl<>(getContext(), constructor.value);
65 Native.LongPtr constructor =
new Native.LongPtr();
66 Native.LongPtr tester =
new Native.LongPtr();
67 long[] accessors =
new long[n];
68 Native.queryConstructor(getContext().nCtx(), getNativeObject(), n, constructor, tester, accessors);
69 return new FuncDecl<>(getContext(), tester.value);
79 Native.LongPtr constructor =
new Native.LongPtr();
80 Native.LongPtr tester =
new Native.LongPtr();
81 long[] accessors =
new long[n];
82 Native.queryConstructor(getContext().nCtx(), getNativeObject(), n, constructor, tester, accessors);
84 for (
int i = 0; i < n; i++)
85 t[i] =
new FuncDecl<>(getContext(), accessors[i]);
95 void addToReferenceQueue() {
96 getContext().getReferenceQueue().storeReference(
this, ConstructorRef::new);
99 static <R> Constructor<R> of(Context ctx, Symbol name, Symbol recognizer,
100 Symbol[] fieldNames, Sort[] sorts,
int[] sortRefs) {
101 int n = AST.arrayLength(fieldNames);
103 if (n != AST.arrayLength(sorts))
104 throw new Z3Exception(
105 "Number of field names does not match number of sorts");
106 if (sortRefs !=
null && sortRefs.length != n)
107 throw new Z3Exception(
108 "Number of field names does not match number of sort refs");
110 if (sortRefs ==
null)
111 sortRefs =
new int[n];
113 long nativeObj = Native.mkConstructor(ctx.nCtx(), name.getNativeObject(),
114 recognizer.getNativeObject(), n, Symbol.arrayToNative(fieldNames),
115 Sort.arrayToNative(sorts), sortRefs);
116 return new Constructor<>(ctx, n, nativeObj);
120 private static class ConstructorRef
extends Z3ReferenceQueue.Reference<Constructor<?>> {
122 private ConstructorRef(Constructor<?> referent, ReferenceQueue<Z3Object> q) {
127 void decRef(Context ctx,
long z3Obj) {
128 Native.delConstructor(ctx.nCtx(), z3Obj);