diff options
author | Philip Herron <philip.herron@embecosm.com> | 2020-12-12 12:56:02 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2020-12-17 17:23:46 +0000 |
commit | 44d10d9547612b5fda3d27bb628d5d6ee79108af (patch) | |
tree | ee39563bec035ad3882c1e655a49ba55df12d47c /gcc/rust/util/rust-hir-map.h | |
parent | 4fb0ab7e635c65318aadf958e0e1303f3435c4e5 (diff) | |
download | gcc-44d10d9547612b5fda3d27bb628d5d6ee79108af.zip gcc-44d10d9547612b5fda3d27bb628d5d6ee79108af.tar.gz gcc-44d10d9547612b5fda3d27bb628d5d6ee79108af.tar.bz2 |
TypeResolution pass now with a TyTy module
Resolution must implement the Gathering specified in the rust-dev guide.
We need to be able to handle cases such as:
let mut x;
x = 1;
or
let mut x = vec!{}
x.push(1)
Now the TyTy module has a combine abstract method to allow the combination
of types to condense down from their integral parts.
Diffstat (limited to 'gcc/rust/util/rust-hir-map.h')
-rw-r--r-- | gcc/rust/util/rust-hir-map.h | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h index 8929ca4..7fc8777 100644 --- a/gcc/rust/util/rust-hir-map.h +++ b/gcc/rust/util/rust-hir-map.h @@ -20,6 +20,7 @@ #define RUST_HIR_MAP_H #include "rust-system.h" +#include "rust-location.h" #include "rust-ast-full-decls.h" #include "rust-hir-full-decls.h" @@ -40,11 +41,11 @@ typedef uint64_t DefId; #define DEF_ID_CRATE_MASK 0xFFFFFFFF00000000 #define DEF_ID_LOCAL_DEF_MASK 0x00000000FFFFFFFF -#define UNKNOWN_CREATENUM ((uint32_t) (-1)) -#define UNKNOWN_NODEID ((uint32_t) (-1)) -#define UNKNOWN_HIRID ((uint32_t) (-1)) -#define UNKNOWN_LOCAL_DEFID ((uint32_t) (-1)) -#define UNKNOWN_DEFID ((uint64_t) (-1)) +#define UNKNOWN_CREATENUM ((uint32_t) (0)) +#define UNKNOWN_NODEID ((uint32_t) (0)) +#define UNKNOWN_HIRID ((uint32_t) (0)) +#define UNKNOWN_LOCAL_DEFID ((uint32_t) (0)) +#define UNKNOWN_DEFID ((uint64_t) (0)) namespace Analysis { @@ -86,7 +87,10 @@ public: NodeId get_next_node_id () { return get_next_node_id (get_current_crate ()); } NodeId get_next_node_id (CrateNum crateNum); + + HirId get_next_hir_id () { return get_next_hir_id (get_current_crate ()); } HirId get_next_hir_id (CrateNum crateNum); + LocalDefId get_next_localdef_id (CrateNum crateNum); AST::Crate *get_ast_crate (CrateNum crateNum); @@ -108,9 +112,21 @@ public: void insert_hir_expr (CrateNum crateNum, HirId id, HIR::Expr *expr); HIR::Expr *lookup_hir_expr (CrateNum crateNum, HirId id); + void insert_hir_type (CrateNum crateNum, HirId id, HIR::Type *type); + HIR::Type *lookup_hir_type (CrateNum crateNum, HirId id); + void walk_local_defids_for_crate (CrateNum crateNum, std::function<bool (HIR::Item *)> cb); + bool lookup_node_to_hir (CrateNum crate, NodeId id, HirId *ref); + + void insert_location (CrateNum crate, HirId id, Location locus); + Location lookup_location (CrateNum crate, HirId id); + Location lookup_location (HirId id) + { + return lookup_location (get_current_crate (), id); + } + private: Mappings (); @@ -127,8 +143,12 @@ private: std::map<DefId, HIR::Item *> defIdMappings; std::map<CrateNum, std::map<LocalDefId, HIR::Item *> > localDefIdMappings; std::map<CrateNum, std::map<HirId, HIR::Item *> > hirItemMappings; + std::map<CrateNum, std::map<HirId, HIR::Type *> > hirTypeMappings; std::map<CrateNum, std::map<HirId, HIR::Expr *> > hirExprMappings; + // location info + std::map<CrateNum, std::map<NodeId, Location> > locations; + // reverse mappings std::map<CrateNum, std::map<NodeId, HirId> > nodeIdToHirMappings; }; |