diff --git a/runtime/src/main/java/dev/cel/runtime/BUILD.bazel b/runtime/src/main/java/dev/cel/runtime/BUILD.bazel index 42d341c49..1a4308f09 100644 --- a/runtime/src/main/java/dev/cel/runtime/BUILD.bazel +++ b/runtime/src/main/java/dev/cel/runtime/BUILD.bazel @@ -156,9 +156,9 @@ java_library( ":interpretable", ":runtime_helpers", "//common/annotations", + "//third_party/java/protobuf", "@maven//:com_google_guava_guava", "@maven//:org_jspecify_jspecify", - "@maven_android//:com_google_protobuf_protobuf_javalite", ], ) @@ -199,10 +199,10 @@ java_library( deps = [ "//common/types", "//common/types:type_providers", + "//third_party/java/protobuf", "@maven//:com_google_errorprone_error_prone_annotations", "@maven//:com_google_guava_guava", "@maven//:com_google_protobuf_protobuf_java", - "@maven_android//:com_google_protobuf_protobuf_javalite", ], ) @@ -352,9 +352,9 @@ java_library( "//common:runtime_exception", "//common/annotations", "//common/internal:comparison_functions", + "//third_party/java/protobuf", "@maven//:com_google_errorprone_error_prone_annotations", "@maven//:com_google_guava_guava", - "@maven_android//:com_google_protobuf_protobuf_javalite", ], ) @@ -430,12 +430,12 @@ java_library( "//common:runtime_exception", "//common/annotations", "//common/internal:converter", + "//third_party/java/protobuf", "@maven//:com_google_errorprone_error_prone_annotations", "@maven//:com_google_guava_guava", "@maven//:com_google_protobuf_protobuf_java", "@maven//:com_google_re2j_re2j", "@maven//:org_threeten_threeten_extra", - "@maven_android//:com_google_protobuf_protobuf_javalite", ], ) @@ -793,7 +793,6 @@ java_library( ":function_resolver", ":interpretable", ":interpreter", - ":lite_runtime", ":proto_message_activation_factory", ":proto_message_runtime_equality", ":runtime_equality", @@ -999,9 +998,9 @@ java_library( "//common/values:cel_value", "//common/values:cel_value_provider", "//common/values:combined_cel_value_provider", + "//third_party/java/protobuf", "@maven//:com_google_errorprone_error_prone_annotations", "@maven//:com_google_guava_guava", - "@maven_android//:com_google_protobuf_protobuf_javalite", ], ) diff --git a/runtime/src/main/java/dev/cel/runtime/CelRuntime.java b/runtime/src/main/java/dev/cel/runtime/CelRuntime.java index d730701e7..c9a028d0e 100644 --- a/runtime/src/main/java/dev/cel/runtime/CelRuntime.java +++ b/runtime/src/main/java/dev/cel/runtime/CelRuntime.java @@ -37,7 +37,20 @@ public interface CelRuntime { /** Creates an evaluable {@code Program} instance which is thread-safe and immutable. */ @Immutable - interface Program extends CelLiteRuntime.Program { + interface Program { + + /** Evaluate the expression without any variables. */ + Object eval() throws CelEvaluationException; + + /** Evaluate the expression using a {@code mapValue} as the source of input variables. */ + Object eval(Map mapValue) throws CelEvaluationException; + + /** + * Evaluate a compiled program with {@code mapValue} and late-bound functions {@code + * lateBoundFunctionResolver}. + */ + Object eval(Map mapValue, CelFunctionResolver lateBoundFunctionResolver) + throws CelEvaluationException; /** Evaluate the expression using {@code message} fields as the source of input variables. */ Object eval(Message message) throws CelEvaluationException; diff --git a/runtime/src/test/java/dev/cel/runtime/BUILD.bazel b/runtime/src/test/java/dev/cel/runtime/BUILD.bazel index 6e9685149..2d4ce0d81 100644 --- a/runtime/src/test/java/dev/cel/runtime/BUILD.bazel +++ b/runtime/src/test/java/dev/cel/runtime/BUILD.bazel @@ -19,6 +19,7 @@ java_library( # keep sorted exclude = [ "CelLiteInterpreterTest.java", + "CelLiteRuntimeTest.java", "CelValueInterpreterTest.java", "InterpreterTest.java", ] + ANDROID_TESTS, @@ -48,7 +49,6 @@ java_library( "//common/types:cel_v1alpha1_types", "//common/types:message_type_provider", "//common/values:cel_value_provider", - "//common/values:proto_message_lite_value_provider", "//compiler", "//compiler:compiler_builder", "//extensions:optional_library", @@ -65,8 +65,6 @@ java_library( "//runtime:interpreter", "//runtime:interpreter_util", "//runtime:late_function_binding", - "//runtime:lite_runtime", - "//runtime:lite_runtime_factory", "//runtime:proto_message_activation_factory", "//runtime:proto_message_runtime_equality", "//runtime:proto_message_runtime_helpers", @@ -89,12 +87,10 @@ java_library( "@com_google_googleapis//google/rpc/context:attribute_context_java_proto", "@maven//:com_google_guava_guava", "@maven//:com_google_protobuf_protobuf_java", - "@maven//:com_google_protobuf_protobuf_java_util", "@maven//:com_google_testparameterinjector_test_parameter_injector", "@maven//:com_google_truth_extensions_truth_proto_extension", "@maven//:junit_junit", "@maven//:org_jspecify_jspecify", - "@maven_android//:com_google_protobuf_protobuf_javalite", ], ) @@ -161,6 +157,46 @@ cel_android_local_test( ], ) +java_library( + name = "cel_lite_runtime_test", + testonly = 1, + srcs = [ + "CelLiteRuntimeTest.java", + ], + deps = [ + "//:java_truth", + "//common:cel_ast", + "//common:compiler_common", + "//common/internal:proto_time_utils", + "//common/types", + "//common/values:proto_message_lite_value_provider", + "//compiler", + "//compiler:compiler_builder", + "//parser:macro", + "//runtime", + "//runtime:function_binding", + "//runtime:lite_runtime", + "//runtime:lite_runtime_factory", + "//runtime:standard_functions", + "//testing/protos:message_with_enum_cel_java_proto", + "//testing/protos:message_with_enum_java_proto", + "//testing/protos:multi_file_cel_java_proto", + "//testing/protos:multi_file_java_proto", + "//testing/protos:single_file_java_proto", + "//testing/protos:test_all_types_cel_java_proto2", + "//testing/protos:test_all_types_cel_java_proto3", + "@cel_spec//proto/cel/expr/conformance/proto2:test_all_types_java_proto", + "@cel_spec//proto/cel/expr/conformance/proto3:test_all_types_java_proto", + "@maven//:com_google_guava_guava", + "@maven//:com_google_protobuf_protobuf_java", + "@maven//:com_google_protobuf_protobuf_java_util", + "@maven//:com_google_testparameterinjector_test_parameter_injector", + "@maven//:com_google_truth_extensions_truth_proto_extension", + "@maven//:junit_junit", + "@maven_android//:com_google_protobuf_protobuf_javalite", + ], +) + java_library( name = "cel_lite_interpreter_test", testonly = 1, @@ -188,6 +224,7 @@ junit4_test_suites( src_dir = "src/test/java", deps = [ ":cel_lite_interpreter_test", + ":cel_lite_runtime_test", ":cel_value_interpreter_test", ":interpreter_test", ":tests",