Draft
Conversation
5c558e0 to
e84ed4c
Compare
Basic Infra to handle drop trait implementation. ChangeLog: * .gitignore: Hide Zed editor files. gcc/rust/ChangeLog: * Make-lang.in: Add datum.h and drop.h. * backend/rust-compile-context.h (RUST_COMPILE_CONTEXT): Add methods to hold cleanup and drop place. * backend/rust-compile-expr.cc (CompileExpr::CompileExpr): Wrap raw tree node inside datum with type and kind. (CompileExpr::CompileDatum): New API method to get datum. (CompileExpr::visit): Set datum after setting translated. * backend/rust-compile-expr.h (RUST_COMPILE_EXPR): Add CompileDatum API. * backend/rust-compile-stmt.cc (CompileStmt::visit): Add cleanup for ExprStmt, setup drop_flag state in let statement. * backend/rust-compile-var-decl.h (RUST_COMPILE_VAR_DECL): Create and store drop path/place for new declared variables. * rust-backend.h (block_add_statements_with_cleanups): New header function. * rust-gcc.cc (block_add_statements_with_cleanups): Wrap block body and cleanup into try_finally. * typecheck/rust-hir-type-check.h: Add method to get associated_traits_to_impls. * util/rust-lang-item.cc: Register drop lang item. * util/rust-lang-item.h: Register drop lang item. * backend/rust-compile-datum.cc: Implementation for datum.h. * backend/rust-compile-datum.h: Introduce the Datum system for tracking values through expression compilation. * backend/rust-compile-drop.cc: Implementation for drop.h. * backend/rust-compile-drop.h: Introduce Drop Place to track variable state and runtime cleanup information. gcc/testsuite/ChangeLog: * rust/execute/torture/drop-struct.rs: Add basic drop test. Signed-off-by: Islam-Imad <islamimad404@gmail.com>
e84ed4c to
0a986a1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Datum system is the central point for tracking values as they flow through expression compilation. Instead of letting raw tree nodes flow through expression we will have a rich Datum that holds other important info like drop and value kind.
The Drop Place is used to hold all needed information to drop a variable and track its state at runtime if this variable is initialized or uninitialized or partially initialized.
cc @philberty