diff options
author | Abdalrhman Mohamed <32971963+abdoo8080@users.noreply.github.com> | 2021-11-11 16:01:24 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-11 22:01:24 +0000 |
commit | 860164fa178cd8fa848ce3796c242fdde5838650 (patch) | |
tree | 9b5d8069b9fcf23e9b3cb9ba5e7cb9c1e44aaa14 /src/api/java | |
parent | 7867526e7070de52db36b1a2988d31ebadecf8b0 (diff) |
Add an API method to get the raw name of a term. (#7618)
Diffstat (limited to 'src/api/java')
-rw-r--r-- | src/api/java/io/github/cvc5/api/Term.java | 21 | ||||
-rw-r--r-- | src/api/java/jni/term.cpp | 30 |
2 files changed, 51 insertions, 0 deletions
diff --git a/src/api/java/io/github/cvc5/api/Term.java b/src/api/java/io/github/cvc5/api/Term.java index bbed609f7..fc09767ed 100644 --- a/src/api/java/io/github/cvc5/api/Term.java +++ b/src/api/java/io/github/cvc5/api/Term.java @@ -201,6 +201,27 @@ public class Term extends AbstractPointer implements Comparable<Term>, Iterable< private native long getOp(long pointer); /** + * @return true if the term has a symbol. + */ + public boolean hasSymbol() + { + return hasSymbol(pointer); + } + + private native boolean hasSymbol(long pointer); + + /** + * Asserts hasSymbol(). + * @return the raw symbol of the term. + */ + public String getSymbol() + { + return getSymbol(pointer); + } + + private native String getSymbol(long pointer); + + /** * @return true if this Term is a null term */ public boolean isNull() diff --git a/src/api/java/jni/term.cpp b/src/api/java/jni/term.cpp index d54b0a2b5..702a5064d 100644 --- a/src/api/java/jni/term.cpp +++ b/src/api/java/jni/term.cpp @@ -247,6 +247,36 @@ JNIEXPORT jlong JNICALL Java_io_github_cvc5_api_Term_getOp(JNIEnv* env, /* * Class: io_github_cvc5_api_Term + * Method: hasSymbol + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_io_github_cvc5_api_Term_hasSymbol(JNIEnv* env, + jobject, + jlong pointer) +{ + CVC5_JAVA_API_TRY_CATCH_BEGIN; + Term* current = reinterpret_cast<Term*>(pointer); + return static_cast<jboolean>(current->hasSymbol()); + CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, static_cast<jboolean>(false)); +} + +/* + * Class: io_github_cvc5_api_Term + * Method: getSymbol + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_io_github_cvc5_api_Term_getSymbol(JNIEnv* env, + jobject, + jlong pointer) +{ + CVC5_JAVA_API_TRY_CATCH_BEGIN; + Term* current = reinterpret_cast<Term*>(pointer); + return env->NewStringUTF(current->getSymbol().c_str()); + CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, nullptr); +} + +/* + * Class: io_github_cvc5_api_Term * Method: isNull * Signature: (J)Z */ |