Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove direct interop usages from flat_expr_builder. #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2023
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
1 change: 0 additions & 1 deletion eval/compiler/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ cc_library(
"//eval/eval:select_step",
"//eval/eval:shadowable_value_step",
"//eval/eval:ternary_step",
"//eval/internal:interop",
"//eval/public:ast_traverse_native",
"//eval/public:ast_visitor_native",
"//eval/public:source_position_native",
Expand Down
15 changes: 9 additions & 6 deletions eval/compiler/flat_expr_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
#include "eval/eval/select_step.h"
#include "eval/eval/shadowable_value_step.h"
#include "eval/eval/ternary_step.h"
#include "eval/internal/interop.h"
#include "eval/public/ast_traverse_native.h"
#include "eval/public/ast_visitor_native.h"
#include "eval/public/source_position_native.h"
Expand All @@ -77,7 +76,6 @@ using ::cel::Value;
using ::cel::ValueFactory;
using ::cel::ast::Ast;
using ::cel::ast::internal::AstImpl;
using ::cel::interop_internal::CreateIntValue;

constexpr int64_t kExprIdNotFromAst = -1;

Expand Down Expand Up @@ -656,6 +654,8 @@ class FlatExprVisitor : public cel::ast::internal::AstVisitor {

absl::Status progress_status() const { return progress_status_; }

cel::ValueFactory& value_factory() { return value_factory_; }

void AddStep(absl::StatusOr<std::unique_ptr<ExpressionStep>> step) {
if (step.ok() && progress_status_.ok()) {
execution_path_.push_back(*std::move(step));
Expand Down Expand Up @@ -1047,8 +1047,9 @@ int ComprehensionAccumulationReferences(const cel::ast::internal::Expr& expr,

void ComprehensionVisitor::PreVisit(const cel::ast::internal::Expr*) {
constexpr int64_t kLoopStepPlaceholder = -10;
visitor_->AddStep(CreateConstValueStep(CreateIntValue(kLoopStepPlaceholder),
kExprIdNotFromAst, false));
visitor_->AddStep(CreateConstValueStep(
visitor_->value_factory().CreateIntValue(kLoopStepPlaceholder),
kExprIdNotFromAst, false));
}

void ComprehensionVisitor::PostVisitArg(int arg_num,
Expand All @@ -1063,11 +1064,13 @@ void ComprehensionVisitor::PostVisitArg(int arg_num,
visitor_->AddStep(CreateListKeysStep(expr->id()));
// Setup index stack position
visitor_->AddStep(
CreateConstValueStep(CreateIntValue(-1), kExprIdNotFromAst, false));
CreateConstValueStep(visitor_->value_factory().CreateIntValue(-1),
kExprIdNotFromAst, false));
// Element at index.
constexpr int64_t kCurrentValuePlaceholder = -20;
visitor_->AddStep(CreateConstValueStep(
CreateIntValue(kCurrentValuePlaceholder), kExprIdNotFromAst, false));
visitor_->value_factory().CreateIntValue(kCurrentValuePlaceholder),
kExprIdNotFromAst, false));
break;
}
case cel::ast::internal::ACCU_INIT: {
Expand Down