diff options
author | lrh2000 <lrh2000@pku.edu.cn> | 2021-04-22 21:22:11 +0800 |
---|---|---|
committer | lrh2000 <lrh2000@pku.edu.cn> | 2021-04-22 22:05:12 +0800 |
commit | 28895c1265e19a3e854040610d8478cfb8768d0a (patch) | |
tree | eec0947af5d1e9bcbddb29c3b1935136d1948e98 /gcc/rust/backend/rust-compile-context.h | |
parent | 3aeb9f47187f9b7ad55e32bcd273556823f383c6 (diff) | |
parent | dd3c58b2ce55ce6585916607927c3bca087610c6 (diff) | |
download | gcc-28895c1265e19a3e854040610d8478cfb8768d0a.zip gcc-28895c1265e19a3e854040610d8478cfb8768d0a.tar.gz gcc-28895c1265e19a3e854040610d8478cfb8768d0a.tar.bz2 |
Merge branch 'origin/master'
Diffstat (limited to 'gcc/rust/backend/rust-compile-context.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-context.h | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 2024a6f..11e791c 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -27,6 +27,7 @@ #include "rust-compile-tyty.h" #include "rust-ast-full.h" #include "rust-hir-full.h" +#include "rust-hir-const-fold-ctx.h" namespace Rust { namespace Compile { @@ -43,7 +44,8 @@ public: Context (::Backend *backend) : backend (backend), resolver (Resolver::Resolver::get ()), tyctx (Resolver::TypeCheckContext::get ()), - mappings (Analysis::Mappings::get ()) + mappings (Analysis::Mappings::get ()), + const_ctx (ConstFold::Context::get ()) { // insert the builtins auto builtins = resolver->get_builtin_types (); @@ -104,6 +106,7 @@ public: Resolver::Resolver *get_resolver () { return resolver; } Resolver::TypeCheckContext *get_tyctx () { return tyctx; } Analysis::Mappings *get_mappings () { return mappings; } + ConstFold::Context *get_const_ctx () { return const_ctx; } void push_block (Bblock *scope) { @@ -260,6 +263,7 @@ private: Resolver::Resolver *resolver; Resolver::TypeCheckContext *tyctx; Analysis::Mappings *mappings; + ConstFold::Context *const_ctx; // state std::vector<fncontext> fn_stack; @@ -420,16 +424,10 @@ public: void visit (TyTy::ArrayType &type) override { - mpz_t ival; - mpz_init_set_ui (ival, type.get_capacity ()); - - Btype *capacity_type = ctx->get_backend ()->integer_type (true, 32); - Bexpression *length - = ctx->get_backend ()->integer_constant_expression (capacity_type, ival); - Btype *element_type = TyTyResolveCompile::compile (ctx, type.get_element_type ()); - translated = ctx->get_backend ()->array_type (element_type, length); + translated + = ctx->get_backend ()->array_type (element_type, type.get_capacity ()); } void visit (TyTy::BoolType &type) override |