summaryrefslogtreecommitdiff
path: root/src/hir/type.hpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2019-11-02 11:07:23 +0800
committerJohn Hodge <tpg@ucc.asn.au>2019-11-02 11:07:23 +0800
commit1d02810c3cf908bfba7c15ae50eb5314603b9d85 (patch)
tree79dd5e4ef4c3ff79db0912ba546f08e61a7a8c10 /src/hir/type.hpp
parent7111acba04d72fe4084b1a1f3209ff83efe8614d (diff)
parent8b53b38f40625ab0510f541d69db3f83332a830a (diff)
downloadmrust-1d02810c3cf908bfba7c15ae50eb5314603b9d85.tar.gz
Merge branch 'nightly-1.29' - #95 Working support for rustc 1.29
Diffstat (limited to 'src/hir/type.hpp')
-rw-r--r--src/hir/type.hpp52
1 files changed, 49 insertions, 3 deletions
diff --git a/src/hir/type.hpp b/src/hir/type.hpp
index 480b32c4..cbc2e94a 100644
--- a/src/hir/type.hpp
+++ b/src/hir/type.hpp
@@ -19,6 +19,8 @@
namespace HIR {
+class TraitMarkings;
+class ExternType;
class Struct;
class Union;
class Enum;
@@ -87,15 +89,28 @@ struct LifetimeRef
static const uint32_t UNKNOWN = 0;
static const uint32_t STATIC = 0xFFFF;
+ //RcString name;
// Values below 2^16 are parameters/static, values above are per-function region IDs allocated during region inferrence.
uint32_t binding = UNKNOWN;
+ LifetimeRef()
+ :binding(UNKNOWN)
+ {
+ }
+ LifetimeRef(uint32_t binding)
+ :binding(binding)
+ {
+ }
+
static LifetimeRef new_static() {
LifetimeRef rv;
rv.binding = STATIC;
return rv;
}
+ Ordering ord(const LifetimeRef& x) const {
+ return ::ord(binding, x.binding);
+ }
bool operator==(const LifetimeRef& x) const {
return binding == x.binding;
}
@@ -152,11 +167,17 @@ public:
TAGGED_UNION_EX(TypePathBinding, (), Unbound, (
(Unbound, struct {}), // Not yet bound, either during lowering OR during resolution (when associated and still being resolved)
(Opaque, struct {}), // Opaque, i.e. An associated type of a generic (or Self in a trait)
+ (ExternType, const ::HIR::ExternType*),
(Struct, const ::HIR::Struct*),
(Union, const ::HIR::Union*),
(Enum, const ::HIR::Enum*)
), (), (), (
TypePathBinding clone() const;
+
+ const TraitMarkings* get_trait_markings() const;
+
+ bool operator==(const TypePathBinding& x) const;
+ bool operator!=(const TypePathBinding& x) const { return !(*this == x); }
)
);
@@ -184,9 +205,16 @@ public:
(Path, struct {
::HIR::Path path;
TypePathBinding binding;
+
+ bool is_closure() const {
+ return path.m_data.is_Generic()
+ && path.m_data.as_Generic().m_path.m_components.back().size() > 8
+ && path.m_data.as_Generic().m_path.m_components.back().compare(0,8, "closure#") == 0
+ ;
+ }
}),
(Generic, struct {
- ::std::string name;
+ RcString name;
// 0xFFFF = Self, 0-255 = Type/Trait, 256-511 = Method, 512-767 = Placeholder
unsigned int binding;
@@ -208,7 +236,7 @@ public:
(Array, struct {
::std::unique_ptr<TypeRef> inner;
::std::shared_ptr<::HIR::ExprPtr> size;
- size_t size_val;
+ uint64_t size_val;
}),
(Slice, struct {
::std::unique_ptr<TypeRef> inner;
@@ -249,7 +277,7 @@ public:
TypeRef(::std::vector< ::HIR::TypeRef> sts):
m_data( Data::make_Tuple(mv$(sts)) )
{}
- TypeRef(::std::string name, unsigned int slot):
+ TypeRef(RcString name, unsigned int slot):
m_data( Data::make_Generic({ mv$(name), slot }) )
{}
TypeRef(::HIR::TypeRef::Data x):
@@ -316,6 +344,24 @@ public:
// Compares this type with another, using `resolve_placeholder` to get replacements for generics/infers in `x`
Compare compare_with_placeholders(const Span& sp, const ::HIR::TypeRef& x, t_cb_resolve_type resolve_placeholder) const;
+
+ const ::HIR::SimplePath* get_sort_path() const {
+ // - Generic paths get sorted
+ if( TU_TEST1(this->m_data, Path, .path.m_data.is_Generic()) )
+ {
+ return &this->m_data.as_Path().path.m_data.as_Generic().m_path;
+ }
+ // - So do trait objects
+ else if( this->m_data.is_TraitObject() )
+ {
+ return &this->m_data.as_TraitObject().m_trait.m_path.m_path;
+ }
+ else
+ {
+ // Keep as nullptr, will search primitive list
+ return nullptr;
+ }
+ }
};
extern ::std::ostream& operator<<(::std::ostream& os, const ::HIR::TypeRef& ty);