From 0480a81590cfa28220b939673c6d3c4068f2d176 Mon Sep 17 00:00:00 2001 From: Jonathan Tatum Date: Thu, 28 Aug 2025 11:38:12 -0700 Subject: [PATCH] Delete AstImpl, everything should just use Ast directly now. PiperOrigin-RevId: 800548853 --- common/ast.h | 10 +------- common/ast/BUILD | 11 --------- common/ast/ast_impl.h | 55 ------------------------------------------- 3 files changed, 1 insertion(+), 75 deletions(-) delete mode 100644 common/ast/ast_impl.h diff --git a/common/ast.h b/common/ast.h index 83d37f149..1b07b9878 100644 --- a/common/ast.h +++ b/common/ast.h @@ -27,10 +27,6 @@ namespace cel { -namespace ast_internal { -class AstImpl; -} // namespace ast_internal - // In memory representation of a CEL abstract syntax tree. // // If AST inspection or manipulation is needed, prefer to use an existing tool @@ -42,13 +38,11 @@ class AstImpl; // // To create a new instance from a protobuf representation, use the conversion // utilities in `common/ast_proto.h`. -class Ast { +class Ast final { public: using ReferenceMap = absl::flat_hash_map; using TypeMap = absl::flat_hash_map; - virtual ~Ast() = default; - Ast() : is_checked_(false) {} Ast(Expr expr, SourceInfo source_info) @@ -142,8 +136,6 @@ class Ast { } private: - friend class ast_internal::AstImpl; - Expr root_expr_; SourceInfo source_info_; ReferenceMap reference_map_; diff --git a/common/ast/BUILD b/common/ast/BUILD index a973c160b..c4eaea783 100644 --- a/common/ast/BUILD +++ b/common/ast/BUILD @@ -73,17 +73,6 @@ cc_test( ], ) -cc_library( - name = "ast_impl", - hdrs = ["ast_impl.h"], - deps = [ - ":expr", - ":metadata", - "//common:ast", - "//common:expr", - ], -) - cc_library( name = "expr", hdrs = [ diff --git a/common/ast/ast_impl.h b/common/ast/ast_impl.h deleted file mode 100644 index 2b40dffc7..000000000 --- a/common/ast/ast_impl.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 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. - -#ifndef THIRD_PARTY_CEL_CPP_BASE_AST_INTERNAL_AST_IMPL_H_ -#define THIRD_PARTY_CEL_CPP_BASE_AST_INTERNAL_AST_IMPL_H_ - -#include -#include - -#include "common/ast.h" -#include "common/ast/expr.h" -#include "common/ast/metadata.h" // IWYU pragma: export -#include "common/expr.h" - -namespace cel::ast_internal { - -// Trivial subclass of the public Ast. -// -// Temporarily needed to transition to just using the public Ast. -class AstImpl : public Ast { - public: - using ReferenceMap = Ast::ReferenceMap; - using TypeMap = Ast::TypeMap; - - AstImpl() = default; - - AstImpl(Expr expr, SourceInfo source_info) - : Ast(std::move(expr), std::move(source_info)) {} - - AstImpl(Expr expr, SourceInfo source_info, ReferenceMap reference_map, - TypeMap type_map, std::string expr_version) - : Ast(std::move(expr), std::move(source_info), std::move(reference_map), - std::move(type_map), std::move(expr_version)) {} - - // Move-only - AstImpl(const AstImpl& other) = delete; - AstImpl& operator=(const AstImpl& other) = delete; - AstImpl(AstImpl&& other) = default; - AstImpl& operator=(AstImpl&& other) = default; -}; - -} // namespace cel::ast_internal - -#endif // THIRD_PARTY_CEL_CPP_BASE_AST_INTERNAL_AST_IMPL_H_