Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions runtime/src/main/java/dev/cel/runtime/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)

Expand Down Expand Up @@ -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",
],
)

Expand Down Expand Up @@ -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",
],
)

Expand Down Expand Up @@ -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",
],
)

Expand Down Expand Up @@ -793,7 +793,6 @@ java_library(
":function_resolver",
":interpretable",
":interpreter",
":lite_runtime",
":proto_message_activation_factory",
":proto_message_runtime_equality",
":runtime_equality",
Expand Down Expand Up @@ -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",
],
)

Expand Down
15 changes: 14 additions & 1 deletion runtime/src/main/java/dev/cel/runtime/CelRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, ?> mapValue) throws CelEvaluationException;

/**
* Evaluate a compiled program with {@code mapValue} and late-bound functions {@code
* lateBoundFunctionResolver}.
*/
Object eval(Map<String, ?> mapValue, CelFunctionResolver lateBoundFunctionResolver)
throws CelEvaluationException;

/** Evaluate the expression using {@code message} fields as the source of input variables. */
Object eval(Message message) throws CelEvaluationException;
Expand Down
47 changes: 42 additions & 5 deletions runtime/src/test/java/dev/cel/runtime/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ java_library(
# keep sorted
exclude = [
"CelLiteInterpreterTest.java",
"CelLiteRuntimeTest.java",
"CelValueInterpreterTest.java",
"InterpreterTest.java",
] + ANDROID_TESTS,
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
],
)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
Loading