-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSymbol.java
More file actions
81 lines (73 loc) · 2.06 KB
/
Symbol.java
File metadata and controls
81 lines (73 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
* This file was automatically generated from Symbol.cs
* w/ further modifications by:
* @author Christoph M. Wintersteiger (cwinter)
**/
package com.microsoft.z3;
import com.microsoft.z3.enumerations.Z3_symbol_kind;
/**
* Symbols are used to name several term and type constructors.
**/
public class Symbol extends Z3Object
{
/**
* The kind of the symbol (int or string)
**/
protected Z3_symbol_kind getKind() throws Z3Exception
{
return Z3_symbol_kind.fromInt(Native.getSymbolKind(getContext().nCtx(),
getNativeObject()));
}
/**
* Indicates whether the symbol is of Int kind
**/
public boolean isIntSymbol() throws Z3Exception
{
return getKind() == Z3_symbol_kind.Z3_INT_SYMBOL;
}
/**
* Indicates whether the symbol is of string kind.
**/
public boolean isStringSymbol() throws Z3Exception
{
return getKind() == Z3_symbol_kind.Z3_STRING_SYMBOL;
}
/**
* A string representation of the symbol.
**/
public String toString()
{
try
{
if (isIntSymbol())
return Integer.toString(((IntSymbol) this).getInt());
else if (isStringSymbol())
return ((StringSymbol) this).getString();
else
return new String(
"Z3Exception: Unknown symbol kind encountered.");
} catch (Z3Exception ex)
{
return new String("Z3Exception: " + ex.getMessage());
}
}
/**
* Symbol constructor
**/
protected Symbol(Context ctx, long obj) throws Z3Exception
{
super(ctx, obj);
}
static Symbol create(Context ctx, long obj) throws Z3Exception
{
switch (Z3_symbol_kind.fromInt(Native.getSymbolKind(ctx.nCtx(), obj)))
{
case Z3_INT_SYMBOL:
return new IntSymbol(ctx, obj);
case Z3_STRING_SYMBOL:
return new StringSymbol(ctx, obj);
default:
throw new Z3Exception("Unknown symbol kind encountered");
}
}
}