Skip to content
Merged
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
6 changes: 6 additions & 0 deletions common/exceptions/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@ java_library(
# used_by_android
exports = ["//common/src/main/java/dev/cel/common/exceptions:invalid_argument"],
)

java_library(
name = "iteration_budget_exceeded",
# used_by_android
exports = ["//common/src/main/java/dev/cel/common/exceptions:iteration_budget_exceeded"],
)
13 changes: 13 additions & 0 deletions common/src/main/java/dev/cel/common/exceptions/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,16 @@ java_library(
"//common/annotations",
],
)

java_library(
name = "iteration_budget_exceeded",
srcs = ["CelIterationLimitExceededException.java"],
# used_by_android
tags = [
],
deps = [
"//common:error_codes",
"//common:runtime_exception",
"//common/annotations",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package dev.cel.common.exceptions;

import dev.cel.common.CelErrorCode;
import dev.cel.common.CelRuntimeException;
import dev.cel.common.annotations.Internal;
import java.util.Locale;

/** Indicates that the iteration budget for a comprehension has been exceeded. */
@Internal
public final class CelIterationLimitExceededException extends CelRuntimeException {

public CelIterationLimitExceededException(int budget) {
super(
String.format(Locale.US, "Iteration budget exceeded: %d", budget),
CelErrorCode.ITERATION_BUDGET_EXCEEDED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License aj
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/** Represents a resolvable symbol or path (such as a variable or a field selection). */
@Immutable
interface Attribute {
Object resolve(GlobalResolver ctx);
Object resolve(GlobalResolver ctx, ExecutionFrame frame);

Attribute addQualifier(Qualifier qualifier);
}
58 changes: 32 additions & 26 deletions runtime/src/main/java/dev/cel/runtime/planner/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ java_library(
"//common:cel_ast",
"//common:container",
"//common:operator",
"//common:options",
"//common/annotations",
"//common/ast",
"//common/types",
Expand All @@ -59,11 +60,14 @@ java_library(
srcs = ["PlannedProgram.java"],
deps = [
":error_metadata",
":execution_frame",
":planned_interpretable",
":strict_error_exception",
"//:auto_value",
"//common:options",
"//common:runtime_exception",
"//common/values",
"//runtime",
"//runtime:activation",
"//runtime:evaluation_exception",
"//runtime:evaluation_exception_builder",
Expand All @@ -78,11 +82,10 @@ java_library(
name = "eval_const",
srcs = ["EvalConstant.java"],
deps = [
":execution_frame",
":planned_interpretable",
"//common/values",
"//common/values:cel_byte_string",
"//runtime:evaluation_listener",
"//runtime:function_resolver",
"//runtime:interpretable",
"@maven//:com_google_errorprone_error_prone_annotations",
"@maven//:com_google_guava_guava",
Expand Down Expand Up @@ -111,6 +114,7 @@ java_library(
],
deps = [
":eval_helpers",
":execution_frame",
":planned_interpretable",
":qualifier",
"//common:container",
Expand Down Expand Up @@ -158,10 +162,9 @@ java_library(
srcs = ["EvalAttribute.java"],
deps = [
":attribute",
":execution_frame",
":interpretable_attribute",
":qualifier",
"//runtime:evaluation_listener",
"//runtime:function_resolver",
"//runtime:interpretable",
"@maven//:com_google_errorprone_error_prone_annotations",
"@maven//:com_google_guava_guava",
Expand All @@ -172,12 +175,11 @@ java_library(
name = "eval_test_only",
srcs = ["EvalTestOnly.java"],
deps = [
":execution_frame",
":interpretable_attribute",
":presence_test_qualifier",
":qualifier",
"//runtime:evaluation_exception",
"//runtime:evaluation_listener",
"//runtime:function_resolver",
"//runtime:interpretable",
"@maven//:com_google_errorprone_error_prone_annotations",
],
Expand All @@ -187,10 +189,9 @@ java_library(
name = "eval_zero_arity",
srcs = ["EvalZeroArity.java"],
deps = [
":execution_frame",
":planned_interpretable",
"//runtime:evaluation_exception",
"//runtime:evaluation_listener",
"//runtime:function_resolver",
"//runtime:interpretable",
"//runtime:resolved_overload",
],
Expand All @@ -201,10 +202,9 @@ java_library(
srcs = ["EvalUnary.java"],
deps = [
":eval_helpers",
":execution_frame",
":planned_interpretable",
"//runtime:evaluation_exception",
"//runtime:evaluation_listener",
"//runtime:function_resolver",
"//runtime:interpretable",
"//runtime:resolved_overload",
],
Expand All @@ -215,10 +215,9 @@ java_library(
srcs = ["EvalVarArgsCall.java"],
deps = [
":eval_helpers",
":execution_frame",
":planned_interpretable",
"//runtime:evaluation_exception",
"//runtime:evaluation_listener",
"//runtime:function_resolver",
"//runtime:interpretable",
"//runtime:resolved_overload",
],
Expand All @@ -229,10 +228,9 @@ java_library(
srcs = ["EvalOr.java"],
deps = [
":eval_helpers",
":execution_frame",
":planned_interpretable",
"//common/values",
"//runtime:evaluation_listener",
"//runtime:function_resolver",
"//runtime:interpretable",
"@maven//:com_google_guava_guava",
],
Expand All @@ -243,10 +241,9 @@ java_library(
srcs = ["EvalAnd.java"],
deps = [
":eval_helpers",
":execution_frame",
":planned_interpretable",
"//common/values",
"//runtime:evaluation_listener",
"//runtime:function_resolver",
"//runtime:interpretable",
"@maven//:com_google_guava_guava",
],
Expand All @@ -256,10 +253,9 @@ java_library(
name = "eval_conditional",
srcs = ["EvalConditional.java"],
deps = [
":execution_frame",
":planned_interpretable",
"//runtime:evaluation_exception",
"//runtime:evaluation_listener",
"//runtime:function_resolver",
"//runtime:interpretable",
"@maven//:com_google_guava_guava",
],
Expand All @@ -269,13 +265,12 @@ java_library(
name = "eval_create_struct",
srcs = ["EvalCreateStruct.java"],
deps = [
":execution_frame",
":planned_interpretable",
"//common/types",
"//common/values",
"//common/values:cel_value_provider",
"//runtime:evaluation_exception",
"//runtime:evaluation_listener",
"//runtime:function_resolver",
"//runtime:interpretable",
"@maven//:com_google_errorprone_error_prone_annotations",
"@maven//:com_google_guava_guava",
Expand All @@ -286,10 +281,9 @@ java_library(
name = "eval_create_list",
srcs = ["EvalCreateList.java"],
deps = [
":execution_frame",
":planned_interpretable",
"//runtime:evaluation_exception",
"//runtime:evaluation_listener",
"//runtime:function_resolver",
"//runtime:interpretable",
"@maven//:com_google_errorprone_error_prone_annotations",
"@maven//:com_google_guava_guava",
Expand All @@ -300,10 +294,9 @@ java_library(
name = "eval_create_map",
srcs = ["EvalCreateMap.java"],
deps = [
":execution_frame",
":planned_interpretable",
"//runtime:evaluation_exception",
"//runtime:evaluation_listener",
"//runtime:function_resolver",
"//runtime:interpretable",
"@maven//:com_google_errorprone_error_prone_annotations",
"@maven//:com_google_guava_guava",
Expand All @@ -314,22 +307,33 @@ java_library(
name = "eval_fold",
srcs = ["EvalFold.java"],
deps = [
":execution_frame",
":planned_interpretable",
"//runtime:concatenated_list_view",
"//runtime:evaluation_exception",
"//runtime:evaluation_listener",
"//runtime:function_resolver",
"//runtime:interpretable",
"@maven//:com_google_errorprone_error_prone_annotations",
"@maven//:com_google_guava_guava",
"@maven//:org_jspecify_jspecify",
],
)

java_library(
name = "execution_frame",
srcs = ["ExecutionFrame.java"],
deps = [
"//common:options",
"//common/exceptions:iteration_budget_exceeded",
"//runtime:interpretable",
"@maven//:org_jspecify_jspecify",
],
)

java_library(
name = "eval_helpers",
srcs = ["EvalHelpers.java"],
deps = [
":execution_frame",
":planned_interpretable",
":strict_error_exception",
"//common:error_codes",
Expand Down Expand Up @@ -362,6 +366,8 @@ java_library(
name = "planned_interpretable",
srcs = ["PlannedInterpretable.java"],
deps = [
":execution_frame",
"//runtime:evaluation_exception",
"//runtime:interpretable",
"@maven//:com_google_errorprone_error_prone_annotations",
],
Expand Down
27 changes: 2 additions & 25 deletions runtime/src/main/java/dev/cel/runtime/planner/EvalAnd.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

import com.google.common.base.Preconditions;
import dev.cel.common.values.ErrorValue;
import dev.cel.runtime.CelEvaluationListener;
import dev.cel.runtime.CelFunctionResolver;
import dev.cel.runtime.GlobalResolver;

final class EvalAnd extends PlannedInterpretable {
Expand All @@ -28,10 +26,10 @@ final class EvalAnd extends PlannedInterpretable {
private final PlannedInterpretable[] args;

@Override
public Object eval(GlobalResolver resolver) {
public Object eval(GlobalResolver resolver, ExecutionFrame frame) {
ErrorValue errorValue = null;
for (PlannedInterpretable arg : args) {
Object argVal = evalNonstrictly(arg, resolver);
Object argVal = evalNonstrictly(arg, resolver, frame);
if (argVal instanceof Boolean) {
// Short-circuit on false
if (!((boolean) argVal)) {
Expand All @@ -53,27 +51,6 @@ public Object eval(GlobalResolver resolver) {
return true;
}

@Override
public Object eval(GlobalResolver resolver, CelEvaluationListener listener) {
// TODO: Implement support
throw new UnsupportedOperationException("Not yet supported");
}

@Override
public Object eval(GlobalResolver resolver, CelFunctionResolver lateBoundFunctionResolver) {
// TODO: Implement support
throw new UnsupportedOperationException("Not yet supported");
}

@Override
public Object eval(
GlobalResolver resolver,
CelFunctionResolver lateBoundFunctionResolver,
CelEvaluationListener listener) {
// TODO: Implement support
throw new UnsupportedOperationException("Not yet supported");
}

static EvalAnd create(long exprId, PlannedInterpretable[] args) {
return new EvalAnd(exprId, args);
}
Expand Down
Loading
Loading