summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-07-05 23:21:58 +0800
committerJohn Hodge <tpg@mutabah.net>2016-07-05 23:21:58 +0800
commit005eda08c57c8bb2dcad96e9b8909babff906b4b (patch)
tree7ac8d95f4bb97ea9fe7a00d358402b092e43d25e /src
parentcfb510480b59f7daa3e5a2808d6b851033e4143e (diff)
downloadmrust-005eda08c57c8bb2dcad96e9b8909babff906b4b.tar.gz
HIR Typecheck CS - Value pattern types, fixed ivar adding
Diffstat (limited to 'src')
-rw-r--r--src/hir/pattern.hpp2
-rw-r--r--src/hir_typeck/expr_cs.cpp16
2 files changed, 16 insertions, 2 deletions
diff --git a/src/hir/pattern.hpp b/src/hir/pattern.hpp
index 8b67b599..479666f7 100644
--- a/src/hir/pattern.hpp
+++ b/src/hir/pattern.hpp
@@ -46,7 +46,7 @@ struct Pattern
{
TAGGED_UNION(Value, String,
(Integer, struct {
- enum ::HIR::CoreType type;
+ enum ::HIR::CoreType type; // Str == _
uint64_t value; // Signed numbers are encoded as 2's complement
}),
(String, ::std::string),
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp
index 68de7e8b..7e14dc87 100644
--- a/src/hir_typeck/expr_cs.cpp
+++ b/src/hir_typeck/expr_cs.cpp
@@ -348,6 +348,7 @@ namespace {
this->context.equate_types(node.span(), node.m_res_type, ::HIR::TypeRef::new_unit());
+ this->context.add_ivars(node.m_code->m_res_type);
node.m_code->visit( *this );
}
void visit(::HIR::ExprNode_LoopControl& node) override
@@ -1589,7 +1590,19 @@ void Context::add_binding(const Span& sp, ::HIR::Pattern& pat, ::HIR::TypeRef& t
// Just leave it, the pattern says nothing
),
(Value,
- TODO(sp, "Value pattern");
+ TU_MATCH(::HIR::Pattern::Value, (e.val), (v),
+ (Integer,
+ if( v.type != ::HIR::CoreType::Str ) {
+ this->equate_types(sp, type, ::HIR::TypeRef(v.type));
+ }
+ ),
+ (String,
+ this->equate_types(sp, type, ::HIR::TypeRef::new_borrow( ::HIR::BorrowType::Shared, ::HIR::TypeRef(::HIR::CoreType::Str) ));
+ ),
+ (Named,
+ // TODO: Get type of the value and equate it
+ )
+ )
),
(Range,
TODO(sp, "Range pattern");
@@ -1903,6 +1916,7 @@ void Context::add_binding(const Span& sp, ::HIR::Pattern& pat, ::HIR::TypeRef& t
}
void Context::equate_types_coerce(const Span& sp, const ::HIR::TypeRef& l, ::HIR::ExprNodeP& node_ptr)
{
+ this->m_ivars.get_type(l);
// - Just record the equality
this->link_coerce.push_back(Coercion {
l.clone(), &node_ptr