Emit eval result of constant expressions for Java.

b/31223640

Change-Id: I3552e01ecaef8ac570f13c4357cd04c1c3c516bb
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/ConstantExpression.h b/ConstantExpression.h
index 7e09dfa..fe2d572 100644
--- a/ConstantExpression.h
+++ b/ConstantExpression.h
@@ -55,6 +55,8 @@
     const char *value() const;
     /* Evaluated result in a string form, with given contextual kind. */
     const char *cppValue(ScalarType::Kind castKind) const;
+    /* Evaluated result in a string form, with given contextual kind. */
+    const char *javaValue(ScalarType::Kind castKind) const;
     /* Original expression with type. */
     const char *description() const;
 
@@ -69,9 +71,10 @@
     /* The stored result value.
      * Is valid only when mType != kConstExprUnknown. */
     uint64_t mValue;
-    /* Return a signed int64_t value.
-     * First cast it according to mValueKind, then cast it to int64_t. */
-    int64_t int64Value() const;
+    /* Return the value casted to the given type.
+     * First cast it according to mValueKind, then cast it to T.
+     * Assumes mType != kConstExprUnknown */
+    template <typename T> T cast() const;
     /* Helper function for value(ScalarType::Kind) */
     const char *value0(ScalarType::Kind castKind) const;