summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--src/ast/generics.hpp10
-rw-r--r--src/ast/path.hpp14
-rw-r--r--src/ast/pattern.hpp1
-rw-r--r--src/ast/types.hpp2
-rw-r--r--src/common.hpp4
-rw-r--r--src/hir/deserialise.cpp23
-rw-r--r--src/hir/hir.cpp4
-rw-r--r--src/hir/pattern.hpp2
-rw-r--r--src/hir/serialise_lowlevel.hpp4
-rw-r--r--src/hir/type.cpp1
-rw-r--r--src/hir/type.hpp7
-rw-r--r--src/hir_conv/constant_evaluation.cpp10
-rw-r--r--src/hir_conv/expand_type.cpp2
-rw-r--r--src/hir_conv/resolve_ufcs.cpp8
-rw-r--r--src/hir_expand/closures.cpp6
-rw-r--r--src/hir_expand/const_eval_full.cpp2
-rw-r--r--src/hir_expand/erased_types.cpp36
-rw-r--r--src/hir_expand/ufcs_everything.cpp16
-rw-r--r--src/hir_typeck/expr_check.cpp60
-rw-r--r--src/hir_typeck/expr_cs.cpp392
-rw-r--r--src/hir_typeck/helpers.cpp69
-rw-r--r--src/hir_typeck/impl_ref.cpp2
-rw-r--r--src/hir_typeck/static.cpp133
-rw-r--r--src/include/debug.hpp6
-rw-r--r--src/include/serialise.hpp4
-rw-r--r--src/mir/check.cpp13
-rw-r--r--src/mir/from_hir.cpp13
-rw-r--r--src/mir/from_hir.hpp2
-rw-r--r--src/mir/from_hir_match.cpp28
-rw-r--r--src/mir/helpers.hpp6
-rw-r--r--src/mir/mir.hpp2
-rw-r--r--src/mir/mir_builder.cpp6
-rw-r--r--src/parse/expr.cpp2
-rw-r--r--src/parse/lex.cpp13
-rw-r--r--src/parse/pattern.cpp2
-rw-r--r--src/parse/token.cpp5
-rw-r--r--src/parse/token.hpp2
-rw-r--r--src/parse/tokenstream.cpp5
-rw-r--r--src/resolve/use.cpp2
-rw-r--r--vsproject/mrustc.vcxproj52
-rw-r--r--vsproject/mrustc.vcxproj.filters455
-rw-r--r--vsproject/packages.config6
43 files changed, 782 insertions, 652 deletions
diff --git a/.gitignore b/.gitignore
index a05f936f..e85b1a2c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,7 +19,9 @@
/vsproject/x64
/vsproject/tu_test/Win32
/vsproject/tu_test/x64
+/vsproject/packages
/vsproject/*.sdf
+/vsproject/*.VC.db
/vsproject/*.depend
/vsproject/*.opendb
diff --git a/src/ast/generics.hpp b/src/ast/generics.hpp
index 2de5aeaa..bc14202e 100644
--- a/src/ast/generics.hpp
+++ b/src/ast/generics.hpp
@@ -1,3 +1,10 @@
+/*
+ * MRustC - Rust Compiler
+ * - By John Hodge (Mutabah/thePowersGang)
+ *
+ * ast/generics.hpp
+ * - AST Generics (type parameters, bounds, ...)
+ */
#pragma once
#include <string>
@@ -5,11 +12,10 @@
namespace AST {
-
class TypeParam
{
::std::string m_name;
- TypeRef m_default;
+ ::TypeRef m_default;
public:
TypeParam(TypeParam&& x) = default;
TypeParam& operator=(TypeParam&& x) = default;
diff --git a/src/ast/path.hpp b/src/ast/path.hpp
index 7a67b93e..f3a72133 100644
--- a/src/ast/path.hpp
+++ b/src/ast/path.hpp
@@ -48,27 +48,27 @@ TAGGED_UNION_EX(PathBinding, (), Unbound, (
}),
(Module, struct {
const Module* module_;
- const ::HIR::Module* hir = nullptr;
+ const ::HIR::Module* hir;
}),
(Struct, struct {
const Struct* struct_;
- const ::HIR::Struct* hir = nullptr;
+ const ::HIR::Struct* hir;
}),
(Enum, struct {
const Enum* enum_;
- const ::HIR::Enum* hir = nullptr;
+ const ::HIR::Enum* hir;
}),
(Union, struct {
const Union* union_;
- const ::HIR::Union* hir = nullptr;
+ const ::HIR::Union* hir;
}),
(Trait, struct {
const Trait* trait_;
- const ::HIR::Trait* hir = nullptr;
+ const ::HIR::Trait* hir;
}),
(Static, struct {
const Static* static_;
- const ::HIR::Static* hir = nullptr; // if nullptr and static_ == nullptr, points to a `const`
+ const ::HIR::Static* hir; // if nullptr and static_ == nullptr, points to a `const`
}),
(Function, struct {
const Function* func_;
@@ -76,7 +76,7 @@ TAGGED_UNION_EX(PathBinding, (), Unbound, (
(EnumVar, struct {
const Enum* enum_;
unsigned int idx;
- const ::HIR::Enum* hir = nullptr;
+ const ::HIR::Enum* hir;
}),
(TypeAlias, struct {
const TypeAlias* alias_;
diff --git a/src/ast/pattern.hpp b/src/ast/pattern.hpp
index af6a5adf..583ce351 100644
--- a/src/ast/pattern.hpp
+++ b/src/ast/pattern.hpp
@@ -14,6 +14,7 @@
#include <string>
#include <tagged_union.hpp>
#include <ident.hpp>
+#include "path.hpp"
namespace AST {
diff --git a/src/ast/types.hpp b/src/ast/types.hpp
index e2114bae..314ab828 100644
--- a/src/ast/types.hpp
+++ b/src/ast/types.hpp
@@ -3,7 +3,7 @@
#include <memory>
-#include "common.hpp"
+#include "../common.hpp"
#include "coretypes.hpp"
#include "ast/path.hpp"
#include "ast/macro.hpp"
diff --git a/src/common.hpp b/src/common.hpp
index a0130371..76940d25 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -11,6 +11,10 @@
#include <sstream>
#include <memory>
+#ifdef _MSC_VER
+#define __attribute__(x)
+#endif
+
#define FMT(ss) (dynamic_cast< ::std::stringstream&>(::std::stringstream() << ss).str())
// XXX: Evil hack - Define 'mv$' to be ::std::move
#define mv$(x) ::std::move(x)
diff --git a/src/hir/deserialise.cpp b/src/hir/deserialise.cpp
index 4a9b5720..c08f886d 100644
--- a/src/hir/deserialise.cpp
+++ b/src/hir/deserialise.cpp
@@ -505,10 +505,10 @@ namespace {
::HIR::Linkage deserialise_linkage()
{
- return ::HIR::Linkage {
- ::HIR::Linkage::Type::Auto,
- m_in.read_string(),
- };
+ ::HIR::Linkage l;
+ l.type = ::HIR::Linkage::Type::Auto;
+ l.name = m_in.read_string();
+ return l;
}
// - Value items
@@ -707,7 +707,7 @@ namespace {
_(Array, {
deserialise_ptr< ::HIR::TypeRef>(),
nullptr,
- m_in.read_u64c()
+ m_in.read_u64c() & SIZE_MAX
})
_(Slice, {
deserialise_ptr< ::HIR::TypeRef>()
@@ -1002,12 +1002,13 @@ namespace {
deserialise_vec< ::std::string>(),
deserialise_vec< ::std::string>()
});
- case 3:
- return ::MIR::Statement::make_SetDropFlag({
- static_cast<unsigned int>(m_in.read_count()),
- m_in.read_bool(),
- static_cast<unsigned int>(m_in.read_count())
- });
+ case 3: {
+ ::MIR::Statement::Data_SetDropFlag sdf;
+ sdf.idx = static_cast<unsigned int>(m_in.read_count());
+ sdf.new_val = m_in.read_bool();
+ sdf.other = static_cast<unsigned int>(m_in.read_count());
+ return ::MIR::Statement::make_SetDropFlag(sdf);
+ }
default:
::std::cerr << "Bad tag for a MIR Statement" << ::std::endl;
throw "";
diff --git a/src/hir/hir.cpp b/src/hir/hir.cpp
index 66dc0e0b..9d1fcf97 100644
--- a/src/hir/hir.cpp
+++ b/src/hir/hir.cpp
@@ -727,8 +727,8 @@ const ::HIR::SimplePath& ::HIR::Crate::get_lang_item_path_opt(const char* name)
const ::HIR::TypeItem& ::HIR::Crate::get_typeitem_by_path(const Span& sp, const ::HIR::SimplePath& path, bool ignore_crate_name, bool ignore_last_node) const
{
- ASSERT_BUG(sp, path.m_components.size() > 0, "get_typeitem_by_path received invalid path - " << path);
- ASSERT_BUG(sp, path.m_components.size() > (ignore_last_node ? 1 : 0), "get_typeitem_by_path received invalid path - " << path);
+ ASSERT_BUG(sp, path.m_components.size() > 0u, "get_typeitem_by_path received invalid path - " << path);
+ ASSERT_BUG(sp, path.m_components.size() > (ignore_last_node ? 1u : 0u), "get_typeitem_by_path received invalid path - " << path);
const ::HIR::Module* mod;
if( !ignore_crate_name && path.m_crate_name != m_crate_name ) {
diff --git a/src/hir/pattern.hpp b/src/hir/pattern.hpp
index 4c38b150..df14de79 100644
--- a/src/hir/pattern.hpp
+++ b/src/hir/pattern.hpp
@@ -85,7 +85,7 @@ struct Pattern
(SplitTuple, struct {
::std::vector<Pattern> leading;
::std::vector<Pattern> trailing;
- unsigned int total_size = 0;
+ unsigned int total_size;
}),
(StructValue, struct {
GenericPath path;
diff --git a/src/hir/serialise_lowlevel.hpp b/src/hir/serialise_lowlevel.hpp
index fb4504e7..de913432 100644
--- a/src/hir/serialise_lowlevel.hpp
+++ b/src/hir/serialise_lowlevel.hpp
@@ -52,7 +52,7 @@ public:
// Variable-length encoded u64 (for array sizes)
void write_u64c(uint64_t v) {
if( v < (1<<7) ) {
- write_u8(v);
+ write_u8(static_cast<uint8_t>(v));
}
else if( v < (1<<(6+16)) ) {
uint8_t buf[] = {
@@ -62,7 +62,7 @@ public:
};
this->write(buf, sizeof buf);
}
- else if( v < (1ul << (5 + 32)) ) {
+ else if( v < (1ull << (5 + 32)) ) {
uint8_t buf[] = {
static_cast<uint8_t>(0xC0 + (v >> 32)), // 0xC0 -- 0xDF
static_cast<uint8_t>(v >> 24),
diff --git a/src/hir/type.cpp b/src/hir/type.cpp
index 07e9f477..dd655ccc 100644
--- a/src/hir/type.cpp
+++ b/src/hir/type.cpp
@@ -762,6 +762,7 @@ bool ::HIR::TypeRef::match_test_generics(const Span& sp, const ::HIR::TypeRef& x
(Enum , return ::HIR::TypeRef::TypePathBinding(e); )
)
assert(!"Fell off end of clone_binding");
+ throw "";
}
diff --git a/src/hir/type.hpp b/src/hir/type.hpp
index 3bf384a6..b5b10c4e 100644
--- a/src/hir/type.hpp
+++ b/src/hir/type.hpp
@@ -125,8 +125,8 @@ public:
TAGGED_UNION(Data, Infer,
(Infer, struct {
- unsigned int index = ~0u;
- InferClass ty_class = InferClass::None;
+ unsigned int index;
+ InferClass ty_class;
}),
(Diverge, struct {}),
(Primitive, ::HIR::CoreType),
@@ -210,6 +210,9 @@ public:
static TypeRef new_diverge() {
return TypeRef(Data::make_Diverge({}));
}
+ static TypeRef new_infer(unsigned int idx = ~0u, InferClass ty_class = InferClass::None) {
+ return TypeRef(Data::make_Infer({idx, ty_class}));
+ }
static TypeRef new_borrow(BorrowType bt, TypeRef inner) {
return TypeRef(Data::make_Borrow({bt, box$(mv$(inner))}));
}
diff --git a/src/hir_conv/constant_evaluation.cpp b/src/hir_conv/constant_evaluation.cpp
index a70840ed..1ebdbb11 100644
--- a/src/hir_conv/constant_evaluation.cpp
+++ b/src/hir_conv/constant_evaluation.cpp
@@ -427,7 +427,7 @@ namespace {
case ::HIR::ExprNode_UniOp::Op::Negate:
TU_MATCH_DEF(::HIR::Literal, (val), (e),
( throw ""; ),
- (Integer, m_rv = ::HIR::Literal(-e); ),
+ (Integer, m_rv = ::HIR::Literal(static_cast<uint64_t>(-static_cast<int64_t>(e))); ),
(Float, m_rv = ::HIR::Literal(-e); )
)
break;
@@ -538,7 +538,7 @@ namespace {
node.m_index->visit(*this);
if( !m_rv.is_Integer() )
ERROR(node.span(), E0000, "Array index isn't an integer - got " << m_rv.tag_str());
- auto idx = m_rv.as_Integer();
+ auto idx = static_cast<size_t>( m_rv.as_Integer() );
// Value
m_exp_type = ::HIR::TypeRef::new_slice( mv$(exp_ty) );
@@ -1019,7 +1019,7 @@ namespace {
TRACE_FUNCTION_F("exp=" << exp << ", args=" << args);
StaticTraitResolve resolve { crate };
- ::MIR::TypeResolve state { sp, resolve, FMT_CB(), exp, {}, fcn };
+ ::MIR::TypeResolve state { sp, resolve, FMT_CB(,), exp, {}, fcn };
::HIR::Literal retval;
::std::vector< ::HIR::Literal> locals;
@@ -1592,7 +1592,7 @@ namespace {
auto val = evaluate_constant(expr_ptr->span(), m_crate, nvs, expr_ptr, ::HIR::CoreType::Usize);
if( !val.is_Integer() )
ERROR(expr_ptr->span(), E0000, "Array size isn't an integer");
- e.size_val = val.as_Integer();
+ e.size_val = static_cast<size_t>(val.as_Integer());
}
DEBUG("Array " << ty << " - size = " << e.size_val);
)
@@ -1666,7 +1666,7 @@ namespace {
auto val = evaluate_constant_hir(node.span(), m_exp.m_crate, mv$(nvs), *node.m_size, ::HIR::CoreType::Usize, {});
if( !val.is_Integer() )
ERROR(node.span(), E0000, "Array size isn't an integer");
- node.m_size_val = val.as_Integer();
+ node.m_size_val = static_cast<size_t>(val.as_Integer());
DEBUG("Array literal [?; " << node.m_size_val << "]");
}
diff --git a/src/hir_conv/expand_type.cpp b/src/hir_conv/expand_type.cpp
index 303eae90..511a35b0 100644
--- a/src/hir_conv/expand_type.cpp
+++ b/src/hir_conv/expand_type.cpp
@@ -26,7 +26,7 @@
}
if( e2.m_params.m_types.size() > 0 ) {
// TODO: Better `monomorphise_type`
- return monomorphise_type_with(sp, e2.m_type, [&](const auto& gt)->const auto& {
+ return monomorphise_type_with(sp, e2.m_type, [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == GENERIC_Self ) {
BUG(sp, "Self encountered in expansion for " << path << " - " << e2.m_type);
diff --git a/src/hir_conv/resolve_ufcs.cpp b/src/hir_conv/resolve_ufcs.cpp
index 8f4947c5..d397d78c 100644
--- a/src/hir_conv/resolve_ufcs.cpp
+++ b/src/hir_conv/resolve_ufcs.cpp
@@ -253,7 +253,7 @@ namespace {
return true;
}
- auto monomorph_cb = [&](const auto& ty)->const auto& {
+ auto monomorph_cb = [&](const auto& ty)->const ::HIR::TypeRef& {
const auto& ge = ty.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
// TODO: This has to be the _exact_ same type, including future ivars.
@@ -282,7 +282,7 @@ namespace {
}
};
::HIR::GenericPath par_trait_path_tmp;
- auto monomorph_gp_if_needed = [&](const auto& tpl)->const auto& {
+ auto monomorph_gp_if_needed = [&](const ::HIR::GenericPath& tpl)->const ::HIR::GenericPath& {
// NOTE: This doesn't monomorph if the parameter set is the same
if( monomorphise_genericpath_needed(tpl) && tpl.m_params != trait_path.m_params ) {
DEBUG("- Monomorph " << tpl);
@@ -321,10 +321,10 @@ namespace {
const auto& type = *e.type;
// TODO: This is VERY arbitary and possibly nowhere near what rustc does.
- this->m_resolve.find_impl(sp, trait_path.m_path, nullptr, type, [&](const auto& impl, bool fuzzy){
+ this->m_resolve.find_impl(sp, trait_path.m_path, nullptr, type, [&](const auto& impl, bool fuzzy)->bool{
auto pp = impl.get_trait_params();
// Replace all placeholder parameters (group 2) with ivars (empty types)
- pp = monomorphise_path_params_with(sp, pp, [&](const auto& gt)->const auto& {
+ pp = monomorphise_path_params_with(sp, pp, [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( (ge.binding >> 8) == 2 ) {
static ::HIR::TypeRef empty_type;
diff --git a/src/hir_expand/closures.cpp b/src/hir_expand/closures.cpp
index 180ed89a..82681a47 100644
--- a/src/hir_expand/closures.cpp
+++ b/src/hir_expand/closures.cpp
@@ -507,7 +507,7 @@ namespace {
impl_path_params.m_types.push_back( ::HIR::TypeRef(params.m_types[i].m_name, i) );
}
- auto monomorph_cb = [&](const auto& ty)->const auto& {
+ auto monomorph_cb = [&](const auto& ty)->const ::HIR::TypeRef& {
const auto& ge = ty.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
return params_placeholders.at(0);
@@ -527,7 +527,7 @@ namespace {
}
};
auto monomorph = [&](const auto& ty){ return monomorphise_type_with(sp, ty, monomorph_cb); };
- auto cb_replace = [&](const auto& tpl, auto& rv) {
+ auto cb_replace = [&](const auto& tpl, auto& rv)->bool {
if( tpl.m_data.is_Infer() ) {
BUG(sp, "");
}
@@ -551,7 +551,7 @@ namespace {
};
// - Clone the bounds (from both levels)
- auto monomorph_bound = [&](const ::HIR::GenericBound& b)->auto {
+ auto monomorph_bound = [&](const ::HIR::GenericBound& b)->::HIR::GenericBound {
TU_MATCHA( (b), (e),
(Lifetime,
return ::HIR::GenericBound(e); ),
diff --git a/src/hir_expand/const_eval_full.cpp b/src/hir_expand/const_eval_full.cpp
index 3bdec96f..538693f4 100644
--- a/src/hir_expand/const_eval_full.cpp
+++ b/src/hir_expand/const_eval_full.cpp
@@ -351,7 +351,7 @@ namespace {
auto& idx = get_lval(*e.idx);
MIR_ASSERT(state, idx.is_Integer(), "LValue::Index with non-integer index literal - " << idx.tag_str() << " - " << lv);
auto& vals = val.as_List();
- auto idx_v = idx.as_Integer();
+ auto idx_v = static_cast<size_t>( idx.as_Integer() );
MIR_ASSERT(state, idx_v < vals.size(), "LValue::Index index out of range");
return vals[ idx_v ];
),
diff --git a/src/hir_expand/erased_types.cpp b/src/hir_expand/erased_types.cpp
index e4075e92..aca58207 100644
--- a/src/hir_expand/erased_types.cpp
+++ b/src/hir_expand/erased_types.cpp
@@ -14,19 +14,21 @@
const ::HIR::Function& HIR_Expand_ErasedType_GetFunction(const Span& sp, const StaticTraitResolve& resolve, const ::HIR::Path& origin_path, t_cb_generic& monomorph_cb, ::HIR::PathParams& impl_params)
{
const ::HIR::Function* fcn_ptr = nullptr;
- TU_MATCHA( (origin_path.m_data), (pe),
- (UfcsUnknown,
- BUG(Span(), "UfcsUnknown in ErasedType - " << origin_path);
- ),
- (Generic,
- monomorph_cb = monomorphise_type_get_cb(sp, nullptr, nullptr, &pe.m_params);
- fcn_ptr = &resolve.m_crate.get_function_by_path(sp, pe.m_path);
- ),
- (UfcsKnown,
- // NOTE: This isn't possible yet (will it be? or will it expand to an associated type?)
- TODO(sp, "Replace ErasedType - " << origin_path << " with source (UfcsKnown)");
- ),
- (UfcsInherent,
+ switch(origin_path.m_data.tag())
+ {
+ case ::HIR::Path::Data::TAG_UfcsUnknown:
+ BUG(Span(), "UfcsUnknown in ErasedType - " << origin_path);
+ case ::HIR::Path::Data::TAG_Generic: {
+ const auto& pe = origin_path.m_data.as_Generic();
+ monomorph_cb = monomorphise_type_get_cb(sp, nullptr, nullptr, &pe.m_params);
+ fcn_ptr = &resolve.m_crate.get_function_by_path(sp, pe.m_path);
+ } break;
+ case ::HIR::Path::Data::TAG_UfcsKnown:
+ // NOTE: This isn't possible yet (will it be? or will it expand to an associated type?)
+ TODO(sp, "Replace ErasedType - " << origin_path << " with source (UfcsKnown)");
+ break;
+ case ::HIR::Path::Data::TAG_UfcsInherent: {
+ const auto& pe = origin_path.m_data.as_UfcsInherent();
// 1. Find correct impl block for the path
const ::HIR::TypeImpl* impl_ptr = nullptr;
resolve.m_crate.find_type_impls(*pe.type, [&](const auto& ty)->const auto& { return ty; },
@@ -50,12 +52,16 @@ const ::HIR::Function& HIR_Expand_ErasedType_GetFunction(const Span& sp, const S
return ::HIR::Compare::Equal;
});
for(const auto& t : impl_params.m_types)
+ {
if( t == ::HIR::TypeRef() )
+ {
TODO(sp, "Handle ErasedType where an impl parameter comes from a bound - " << origin_path);
+ }
+ }
monomorph_cb = monomorphise_type_get_cb(sp, &*pe.type, &impl_params, &pe.params);
- )
- )
+ } break;
+ }
assert(fcn_ptr);
return *fcn_ptr;
}
diff --git a/src/hir_expand/ufcs_everything.cpp b/src/hir_expand/ufcs_everything.cpp
index 0562c418..60d503aa 100644
--- a/src/hir_expand/ufcs_everything.cpp
+++ b/src/hir_expand/ufcs_everything.cpp
@@ -289,8 +289,7 @@ namespace {
ASSERT_BUG(sp, ty_slot == ty_val, "Types must equal for non-operator assignment, " << ty_slot << " != " << ty_val);
return ;
_(Shr): {langitem = "shr_assign"; opname = "shr_assign"; } if(0)
- _(Shl): {langitem = "shl_assign"; opname = "shl_assign"; } if(0)
- ;
+ _(Shl): {langitem = "shl_assign"; opname = "shl_assign"; }
if( is_op_valid_shift(ty_slot, ty_val) ) {
return ;
}
@@ -298,8 +297,7 @@ namespace {
_(And): {langitem = "bitand_assign"; opname = "bitand_assign"; } if(0)
_(Or ): {langitem = "bitor_assign" ; opname = "bitor_assign" ; } if(0)
- _(Xor): {langitem = "bitxor_assign"; opname = "bitxor_assign"; } if(0)
- ;
+ _(Xor): {langitem = "bitxor_assign"; opname = "bitxor_assign"; }
if( is_op_valid_bitmask(ty_slot, ty_val) ) {
return ;
}
@@ -309,8 +307,7 @@ namespace {
_(Sub): {langitem = "sub_assign"; opname = "sub_assign"; } if(0)
_(Mul): {langitem = "mul_assign"; opname = "mul_assign"; } if(0)
_(Div): {langitem = "div_assign"; opname = "div_assign"; } if(0)
- _(Mod): {langitem = "rem_assign"; opname = "rem_assign"; } if(0)
- ;
+ _(Mod): {langitem = "rem_assign"; opname = "rem_assign"; }
if( is_op_valid_arith(ty_slot, ty_val) ) {
return ;
}
@@ -359,8 +356,8 @@ namespace {
case ::HIR::ExprNode_BinOp::Op::CmpLt: { langitem = "ord"; method = "lt"; } if(0)
case ::HIR::ExprNode_BinOp::Op::CmpLtE: { langitem = "ord"; method = "le"; } if(0)
case ::HIR::ExprNode_BinOp::Op::CmpGt: { langitem = "ord"; method = "gt"; } if(0)
- case ::HIR::ExprNode_BinOp::Op::CmpGtE: { langitem = "ord"; method = "ge"; } if(0)
- ; {
+ case ::HIR::ExprNode_BinOp::Op::CmpGtE: { langitem = "ord"; method = "ge"; }
+ {
// 1. Check if the types are valid for primitive comparison
if( ty_l == ty_r ) {
TU_MATCH_DEF(::HIR::TypeRef::Data, (ty_l.m_data), (e),
@@ -406,8 +403,7 @@ namespace {
case ::HIR::ExprNode_BinOp::Op::Xor: langitem = method = "bitxor"; if(0)
case ::HIR::ExprNode_BinOp::Op::Or : langitem = method = "bitor" ; if(0)
- case ::HIR::ExprNode_BinOp::Op::And: langitem = method = "bitand"; if(0)
- ;
+ case ::HIR::ExprNode_BinOp::Op::And: langitem = method = "bitand";
if( is_op_valid_bitmask(ty_l, ty_r) ) {
return ;
}
diff --git a/src/hir_typeck/expr_check.cpp b/src/hir_typeck/expr_check.cpp
index 4f7bb5f4..6cbb61f4 100644
--- a/src/hir_typeck/expr_check.cpp
+++ b/src/hir_typeck/expr_check.cpp
@@ -36,7 +36,7 @@ namespace {
node_ptr->visit(*this);
// Monomorphise erased type
- ::HIR::TypeRef new_ret_type = clone_ty_with(sp, ret_type, [&](const auto& tpl, auto& rv) {
+ ::HIR::TypeRef new_ret_type = clone_ty_with(sp, ret_type, [&](const auto& tpl, auto& rv)->bool {
if( tpl.m_data.is_ErasedType() )
{
const auto& e = tpl.m_data.as_ErasedType();
@@ -480,7 +480,7 @@ namespace {
#if 1
const auto& ty_params = node.m_path.m_params.m_types;
- auto monomorph_cb = [&](const auto& gt)->const auto& {
+ auto monomorph_cb = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
return ty;
@@ -579,7 +579,7 @@ namespace {
fcn_ptr = &fcn;
cache.m_fcn_params = &fcn.m_params;
- monomorph_cb = [&](const auto& gt)->const auto& {
+ monomorph_cb = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& e = gt.m_data.as_Generic();
if( e.name == "Self" || e.binding == 0xFFFF )
TODO(sp, "Handle 'Self' when monomorphising");
@@ -616,29 +616,7 @@ namespace {
fcn_ptr = &fcn;
- monomorph_cb = [&](const auto& gt)->const auto& {
- const auto& ge = gt.m_data.as_Generic();
- if( ge.binding == 0xFFFF ) {
- return *e.type;
- }
- else if( ge.binding < 256 ) {
- auto idx = ge.binding;
- if( idx >= trait_params.m_types.size() ) {
- BUG(sp, "Generic param (impl) out of input range - " << idx << " '"<<ge.name<<"' >= " << trait_params.m_types.size());
- }
- return trait_params.m_types[idx];
- }
- else if( ge.binding < 512 ) {
- auto idx = ge.binding - 256;
- if( idx >= path_params.m_types.size() ) {
- BUG(sp, "Generic param out of input range - " << idx << " '"<<ge.name<<"' >= " << path_params.m_types.size());
- }
- return path_params.m_types[idx];
- }
- else {
- BUG(sp, "Generic bounding out of total range");
- }
- };
+ monomorph_cb = monomorphise_type_get_cb(sp, &*e.type, &trait_params, &path_params);
),
(UfcsUnknown,
TODO(sp, "Hit a UfcsUnknown (" << path << ") - Is this an error?");
@@ -646,7 +624,7 @@ namespace {
(UfcsInherent,
// - Locate function (and impl block)
const ::HIR::TypeImpl* impl_ptr = nullptr;
- m_resolve.m_crate.find_type_impls(*e.type, [&](const auto& ty)->const auto& { return ty; },
+ m_resolve.m_crate.find_type_impls(*e.type, [&](const auto& ty)->const ::HIR::TypeRef& { return ty; },
[&](const auto& impl) {
DEBUG("- impl" << impl.m_params.fmt_args() << " " << impl.m_type);
auto it = impl.m_methods.find(e.item);
@@ -670,29 +648,7 @@ namespace {
// Create monomorphise callback
const auto& fcn_params = e.params;
- monomorph_cb = [&](const auto& gt)->const auto& {
- const auto& ge = gt.m_data.as_Generic();
- if( ge.binding == 0xFFFF ) {
- return *e.type;
- }
- else if( ge.binding < 256 ) {
- auto idx = ge.binding;
- if( idx >= impl_params.m_types.size() ) {
- BUG(sp, "Generic param out of input range (impl) - " << idx << " '" << ge.name << "' >= " << impl_params.m_types.size());
- }
- return impl_params.m_types[idx];
- }
- else if( ge.binding < 512 ) {
- auto idx = ge.binding - 256;
- if( idx >= fcn_params.m_types.size() ) {
- BUG(sp, "Generic param out of input range (item) - " << idx << " '" << ge.name << "' >= " << fcn_params.m_types.size());
- }
- return fcn_params.m_types[idx];
- }
- else {
- BUG(sp, "Generic bounding out of total range");
- }
- };
+ monomorph_cb = monomorphise_type_get_cb(sp, &*e.type, &impl_params, &fcn_params);
)
)
@@ -709,7 +665,7 @@ namespace {
}
DEBUG("Ret " << fcn.m_return);
// Replace ErasedType and monomorphise
- cache.m_arg_types.push_back( clone_ty_with(sp, fcn.m_return, [&](const auto& tpl, auto& rv) {
+ cache.m_arg_types.push_back( clone_ty_with(sp, fcn.m_return, [&](const auto& tpl, auto& rv)->bool {
if( tpl.m_data.is_Infer() ) {
BUG(sp, "");
}
@@ -819,7 +775,7 @@ namespace {
::HIR::PathParams params;
params.m_types.push_back( ::HIR::TypeRef( mv$(tup_ents) ) );
- bool found = m_resolve.find_impl(node.span(), trait, &params, val_ty, [&](auto , bool fuzzy){
+ bool found = m_resolve.find_impl(node.span(), trait, &params, val_ty, [&](auto , bool fuzzy)->bool{
ASSERT_BUG(node.span(), !fuzzy, "Fuzzy match in check pass");
return true;
});
diff --git a/src/hir_typeck/expr_cs.cpp b/src/hir_typeck/expr_cs.cpp
index 57bad017..66baba4d 100644
--- a/src/hir_typeck/expr_cs.cpp
+++ b/src/hir_typeck/expr_cs.cpp
@@ -283,7 +283,7 @@ namespace {
//const auto& params_def = fcn.m_params;
const auto& path_params = e.m_params;
- cache.m_monomorph_cb = [&](const auto& gt)->const auto& {
+ cache.m_monomorph_cb = [&](const ::HIR::TypeRef& gt)->const ::HIR::TypeRef& {
const auto& e = gt.m_data.as_Generic();
if( e.name == "Self" || e.binding == 0xFFFF )
TODO(sp, "Handle 'Self' when monomorphising");
@@ -320,7 +320,7 @@ namespace {
const auto& trait_params = e.trait.m_params;
const auto& path_params = e.params;
- cache.m_monomorph_cb = [&](const auto& gt)->const auto& {
+ cache.m_monomorph_cb = [&](const ::HIR::TypeRef& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
return *e.type;
@@ -431,7 +431,7 @@ namespace {
// Monomorphise the impl type with the new ivars, and equate to *e.type
- auto impl_monomorph_cb = [&](const auto& gt)->const auto& {
+ auto impl_monomorph_cb = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
return context.get_type(*e.type);
@@ -464,7 +464,7 @@ namespace {
// Create monomorphise callback
const auto& fcn_params = e.params;
- cache.m_monomorph_cb = [&](const auto& gt)->const auto& {
+ cache.m_monomorph_cb = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
return context.get_type(*e.type);
@@ -1099,7 +1099,7 @@ namespace {
}
const auto& ty_params = node.m_path.m_params.m_types;
- auto monomorph_cb = [&](const auto& gt)->const auto& {
+ auto monomorph_cb = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
return ty;
@@ -1176,7 +1176,7 @@ namespace {
const ::HIR::t_struct_fields& fields = *fields_ptr;
const auto& ty_params = node.m_path.m_params.m_types;
- auto monomorph_cb = [&](const auto& gt)->const auto& {
+ auto monomorph_cb = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
return ty;
@@ -1241,22 +1241,7 @@ namespace {
this->context.equate_types(node.span(), node.m_res_type, ty);
- const auto& ty_params = node.m_path.m_params.m_types;
- auto monomorph_cb = [&](const auto& gt)->const auto& {
- const auto& ge = gt.m_data.as_Generic();
- if( ge.binding == 0xFFFF ) {
- return ty;
- }
- else if( ge.binding < 256 ) {
- if( ge.binding >= ty_params.size() ) {
- BUG(node.span(), "Type parameter index out of range (#" << ge.binding << " " << ge.name << ")");
- }
- return ty_params[ge.binding];
- }
- else {
- BUG(node.span(), "Method-level parameter on struct (#" << ge.binding << " " << ge.name << ")");
- }
- };
+ auto monomorph_cb = monomorphise_type_get_cb(node.span(), &ty, &node.m_path.m_params, nullptr);
// Convert bounds on the type into rules
apply_bounds_as_rules(context, node.span(), unm.m_params, monomorph_cb);
@@ -1542,26 +1527,7 @@ namespace {
const auto& f = this->context.m_crate.get_function_by_path(sp, e.m_path);
fix_param_count(sp, this->context, ::HIR::TypeRef(), false, e, f.m_params, e.m_params);
- const auto& params = e.m_params;
- auto monomorph_cb = [&](const auto& gt)->const auto& {
- const auto& e = gt.m_data.as_Generic();
- if( e.binding == 0xFFFF ) {
- BUG(sp, "Reference to Self in free function - " << gt);
- }
- else if( (e.binding >> 8) == 0 ) {
- BUG(sp, "Reference to impl-level param in free function - " << gt);
- }
- else if( (e.binding >> 8) == 1 ) {
- auto idx = e.binding & 0xFF;
- if( idx >= params.m_types.size() ) {
- BUG(sp, "Generic param out of input range - " << gt << " >= " << params.m_types.size());
- }
- return params.m_types[idx];
- }
- else {
- BUG(sp, "Unknown param in free function - " << gt);
- }
- };
+ auto monomorph_cb = monomorphise_type_get_cb(sp, nullptr, nullptr, &e.m_params);
::HIR::FunctionType ft {
f.m_unsafe,
@@ -1665,27 +1631,7 @@ namespace {
const auto& fcn_params = e.params;
const auto& trait_params = e.trait.m_params;
- auto monomorph_cb = [&](const auto& gt)->const auto& {
- const auto& ge = gt.m_data.as_Generic();
- if( ge.binding == 0xFFFF ) {
- return this->context.get_type(*e.type);
- }
- else if( (ge.binding >> 8) == 0 ) {
- auto idx = ge.binding;
- ASSERT_BUG(sp, idx < trait_params.m_types.size(), "Generic param out of input range - " << gt << " >= " << trait_params.m_types.size());
- return this->context.get_type(trait_params.m_types[idx]);
- }
- else if( (ge.binding >> 8) == 1 ) {
- auto idx = ge.binding & 0xFF;
- if( idx >= fcn_params.m_types.size() ) {
- BUG(sp, "Generic param out of input range - " << gt << " >= " << fcn_params.m_types.size());
- }
- return this->context.get_type(fcn_params.m_types[idx]);
- }
- else {
- BUG(sp, "Generic bounding out of total range - " << gt);
- }
- };
+ auto monomorph_cb = monomorphise_type_get_cb(sp, &*e.type, &e.trait.m_params, &e.params);
::HIR::FunctionType ft {
ie.m_unsafe, ie.m_abi,
box$( monomorphise_type_with(sp, ie.m_return, monomorph_cb) ),
@@ -1768,7 +1714,7 @@ namespace {
{
// Create monomorphise callback
const auto& fcn_params = e.params;
- auto monomorph_cb = [&](const auto& gt)->const auto& {
+ auto monomorph_cb = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
return this->context.get_type(*e.type);
@@ -2046,29 +1992,6 @@ namespace {
this->m_completed = true;
),
(Path,
- #if 0
- TU_MATCHA( (e.binding), (be),
- (Unbound,
- BUG(sp, "Encountered unbound type in _Cast Path - " << tgt_ty);
- ),
- (Opaque,
- // TODO: Bounds search
- TODO(sp, "Cast Path::Opaque with CoerceUnsized - " << tgt_ty);
- ),
- (Struct,
- if( !be->m_markings.can_coerce )
- ERROR(sp, E0000, "Non-scalar cast to " << this->context.m_ivars.fmt_type(tgt_ty));
- ),
- (Union,
- if( !be->m_markings.can_coerce )
- ERROR(sp, E0000, "Non-scalar cast to " << this->context.m_ivars.fmt_type(tgt_ty));
- ),
- (Enum,
- if( !be->m_markings.can_coerce )
- ERROR(sp, E0000, "Non-scalar cast to " << this->context.m_ivars.fmt_type(tgt_ty));
- )
- )
- #endif
this->context.equate_types_coerce(sp, tgt_ty, node.m_value);
this->m_completed = true;
return ;
@@ -2430,147 +2353,148 @@ namespace {
const auto& ty = *ty_p;
DEBUG("- ty = " << ty);
- TU_MATCH_DEF(decltype(ty.m_data), (ty.m_data), (e),
- (
- ::HIR::TypeRef fcn_args_tup;
- ::HIR::TypeRef fcn_ret;
-
- // TODO: Use `find_trait_impls` instead of two different calls
- // - This will get the TraitObject impl search too
-
- // Locate an impl of FnOnce (exists for all other Fn* traits)
- unsigned int count = 0;
- this->context.m_resolve.find_trait_impls(node.span(), lang_FnOnce, trait_pp, ty, [&](auto impl, auto cmp) {
- count ++;
-
- auto tup = impl.get_trait_ty_param(0);
- if( !tup.m_data.is_Tuple() )
- ERROR(node.span(), E0000, "FnOnce expects a tuple argument, got " << tup);
- fcn_args_tup = mv$(tup);
-
- fcn_ret = impl.get_type("Output");
- DEBUG("[visit:_CallValue] fcn_args_tup=" << fcn_args_tup << ", fcn_ret=" << fcn_ret);
- return cmp == ::HIR::Compare::Equal;
- });
- DEBUG("Found " << count << " impls of FnOnce");
- if( count > 1 ) {
- return ;
- }
- if( count == 1 )
- {
-
- // 3. Locate the most permissive implemented Fn* trait (Fn first, then FnMut, then assume just FnOnce)
- // NOTE: Borrowing is added by the expansion to CallPath
- if( this->context.m_resolve.find_trait_impls(node.span(), lang_Fn, trait_pp, ty, [&](auto impl, auto cmp) {
- // TODO: Take the value of `cmp` into account
- fcn_ret = impl.get_type("Output");
- return true;
- //return cmp == ::HIR::Compare::Equal;
- })
- )
- {
- DEBUG("-- Using Fn");
- node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::Fn;
-
- this->context.equate_types_assoc(node.span(), node.m_res_type, lang_Fn, ::make_vec1( fcn_args_tup.clone() ), ty, "Output");
- }
- else if( this->context.m_resolve.find_trait_impls(node.span(), lang_FnMut, trait_pp, ty, [&](auto impl, auto cmp) {
- // TODO: Take the value of `cmp` into account
- fcn_ret = impl.get_type("Output");
- return true;
- //return cmp == ::HIR::Compare::Equal;
- })
- )
- {
- DEBUG("-- Using FnMut");
- node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::FnMut;
-
- this->context.equate_types_assoc(node.span(), node.m_res_type, lang_FnMut, ::make_vec1( fcn_args_tup.clone() ), ty, "Output");
- }
- else
- {
- DEBUG("-- Using FnOnce (default)");
- node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::FnOnce;
-
- this->context.equate_types_assoc(node.span(), node.m_res_type, lang_FnOnce, ::make_vec1( fcn_args_tup.clone() ), ty, "Output");
- }
-
- // If the return type wasn't found in the impls, emit it as a UFCS
- if( fcn_ret == ::HIR::TypeRef() )
- {
- fcn_ret = ::HIR::TypeRef( ::HIR::Path(::HIR::Path::Data::make_UfcsKnown({
- box$( ty.clone() ),
- // - Clone argument tuple, as it's stolen into cache below
- ::HIR::GenericPath(lang_FnOnce, ::HIR::PathParams( fcn_args_tup.clone() )),
- "Output",
- {}
- })) );
- }
- }
- else TU_IFLET( ::HIR::TypeRef::Data, ty.m_data, Borrow, e,
- deref_count ++;
- ty_p = &this->context.get_type(*e.inner);
- DEBUG("Deref " << ty << " -> " << *ty_p);
- keep_looping = true;
- continue ;
- )
- else
- {
- if( !ty.m_data.is_Generic() )
- {
- bool found = this->context.m_resolve.find_trait_impls_crate(node.span(), lang_FnOnce, trait_pp, ty, [&](auto impl, auto cmp) {
- if( cmp == ::HIR::Compare::Fuzzy )
- TODO(node.span(), "Handle fuzzy match - " << impl);
-
- auto tup = impl.get_trait_ty_param(0);
- if( !tup.m_data.is_Tuple() )
- ERROR(node.span(), E0000, "FnOnce expects a tuple argument, got " << tup);
- fcn_args_tup = mv$(tup);
- fcn_ret = impl.get_type("Output");
- ASSERT_BUG(node.span(), fcn_ret != ::HIR::TypeRef(), "Impl didn't have a type for Output - " << impl);
- return true;
- });
- if( found ) {
- // Fill cache and leave the TU_MATCH
- node.m_arg_types = mv$( fcn_args_tup.m_data.as_Tuple() );
- node.m_arg_types.push_back( mv$(fcn_ret) );
- node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::Unknown;
- break ; // leaves TU_MATCH
- }
- }
- if( const auto* next_ty_p = this->context.m_resolve.autoderef(node.span(), ty, tmp_type) )
- {
- DEBUG("Deref (autoderef) " << ty << " -> " << *next_ty_p);
- deref_count ++;
- ty_p = next_ty_p;
- keep_looping = true;
- continue ;
- }
-
- // Didn't find anything. Error?
- ERROR(node.span(), E0000, "Unable to find an implementation of Fn*"<<trait_pp<<" for " << this->context.m_ivars.fmt_type(ty));
- }
-
- node.m_arg_types = mv$( fcn_args_tup.m_data.as_Tuple() );
- node.m_arg_types.push_back( mv$(fcn_ret) );
- ),
- (Closure,
- for( const auto& arg : e.m_arg_types )
- node.m_arg_types.push_back( arg.clone() );
- node.m_arg_types.push_back( e.m_rettype->clone() );
- node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::Unknown;
- ),
- (Function,
- for( const auto& arg : e.m_arg_types )
- node.m_arg_types.push_back( arg.clone() );
- node.m_arg_types.push_back( e.m_rettype->clone() );
- node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::Fn;
- ),
- (Infer,
- // No idea yet
- return ;
- )
- )
+ if( const auto* e = ty.m_data.opt_Closure() )
+ {
+ for( const auto& arg : e->m_arg_types )
+ node.m_arg_types.push_back(arg.clone());
+ node.m_arg_types.push_back(e->m_rettype->clone());
+ node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::Unknown;
+ }
+ else if( const auto* e = ty.m_data.opt_Function() )
+ {
+ for( const auto& arg : e->m_arg_types )
+ node.m_arg_types.push_back(arg.clone());
+ node.m_arg_types.push_back(e->m_rettype->clone());
+ node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::Fn;
+ }
+ else if( ty.m_data.is_Infer() )
+ {
+ // No idea yet
+ return ;
+ }
+ else
+ {
+ ::HIR::TypeRef fcn_args_tup;
+ ::HIR::TypeRef fcn_ret;
+
+ // TODO: Use `find_trait_impls` instead of two different calls
+ // - This will get the TraitObject impl search too
+
+ // Locate an impl of FnOnce (exists for all other Fn* traits)
+ unsigned int count = 0;
+ this->context.m_resolve.find_trait_impls(node.span(), lang_FnOnce, trait_pp, ty, [&](auto impl, auto cmp)->bool {
+ count++;
+
+ auto tup = impl.get_trait_ty_param(0);
+ if (!tup.m_data.is_Tuple())
+ ERROR(node.span(), E0000, "FnOnce expects a tuple argument, got " << tup);
+ fcn_args_tup = mv$(tup);
+
+ fcn_ret = impl.get_type("Output");
+ DEBUG("[visit:_CallValue] fcn_args_tup=" << fcn_args_tup << ", fcn_ret=" << fcn_ret);
+ return cmp == ::HIR::Compare::Equal;
+ });
+ DEBUG("Found " << count << " impls of FnOnce");
+ if(count > 1) {
+ return;
+ }
+ if(count == 1)
+ {
+
+ // 3. Locate the most permissive implemented Fn* trait (Fn first, then FnMut, then assume just FnOnce)
+ // NOTE: Borrowing is added by the expansion to CallPath
+ if( this->context.m_resolve.find_trait_impls(node.span(), lang_Fn, trait_pp, ty, [&](auto impl, auto cmp) {
+ // TODO: Take the value of `cmp` into account
+ fcn_ret = impl.get_type("Output");
+ return true;
+ //return cmp == ::HIR::Compare::Equal;
+ }) )
+ {
+ DEBUG("-- Using Fn");
+ node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::Fn;
+
+ this->context.equate_types_assoc(node.span(), node.m_res_type, lang_Fn, ::make_vec1(fcn_args_tup.clone()), ty, "Output");
+ }
+ else if( this->context.m_resolve.find_trait_impls(node.span(), lang_FnMut, trait_pp, ty, [&](auto impl, auto cmp) {
+ // TODO: Take the value of `cmp` into account
+ fcn_ret = impl.get_type("Output");
+ return true;
+ //return cmp == ::HIR::Compare::Equal;
+ }) )
+ {
+ DEBUG("-- Using FnMut");
+ node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::FnMut;
+
+ this->context.equate_types_assoc(node.span(), node.m_res_type, lang_FnMut, ::make_vec1(fcn_args_tup.clone()), ty, "Output");
+ }
+ else
+ {
+ DEBUG("-- Using FnOnce (default)");
+ node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::FnOnce;
+
+ this->context.equate_types_assoc(node.span(), node.m_res_type, lang_FnOnce, ::make_vec1(fcn_args_tup.clone()), ty, "Output");
+ }
+
+ // If the return type wasn't found in the impls, emit it as a UFCS
+ if(fcn_ret == ::HIR::TypeRef())
+ {
+ fcn_ret = ::HIR::TypeRef(::HIR::Path(::HIR::Path::Data::make_UfcsKnown({
+ box$(ty.clone()),
+ // - Clone argument tuple, as it's stolen into cache below
+ ::HIR::GenericPath(lang_FnOnce, ::HIR::PathParams(fcn_args_tup.clone())),
+ "Output",
+ {}
+ })));
+ }
+ }
+ else if( const auto* e = ty.m_data.opt_Borrow() )
+ {
+ deref_count++;
+ ty_p = &this->context.get_type(*e->inner);
+ DEBUG("Deref " << ty << " -> " << *ty_p);
+ keep_looping = true;
+ continue;
+ }
+ else
+ {
+ if( !ty.m_data.is_Generic() )
+ {
+ bool found = this->context.m_resolve.find_trait_impls_crate(node.span(), lang_FnOnce, trait_pp, ty, [&](auto impl, auto cmp)->bool {
+ if (cmp == ::HIR::Compare::Fuzzy)
+ TODO(node.span(), "Handle fuzzy match - " << impl);
+
+ auto tup = impl.get_trait_ty_param(0);
+ if (!tup.m_data.is_Tuple())
+ ERROR(node.span(), E0000, "FnOnce expects a tuple argument, got " << tup);
+ fcn_args_tup = mv$(tup);
+ fcn_ret = impl.get_type("Output");
+ ASSERT_BUG(node.span(), fcn_ret != ::HIR::TypeRef(), "Impl didn't have a type for Output - " << impl);
+ return true;
+ });
+ if (found) {
+ // Fill cache and leave the TU_MATCH
+ node.m_arg_types = mv$(fcn_args_tup.m_data.as_Tuple());
+ node.m_arg_types.push_back(mv$(fcn_ret));
+ node.m_trait_used = ::HIR::ExprNode_CallValue::TraitUsed::Unknown;
+ break; // leaves TU_MATCH
+ }
+ }
+ if( const auto* next_ty_p = this->context.m_resolve.autoderef(node.span(), ty, tmp_type) )
+ {
+ DEBUG("Deref (autoderef) " << ty << " -> " << *next_ty_p);
+ deref_count++;
+ ty_p = next_ty_p;
+ keep_looping = true;
+ continue;
+ }
+
+ // Didn't find anything. Error?
+ ERROR(node.span(), E0000, "Unable to find an implementation of Fn*" << trait_pp << " for " << this->context.m_ivars.fmt_type(ty));
+ }
+
+ node.m_arg_types = mv$(fcn_args_tup.m_data.as_Tuple());
+ node.m_arg_types.push_back(mv$(fcn_ret));
+ }
} while( keep_looping );
if( deref_count > 0 )
@@ -3168,13 +3092,13 @@ void Context::equate_types(const Span& sp, const ::HIR::TypeRef& li, const ::HIR
// Instantly apply equality
TRACE_FUNCTION_F(li << " == " << ri);
- visit_ty_with(ri, [&](const auto& ty) {
+ visit_ty_with(ri, [&](const auto& ty)->bool {
if( ty.m_data.is_Generic() && ty.m_data.as_Generic().binding >> 8 == 2 ) {
BUG(sp, "Type contained an impl placeholder parameter - " << ri);
}
return false;
});
- visit_ty_with(li, [&](const auto& ty) {
+ visit_ty_with(li, [&](const auto& ty)->bool {
if( ty.m_data.is_Generic() && ty.m_data.as_Generic().binding >> 8 == 2 ) {
BUG(sp, "Type contained an impl placeholder parameter - " << li);
}
@@ -4087,7 +4011,7 @@ void fix_param_count_(const Span& sp, Context& context, const ::HIR::TypeRef& se
ERROR(sp, E0000, "Omitted type parameter with no default in " << path);
}
else if( monomorphise_type_needed(typ.m_default) ) {
- auto cb = [&](const auto& ty)->const auto& {
+ auto cb = [&](const auto& ty)->const ::HIR::TypeRef& {
const auto& ge = ty.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
ASSERT_BUG(sp, self_ty != ::HIR::TypeRef(), "Self not allowed in this context");
@@ -4304,7 +4228,7 @@ namespace {
}
}
- add_coerce_borrow(context, node_ptr, types.back(), [&](auto& node_ptr) {
+ add_coerce_borrow(context, node_ptr, types.back(), [&](auto& node_ptr)->void {
// node_ptr = node that yeilds ty_src
assert( count == types.size() );
for(unsigned int i = 0; i < types.size(); i ++ )
@@ -4502,7 +4426,7 @@ namespace {
bool fuzzy_match = false;
ImplRef best_impl;
- bool found = context.m_resolve.find_trait_impls(sp, lang_CoerceUnsized, pp, ty_src, [&](auto impl, auto cmp) {
+ bool found = context.m_resolve.find_trait_impls(sp, lang_CoerceUnsized, pp, ty_src, [&](auto impl, auto cmp)->bool {
DEBUG("[check_coerce] cmp=" << cmp << ", impl=" << impl);
// TODO: Allow fuzzy match if it's the only matching possibility?
// - Recorded for now to know if there could be a matching impl later
@@ -4707,7 +4631,6 @@ namespace {
// If the coercion is of a block, do the reborrow on the last node of the block
// - Cleans up the dumped MIR and prevents needing a reborrow elsewhere.
- #if 1
::HIR::ExprNodeP* npp = &node_ptr;
while( auto* p = dynamic_cast< ::HIR::ExprNode_Block*>(&**npp) )
{
@@ -4721,7 +4644,6 @@ namespace {
npp = &p->m_nodes.back();
}
::HIR::ExprNodeP& node_ptr = *npp;
- #endif
// Add cast down
auto span = node_ptr->span();
diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp
index c29bc64b..1bf2cafd 100644
--- a/src/hir_typeck/helpers.cpp
+++ b/src/hir_typeck/helpers.cpp
@@ -930,7 +930,7 @@ void TraitResolution::prep_indexes()
this->m_type_equalities.insert(::std::make_pair( mv$(long_ty), mv$(short_ty) ));
};
- this->iterate_bounds([&](const auto& b) {
+ this->iterate_bounds([&](const auto& b)->bool {
TU_MATCH_DEF(::HIR::GenericBound, (b), (be),
(
),
@@ -945,7 +945,7 @@ void TraitResolution::prep_indexes()
}
const auto& trait_params = be.trait.m_path.m_params;
- auto cb_mono = [&](const auto& ty)->const auto& {
+ auto cb_mono = [&](const auto& ty)->const ::HIR::TypeRef& {
const auto& ge = ty.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
return be.type;
@@ -1955,7 +1955,7 @@ void TraitResolution::expand_associated_types_inplace__UfcsKnown(const Span& sp,
// 1. Bounds
bool rv;
bool assume_opaque = true;
- rv = this->iterate_bounds([&](const auto& b) {
+ rv = this->iterate_bounds([&](const auto& b)->bool {
TU_MATCH_DEF(::HIR::GenericBound, (b), (be),
(
),
@@ -2055,7 +2055,7 @@ void TraitResolution::expand_associated_types_inplace__UfcsKnown(const Span& sp,
DEBUG("TODO: Search bounds on associated type - " << assoc_ty.m_trait_bounds);
// Resolve where Self=pe_inner.type (i.e. for the trait this inner UFCS is on)
- auto cb_placeholders_trait = [&](const auto& ty)->const auto&{
+ auto cb_placeholders_trait = [&](const auto& ty)->const ::HIR::TypeRef&{
TU_IFLET(::HIR::TypeRef::Data, ty.m_data, Generic, e,
if( e.binding == 0xFFFF )
return *pe_inner.type;
@@ -2104,7 +2104,7 @@ void TraitResolution::expand_associated_types_inplace__UfcsKnown(const Span& sp,
unsigned int count = 0;
bool is_specialisable = false;
ImplRef best_impl;
- rv = this->find_trait_impls_crate(sp, trait_path.m_path, trait_path.m_params, *pe.type, [&](auto impl, auto qual) {
+ rv = this->find_trait_impls_crate(sp, trait_path.m_path, trait_path.m_params, *pe.type, [&](auto impl, auto qual)->bool {
DEBUG("[expand_associated_types__UfcsKnown] Found " << impl << " qual=" << qual);
// If it's a fuzzy match, keep going (but count if a concrete hasn't been found)
if( qual == ::HIR::Compare::Fuzzy ) {
@@ -2138,8 +2138,8 @@ void TraitResolution::expand_associated_types_inplace__UfcsKnown(const Span& sp,
if( ty == ::HIR::TypeRef() )
ERROR(sp, E0000, "Couldn't find assocated type " << pe.item << " in " << pe.trait);
- if( impl.has_magic_params() )
- ;
+ if( impl.has_magic_params() ) {
+ }
// TODO: What if there's multiple impls?
DEBUG("Converted UfcsKnown - " << e.path << " = " << ty);
@@ -2207,7 +2207,7 @@ bool TraitResolution::find_named_trait_in_trait(const Span& sp,
BUG(sp, "Incorrect number of parameters for trait");
}
- const auto monomorph_cb = [&](const auto& gt)->const auto& {
+ const auto monomorph_cb = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
return target_type;
@@ -2252,7 +2252,7 @@ bool TraitResolution::find_trait_impls_bound(const Span& sp, const ::HIR::Simple
// TODO: A bound can imply something via its associated types. How deep can this go?
// E.g. `T: IntoIterator<Item=&u8>` implies `<T as IntoIterator>::IntoIter : Iterator<Item=&u8>`
- return this->iterate_bounds([&](const auto& b) {
+ return this->iterate_bounds([&](const auto& b)->bool {
if( b.is_TraitBound() )
{
const auto& e = b.as_TraitBound();
@@ -2326,7 +2326,7 @@ bool TraitResolution::find_trait_impls_bound(const Span& sp, const ::HIR::Simple
for(const auto& bound : at.m_trait_bounds) {
if( bound.m_path.m_path == trait )
{
- auto monomorph_cb = [&](const auto& gt)->const auto& {
+ auto monomorph_cb = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
return *assoc_info->type;
@@ -2454,7 +2454,7 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
DEBUG("- Search positive impls");
bool positive_found = false;
this->m_crate.find_auto_trait_impls(trait, type, this->m_ivars.callback_resolve_infer(),
- [&](const auto& impl) {
+ [&](const auto& impl)->bool {
// Skip any negative impls on this pass
if( impl.is_positive != true )
return false;
@@ -2470,7 +2470,7 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
return false;
}
- auto monomorph = [&](const auto& gt)->const auto& {
+ auto monomorph = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
ASSERT_BUG(sp, ge.binding >> 8 != 2, "");
assert( ge.binding < impl_params.size() );
@@ -2573,7 +2573,7 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
TU_MATCH( ::HIR::Path::Data, (e.path.m_data), (pe),
(Generic,
::HIR::TypeRef tmp;
- auto monomorph_cb = [&](const auto& gt)->const auto& {
+ auto monomorph_cb = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
BUG(sp, "Self type in struct/enum generics");
@@ -2588,7 +2588,7 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
}
};
// HELPER: Get a possibily monomorphised version of the input type (stored in `tmp` if needed)
- auto monomorph_get = [&](const auto& ty)->const auto& {
+ auto monomorph_get = [&](const auto& ty)->const ::HIR::TypeRef& {
if( monomorphise_type_needed(ty) ) {
return (tmp = monomorphise_type_with(sp, ty, monomorph_cb));
}
@@ -2714,7 +2714,7 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
) const
{
impl_params.resize( impl_params_def.m_types.size() );
- auto cb = [&](auto idx, const auto& ty) {
+ auto cb = [&](auto idx, const auto& ty)->::HIR::Compare{
DEBUG("[ftic_check_params] Param " << idx << " = " << ty);
assert( idx < impl_params.size() );
if( ! impl_params[idx] ) {
@@ -2727,7 +2727,7 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
}
};
- //auto cb_res = [&](const auto& ty)->const auto& {
+ //auto cb_res = [&](const auto& ty)->const ::HIR::TypeRef& {
// if( ty.m_data.is_Infer() ) {
// return this->m_ivars.get_type(ty);
// }
@@ -2771,7 +2771,7 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
placeholders[i] = ::HIR::TypeRef("impl_?", 2*256 + i);
}
}
- auto cb_infer = [&](const auto& ty)->const auto& {
+ auto cb_infer = [&](const auto& ty)->const ::HIR::TypeRef& {
if( ty.m_data.is_Infer() )
return this->m_ivars.get_type(ty);
#if 0
@@ -2796,7 +2796,7 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
else
return ty;
};
- auto cb_match = [&](unsigned int idx, const auto& ty) {
+ auto cb_match = [&](unsigned int idx, const auto& ty)->::HIR::Compare {
if( ty.m_data.is_Generic() && ty.m_data.as_Generic().binding == idx )
return ::HIR::Compare::Equal;
if( idx >> 8 == 2 ) {
@@ -2816,7 +2816,7 @@ bool TraitResolution::find_trait_impls_crate(const Span& sp,
return ::HIR::Compare::Unequal;
}
};
- auto monomorph = [&](const auto& gt)->const auto& {
+ auto monomorph = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
ASSERT_BUG(sp, ge.binding >> 8 != 2, "");
assert( ge.binding < impl_params.size() );
@@ -2964,20 +2964,7 @@ bool TraitResolution::trait_contains_method(const Span& sp, const ::HIR::Generic
return true;
}
- auto monomorph_cb = [&](const auto& gt)->const auto& {
- const auto& ge = gt.m_data.as_Generic();
- if( ge.binding == 0xFFFF ) {
- return self;
- }
- else if( (ge.binding >> 8) == 0 ) {
- auto idx = ge.binding & 0xFF;
- assert(idx < trait_path.m_params.m_types.size());
- return trait_path.m_params.m_types[ge.binding];
- }
- else {
- BUG(sp, "Unexpected type parameter " << gt);
- }
- };
+ auto monomorph_cb = monomorphise_type_get_cb(sp, &self, &trait_path.m_params, nullptr);
for(const auto& st : trait_ptr.m_all_parent_traits)
{
if( trait_contains_method_(*st.m_trait_ptr, name, ar) )
@@ -3000,7 +2987,7 @@ bool TraitResolution::trait_contains_type(const Span& sp, const ::HIR::GenericPa
return true;
}
- auto monomorph_cb = [&](const auto& gt)->const auto& {
+ auto monomorph_cb = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
assert(ge.binding < 256);
assert(ge.binding < trait_path.m_params.m_types.size());
@@ -3027,7 +3014,7 @@ bool TraitResolution::trait_contains_type(const Span& sp, const ::HIR::GenericPa
const auto& lang_Copy = this->m_crate.get_lang_item_path(sp, "copy");
// NOTE: Don't use find_trait_impls, because that calls this
bool is_fuzzy = false;
- bool has_eq = find_trait_impls_crate(sp, lang_Copy, ::HIR::PathParams{}, ty, [&](auto , auto c){
+ bool has_eq = find_trait_impls_crate(sp, lang_Copy, ::HIR::PathParams{}, ty, [&](auto , auto c)->bool{
switch(c)
{
case ::HIR::Compare::Equal: return true;
@@ -3063,7 +3050,7 @@ bool TraitResolution::trait_contains_type(const Span& sp, const ::HIR::GenericPa
(Generic,
// TODO: Store this result - or even pre-calculate it.
const auto& lang_Copy = this->m_crate.get_lang_item_path(sp, "copy");
- return this->iterate_bounds([&](const auto& b) {
+ return this->iterate_bounds([&](const auto& b)->bool {
TU_IFLET(::HIR::GenericBound, b, TraitBound, be,
if(be.type == ty)
{
@@ -3072,7 +3059,7 @@ bool TraitResolution::trait_contains_type(const Span& sp, const ::HIR::GenericPa
::HIR::PathParams pp;
bool rv = this->find_named_trait_in_trait(sp,
lang_Copy,pp, *be.trait.m_trait_ptr, be.trait.m_path.m_path, be.trait.m_path.m_params, type,
- [&](const auto& , const auto&, const auto&) { return true; }
+ [&](const auto& , const auto&, const auto&)->bool { return true; }
);
if(rv)
return true;
@@ -3409,7 +3396,7 @@ bool TraitResolution::find_method(
// `Self` = `*e.type`
// `/*I:#*/` := `e.trait.m_params`
- auto monomorph_cb = [&](const auto& gt)->const auto& {
+ auto monomorph_cb = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
return *e.type;
@@ -3572,7 +3559,7 @@ bool TraitResolution::find_method(
::HIR::PathParams trait_params;
trait_params.m_types.reserve( n_params );
for(unsigned int i = 0; i < n_params; i++) {
- trait_params.m_types.push_back( ::HIR::TypeRef( ::HIR::TypeRef::Data::make_Infer({ ivars[i], ::HIR::InferClass::None }) ) );
+ trait_params.m_types.push_back( ::HIR::TypeRef::new_infer(ivars[i], ::HIR::InferClass::None) );
ASSERT_BUG(sp, m_ivars.get_type( trait_params.m_types.back() ).m_data.as_Infer().index == ivars[i], "A method selection ivar was bound");
}
@@ -3649,7 +3636,7 @@ bool TraitResolution::find_field(const Span& sp, const ::HIR::TypeRef& ty, const
// Has fields!
const auto& str = *be;
const auto& params = e.path.m_data.as_Generic().m_params;
- auto monomorph = [&](const auto& gt)->const auto& {
+ auto monomorph = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == 0xFFFF )
TODO(sp, "Monomorphise struct field types (Self) - " << gt);
@@ -3694,7 +3681,7 @@ bool TraitResolution::find_field(const Span& sp, const ::HIR::TypeRef& ty, const
(Union,
const auto& unm = *be;
const auto& params = e.path.m_data.as_Generic().m_params;
- auto monomorph = [&](const auto& gt)->const auto& {
+ auto monomorph = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == 0xFFFF )
TODO(sp, "Monomorphise union field types (Self) - " << gt);
diff --git a/src/hir_typeck/impl_ref.cpp b/src/hir_typeck/impl_ref.cpp
index 81f018b4..d3cfd215 100644
--- a/src/hir_typeck/impl_ref.cpp
+++ b/src/hir_typeck/impl_ref.cpp
@@ -86,7 +86,7 @@ bool ImplRef::type_is_specialisable(const char* name) const
::std::function<const ::HIR::TypeRef&(const ::HIR::TypeRef&)> ImplRef::get_cb_monomorph_traitimpl(const Span& sp) const
{
const auto& e = this->m_data.as_TraitImpl();
- return [this,&e,&sp](const auto& gt)->const auto& {
+ return [this,&e,&sp](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
// Store (or cache) a monomorphisation of Self, and error if this recurses
diff --git a/src/hir_typeck/static.cpp b/src/hir_typeck/static.cpp
index 5fec2477..3bae5ba8 100644
--- a/src/hir_typeck/static.cpp
+++ b/src/hir_typeck/static.cpp
@@ -23,7 +23,7 @@ void StaticTraitResolve::prep_indexes()
this->m_type_equalities.insert(::std::make_pair( mv$(long_ty), mv$(short_ty) ));
};
- this->iterate_bounds([&](const auto& b) {
+ this->iterate_bounds([&](const auto& b)->bool {
TU_MATCH_DEF(::HIR::GenericBound, (b), (be),
(
),
@@ -38,7 +38,7 @@ void StaticTraitResolve::prep_indexes()
}
const auto& trait_params = be.trait.m_path.m_params;
- auto cb_mono = [&](const auto& ty)->const auto& {
+ auto cb_mono = [&](const auto& ty)->const ::HIR::TypeRef& {
const auto& ge = ty.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
return be.type;
@@ -93,7 +93,7 @@ bool StaticTraitResolve::find_impl(
) const
{
TRACE_FUNCTION_F(trait_path << FMT_CB(os, if(trait_params) { os << *trait_params; } else { os << "<?>"; }) << " for " << type);
- auto cb_ident = [](const auto&ty)->const auto&{return ty;};
+ auto cb_ident = [](const ::HIR::TypeRef&ty)->const ::HIR::TypeRef& { return ty; };
static ::HIR::PathParams null_params;
static ::std::map< ::std::string, ::HIR::TypeRef> null_assoc;
@@ -299,23 +299,39 @@ bool StaticTraitResolve::find_impl(
if( m_crate.get_trait_by_path(sp, trait_path).m_is_marker )
{
+ struct H {
+ static bool find_impl__auto_trait_check(const StaticTraitResolve& self,
+ const Span& sp, const ::HIR::SimplePath& trait_path, const ::HIR::PathParams* trait_params, const ::HIR::TypeRef& type,
+ t_cb_find_impl found_cb,
+ const ::HIR::MarkerImpl& impl, bool& out_rv
+ )
+ {
+ DEBUG("- Auto " << (impl.is_positive ? "Pos" : "Neg")
+ << " impl" << impl.m_params.fmt_args() << " " << trait_path << impl.m_trait_args << " for " << impl.m_type << " " << impl.m_params.fmt_bounds());
+ if (impl.is_positive)
+ {
+ return self.find_impl__check_crate_raw(sp, trait_path, trait_params, type, impl.m_params, impl.m_trait_args, impl.m_type,
+ [&](auto impl_params, auto placeholders, auto cmp)->bool {
+ //rv = found_cb( ImplRef(impl_params, trait_path, impl, mv$(placeholders)), (cmp == ::HIR::Compare::Fuzzy) );
+ out_rv = found_cb(ImplRef(&type, trait_params, &null_assoc), cmp == ::HIR::Compare::Fuzzy);
+ return out_rv;
+ });
+ }
+ else
+ {
+ return self.find_impl__check_crate_raw(sp, trait_path, trait_params, type, impl.m_params, impl.m_trait_args, impl.m_type,
+ [&](auto impl_params, auto placeholders, auto cmp)->bool {
+ out_rv = false;
+ return true;
+ });
+ }
+ }
+ };
+
// Positive/negative impls
bool rv = false;
- ret = this->m_crate.find_auto_trait_impls(trait_path, type, cb_ident, [&](const auto& impl) {
- DEBUG("[find_impls] - Auto " << (impl.is_positive?"Pos":"Neg")
- << " impl" << impl.m_params.fmt_args() << " " << trait_path << impl.m_trait_args << " for " << impl.m_type << " " << impl.m_params.fmt_bounds());
- return this->find_impl__check_crate_raw(sp, trait_path, trait_params, type, impl.m_params, impl.m_trait_args, impl.m_type,
- [&](auto impl_params, auto placeholders, auto cmp) {
- if( impl.is_positive ) {
- //rv = found_cb( ImplRef(impl_params, trait_path, impl, mv$(placeholders)), (match == ::HIR::Compare::Fuzzy) );
- rv = found_cb( ImplRef(&type, trait_params, &null_assoc), cmp == ::HIR::Compare::Fuzzy );
- return rv;
- }
- else {
- rv = false;
- return true;
- }
- });
+ ret = this->m_crate.find_auto_trait_impls(trait_path, type, cb_ident, [&](const auto& impl)->bool {
+ return H::find_impl__auto_trait_check(*this, sp, trait_path, trait_params, type, found_cb, impl, rv);
});
if(ret)
return rv;
@@ -436,7 +452,7 @@ bool StaticTraitResolve::find_impl__check_bound(
if( bound.m_path.m_path == trait_path && (!trait_params || H::compare_pp(sp, bound.m_path.m_params, *trait_params)) ) {
DEBUG("- Found an associated type impl");
- auto tp_mono = monomorphise_traitpath_with(sp, bound, [&assoc_info,&sp](const auto& gt)->const auto& {
+ auto tp_mono = monomorphise_traitpath_with(sp, bound, [&assoc_info,&sp](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
return *assoc_info->type;
@@ -470,7 +486,7 @@ bool StaticTraitResolve::find_impl__check_crate_raw(
::std::function<bool(::std::vector<const ::HIR::TypeRef*>, ::std::vector<::HIR::TypeRef>, ::HIR::Compare)> found_cb
) const
{
- auto cb_ident = [](const auto&ty)->const auto&{return ty;};
+ auto cb_ident = [](const auto&ty)->const ::HIR::TypeRef&{return ty;};
TRACE_FUNCTION_F("impl" << impl_params_def.fmt_args() << " " << des_trait_path << impl_trait_params << " for " << impl_type << impl_params_def.fmt_bounds());
::std::vector< const ::HIR::TypeRef*> impl_params;
@@ -511,7 +527,7 @@ bool StaticTraitResolve::find_impl__check_crate_raw(
}
}
// Callback that matches placeholders to concrete types
- auto cb_match = [&](unsigned int idx, const auto& ty) {
+ auto cb_match = [&](unsigned int idx, const auto& ty)->::HIR::Compare {
if( ty.m_data.is_Generic() && ty.m_data.as_Generic().binding == idx )
return ::HIR::Compare::Equal;
if( idx >> 8 == 2 ) {
@@ -532,7 +548,7 @@ bool StaticTraitResolve::find_impl__check_crate_raw(
}
};
// Callback that returns monomorpisation results
- auto cb_monomorph = [&](const auto& gt)->const auto& {
+ auto cb_monomorph = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
ASSERT_BUG(sp, ge.binding >> 8 != 2, "");
assert( ge.binding < impl_params.size() );
@@ -544,10 +560,10 @@ bool StaticTraitResolve::find_impl__check_crate_raw(
// Bounds
for(const auto& bound : impl_params_def.m_bounds) {
- TU_MATCH_DEF(::HIR::GenericBound, (bound), (e),
- (
- ),
- (TraitBound,
+ if( const auto* ep = bound.opt_TraitBound() )
+ {
+ const auto& e = *ep;
+
DEBUG("[find_impl] Trait bound " << e.type << " : " << e.trait);
auto b_ty_mono = monomorphise_type_with(sp, e.type, cb_monomorph);
this->expand_associated_types(sp, b_ty_mono);
@@ -581,7 +597,7 @@ bool StaticTraitResolve::find_impl__check_crate_raw(
rv = true;
}
else {
- rv = this->find_impl(sp, aty_src_trait.m_path, aty_src_trait.m_params, b_ty_mono, [&](const auto& impl, bool) {
+ rv = this->find_impl(sp, aty_src_trait.m_path, aty_src_trait.m_params, b_ty_mono, [&](const auto& impl, bool)->bool {
::HIR::TypeRef have = impl.get_type(aty_name.c_str());
this->expand_associated_types(sp, have);
@@ -613,8 +629,11 @@ bool StaticTraitResolve::find_impl__check_crate_raw(
return false;
}
}
- )
- )
+ }
+ else // bound.opt_TraitBound()
+ {
+ // Ignore
+ }
}
return found_cb( mv$(impl_params), mv$(placeholders), match );
@@ -650,12 +669,14 @@ bool StaticTraitResolve::find_impl__check_crate(
};
// - If the type is a path (struct/enum/...), search for impls for all contained types.
- TU_IFLET( ::HIR::TypeRef::Data, type.m_data, Path, e,
+ if( const auto* ep = type.m_data.opt_Path() )
+ {
+ const auto& e = *ep;
::HIR::Compare res = ::HIR::Compare::Equal;
TU_MATCH( ::HIR::Path::Data, (e.path.m_data), (pe),
(Generic,
::HIR::TypeRef tmp;
- auto monomorph_cb = [&](const auto& gt)->const auto& {
+ auto monomorph_cb = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
BUG(sp, "Self type in struct/enum generics");
@@ -670,7 +691,7 @@ bool StaticTraitResolve::find_impl__check_crate(
}
};
// HELPER: Get a possibily monomorphised version of the input type (stored in `tmp` if needed)
- auto monomorph_get = [&](const auto& ty)->const auto& {
+ auto monomorph_get = [&](const auto& ty)->const ::HIR::TypeRef& {
if( monomorphise_type_needed(ty) ) {
tmp = monomorphise_type_with(sp, ty, monomorph_cb);
this->expand_associated_types(sp, tmp);
@@ -771,20 +792,22 @@ bool StaticTraitResolve::find_impl__check_crate(
)
)
return res;
- )
- else TU_IFLET( ::HIR::TypeRef::Data, type.m_data, Tuple, e,
+ }
+ else if( const auto* ep = type.m_data.opt_Tuple() )
+ {
::HIR::Compare res = ::HIR::Compare::Equal;
- for(const auto& sty : e)
+ for(const auto& sty : *ep)
{
res &= type_impls_trait(sty);
if( res == ::HIR::Compare::Unequal )
return ::HIR::Compare::Unequal;
}
return res;
- )
- else TU_IFLET( ::HIR::TypeRef::Data, type.m_data, Array, e,
- return type_impls_trait(*e.inner);
- )
+ }
+ else if( const auto* e = type.m_data.opt_Array() )
+ {
+ return type_impls_trait(*e->inner);
+ }
// Otherwise, there's no negative so it must be positive
else {
return ::HIR::Compare::Equal;
@@ -926,11 +949,10 @@ void StaticTraitResolve::expand_associated_types__UfcsKnown(const Span& sp, ::HI
// 1. Bounds
bool rv;
bool assume_opaque = true;
- rv = this->iterate_bounds([&](const auto& b) {
- TU_MATCH_DEF(::HIR::GenericBound, (b), (be),
- (
- ),
- (TraitBound,
+ rv = this->iterate_bounds([&](const auto& b)->bool {
+ if( const auto* bep = b.opt_TraitBound() )
+ {
+ const auto& be = *bep;
DEBUG("Trait bound - " << be.type << " : " << be.trait);
// 1. Check if the type matches
// - TODO: This should be a fuzzier match?
@@ -982,15 +1004,20 @@ void StaticTraitResolve::expand_associated_types__UfcsKnown(const Span& sp, ::HI
}
// - Didn't match
- ),
- (TypeEquality,
+ }
+ else if( const auto* bep = b.opt_TypeEquality() )
+ {
+ const auto& be = *bep;
DEBUG("Equality - " << be.type << " = " << be.other_type);
if( input == be.type ) {
input = be.other_type.clone();
return true;
}
- )
- )
+ }
+ else
+ {
+ // Nothing.
+ }
return false;
});
if( rv ) {
@@ -1014,7 +1041,7 @@ void StaticTraitResolve::expand_associated_types__UfcsKnown(const Span& sp, ::HI
const auto& assoc_ty = trait_ptr.m_types.at(pe_inner.item);
// Resolve where Self=pe_inner.type (i.e. for the trait this inner UFCS is on)
- auto cb_placeholders_trait = [&](const auto& ty)->const auto&{
+ auto cb_placeholders_trait = [&](const auto& ty)->const ::HIR::TypeRef&{
TU_IFLET(::HIR::TypeRef::Data, ty.m_data, Generic, e,
if( e.binding == 0xFFFF )
return *pe_inner.type;
@@ -1158,7 +1185,7 @@ bool StaticTraitResolve::find_named_trait_in_trait(const Span& sp,
BUG(sp, "Incorrect number of parameters for trait - " << trait_path << pp);
}
- auto monomorph_cb = [&](const auto& gt)->const auto& {
+ auto monomorph_cb = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
if( ge.binding == 0xFFFF ) {
return target_type;
@@ -1193,7 +1220,7 @@ bool StaticTraitResolve::trait_contains_type(const Span& sp, const ::HIR::Generi
return true;
}
- auto monomorph = [&](const auto& gt)->const auto& {
+ auto monomorph = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& ge = gt.m_data.as_Generic();
assert(ge.binding < 256);
assert(ge.binding < trait_path.m_params.m_types.size());
@@ -1222,7 +1249,7 @@ bool StaticTraitResolve::type_is_copy(const Span& sp, const ::HIR::TypeRef& ty)
return it->second;
}
}
- bool rv = this->iterate_bounds([&](const auto& b) {
+ bool rv = this->iterate_bounds([&](const auto& b)->bool {
auto pp = ::HIR::PathParams();
return this->find_impl__check_bound(sp, m_lang_Copy, &pp, ty, [&](auto , bool ){ return true; }, b);
});
@@ -1464,7 +1491,7 @@ StaticTraitResolve::ValuePtr StaticTraitResolve::get_value(const Span& sp, const
out_params.pp_impl = &out_params.pp_impl_data;
out_params.pp_method = &pe.params;
ValuePtr rv;
- m_crate.find_type_impls(*pe.type, [](const auto&x)->const auto& { return x; }, [&](const auto& impl) {
+ m_crate.find_type_impls(*pe.type, [](const auto&x)->const ::HIR::TypeRef& { return x; }, [&](const auto& impl) {
DEBUG("Found impl" << impl.m_params.fmt_args() << " " << impl.m_type);
// TODO: Populate pp_impl
{
diff --git a/src/include/debug.hpp b/src/include/debug.hpp
index 756d6ef2..2bbecb39 100644
--- a/src/include/debug.hpp
+++ b/src/include/debug.hpp
@@ -62,11 +62,15 @@ public:
struct FmtLambda
{
::std::function<void(::std::ostream&)> m_cb;
+ FmtLambda(::std::function<void(::std::ostream&)> cb):
+ m_cb(cb)
+ { }
friend ::std::ostream& operator<<(::std::ostream& os, const FmtLambda& x) {
x.m_cb(os);
return os;
}
};
-#define FMT_CB(os, ...) ::FmtLambda { [&](auto& os) { __VA_ARGS__ } }
+#define FMT_CB(os, ...) ::FmtLambda( [&](auto& os) { __VA_ARGS__; } )
+#define FMT_CB_S(...) ::FmtLambda( [&](auto& _os) { _os << __VA_ARGS__; } )
diff --git a/src/include/serialise.hpp b/src/include/serialise.hpp
index 8b1cea98..0d6d781a 100644
--- a/src/include/serialise.hpp
+++ b/src/include/serialise.hpp
@@ -25,7 +25,7 @@ class Deserialiser;
#define SERIALISE_TU(class_, tag_str, val_name, ...) SERIALISE_TYPE(class_::, tag_str,\
{\
s << class_::tag_to_str(this->tag());\
- TU_MATCH(class_, (*this), (val_name), __VA_ARGS__);\
+ TU_MATCH(class_, (*this), (val_name), __VA_ARGS__)\
},/*
*/ {\
::std::string STU_tag_str;\
@@ -41,7 +41,7 @@ class Deserialiser;
*/ auto& VAL_NAME = this->as_##TAG(); /*
*/ __VA_ARGS__/*
*/} break;
-#define SERIALISE_TU_MATCH_ARMS(CLASS, NAME, ...) TU_GMA(__VA_ARGS__)(SERIALISE_TU_MATCH_ARM, (CLASS, NAME), __VA_ARGS__)
+#define SERIALISE_TU_MATCH_ARMS(CLASS, NAME, ...) TU_EXP1( TU_GMA(__VA_ARGS__)(SERIALISE_TU_MATCH_ARM, (CLASS, NAME), __VA_ARGS__) )
class DeserialiseFailure:
public ::std::runtime_error
diff --git a/src/mir/check.cpp b/src/mir/check.cpp
index 638a540c..807f08aa 100644
--- a/src/mir/check.cpp
+++ b/src/mir/check.cpp
@@ -725,7 +725,7 @@ void MIR_Validate(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path
// TODO: Check suitability of source type (COMPLEX)
),
(BinOp,
- #if 0
+ /*
::HIR::TypeRef tmp_l, tmp_r;
const auto& ty_l = state.get_lvalue_type(tmp_l, e.val_l);
const auto& ty_r = state.get_lvalue_type(tmp_r, e.val_r);
@@ -740,7 +740,7 @@ void MIR_Validate(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path
if( ty_l != ty_r )
MIR_BUG(state, "Type mismatch in binop, " << ty_l << " != " << ty_r);
}
- #endif
+ */
// TODO: Check return type
),
(UniOp,
@@ -757,8 +757,9 @@ void MIR_Validate(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path
ity_p = &*ty.m_data.as_Borrow().inner;
else if( ty.m_data.is_Pointer() )
ity_p = &*ty.m_data.as_Pointer().inner;
- else
+ else {
MIR_BUG(state, "DstMeta requires a &-ptr as input, got " << ty);
+ }
const auto& ity = *ity_p;
if( ity.m_data.is_Generic() )
;
@@ -790,8 +791,9 @@ void MIR_Validate(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path
ity_p = &*ty.m_data.as_Borrow().inner;
else if( ty.m_data.is_Pointer() )
ity_p = &*ty.m_data.as_Pointer().inner;
- else
+ else {
MIR_BUG(state, "DstPtr requires a &-ptr as input, got " << ty);
+ }
const auto& ity = *ity_p;
if( ity.m_data.is_Slice() )
;
@@ -817,8 +819,9 @@ void MIR_Validate(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path
ity_p = &*te->inner;
else if( const auto* te = ty.m_data.opt_Pointer() )
ity_p = &*te->inner;
- else
+ else {
MIR_BUG(state, "DstMeta requires a pointer as output, got " << ty);
+ }
assert(ity_p);
auto meta = get_metadata_type(state, *ity_p);
if( meta == ::HIR::TypeRef() )
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp
index 722e3aa1..e62722ef 100644
--- a/src/mir/from_hir.cpp
+++ b/src/mir/from_hir.cpp
@@ -884,19 +884,16 @@ namespace {
case _(Sub): op = ::MIR::eBinOp::SUB; if(0)
case _(Mul): op = ::MIR::eBinOp::MUL; if(0)
case _(Div): op = ::MIR::eBinOp::DIV; if(0)
- case _(Mod): op = ::MIR::eBinOp::MOD; if(0)
- ;
+ case _(Mod): op = ::MIR::eBinOp::MOD;
this->generate_checked_binop(sp, mv$(dst), op, mv$(dst_clone), ty_slot, mv$(val_lv), ty_val);
break;
case _(Xor): op = ::MIR::eBinOp::BIT_XOR; if(0)
case _(Or ): op = ::MIR::eBinOp::BIT_OR ; if(0)
- case _(And): op = ::MIR::eBinOp::BIT_AND; if(0)
- ;
+ case _(And): op = ::MIR::eBinOp::BIT_AND;
this->generate_checked_binop(sp, mv$(dst), op, mv$(dst_clone), ty_slot, mv$(val_lv), ty_val);
break;
case _(Shl): op = ::MIR::eBinOp::BIT_SHL; if(0)
- case _(Shr): op = ::MIR::eBinOp::BIT_SHR; if(0)
- ;
+ case _(Shr): op = ::MIR::eBinOp::BIT_SHR;
this->generate_checked_binop(sp, mv$(dst), op, mv$(dst_clone), ty_slot, mv$(val_lv), ty_val);
break;
}
@@ -1794,7 +1791,7 @@ namespace {
(Function,
// TODO: Why not use the result type?
//auto monomorph_cb = monomorphise_type_get_cb(sp, nullptr, nullptr, &pe.m_params);
- auto monomorph_cb = [&](const auto& gt)->const auto& {
+ auto monomorph_cb = [&](const auto& gt)->const ::HIR::TypeRef& {
const auto& e = gt.m_data.as_Generic();
if( e.binding == 0xFFFF ) {
BUG(sp, "Reference to Self in free function - " << gt);
@@ -1860,7 +1857,7 @@ namespace {
),
(UfcsInherent,
// 1. Find item in an impl block
- auto rv = m_builder.crate().find_type_impls(*pe.type, [&](const auto& ty)->const auto& { return ty; },
+ auto rv = m_builder.crate().find_type_impls(*pe.type, [&](const auto& ty)->const ::HIR::TypeRef& { return ty; },
[&](const auto& impl) {
DEBUG("- impl" << impl.m_params.fmt_args() << " " << impl.m_type);
// Associated functions
diff --git a/src/mir/from_hir.hpp b/src/mir/from_hir.hpp
index c8d34151..1b57a7f4 100644
--- a/src/mir/from_hir.hpp
+++ b/src/mir/from_hir.hpp
@@ -51,7 +51,7 @@ TAGGED_UNION_EX(VarState, (), Invalid, (
// Partially valid (Map of field states, Box is assumed to have one field)
(Partial, struct {
::std::vector<VarState> inner_states;
- unsigned int outer_flag = ~0u; // If ~0u there's no condition on the outer
+ unsigned int outer_flag; // If ~0u there's no condition on the outer
}),
// Optionally valid (integer indicates the drop flag index)
(Optional, unsigned int),
diff --git a/src/mir/from_hir_match.cpp b/src/mir/from_hir_match.cpp
index e08cd5f7..aa9825cd 100644
--- a/src/mir/from_hir_match.cpp
+++ b/src/mir/from_hir_match.cpp
@@ -1733,7 +1733,7 @@ int MIR_LowerHIR_Match_Simple__GeneratePattern(MirBuilder& builder, const Span&
),
(Array,
TODO(sp, "Match directly on array?");
- #if 0
+ /*
unsigned int total = 0;
for( unsigned int i = 0; i < te.size_val; i ++ ) {
unsigned int cnt = MIR_LowerHIR_Match_Simple__GeneratePattern(
@@ -1748,7 +1748,7 @@ int MIR_LowerHIR_Match_Simple__GeneratePattern(MirBuilder& builder, const Span&
if( num_rules == 0 )
return total;
}
- #endif
+ */
),
(Slice,
ASSERT_BUG(sp, rule.is_Slice() || rule.is_SplitSlice() || (rule.is_Value() && rule.as_Value().is_Bytes()), "Can only match slice with Bytes or Slice rules - " << rule);
@@ -1933,7 +1933,7 @@ struct DecisionTreeNode
DecisionTreeNode clone() const;
void populate_tree_from_rule(const Span& sp, unsigned int arm_index, const PatternRule* first_rule, unsigned int rule_count) {
- populate_tree_from_rule(sp, first_rule, rule_count, [sp,arm_index](auto& branch){
+ populate_tree_from_rule(sp, first_rule, rule_count, [sp,arm_index](Branch& branch){
TU_MATCHA( (branch), (e),
(Unset,
// Good
@@ -2385,13 +2385,17 @@ void DecisionTreeNode::populate_tree_from_rule(const Span& sp, const PatternRule
ASSERT_BUG(sp, m_field_path == rule.field_path, "Patterns with mismatched field paths - " << m_field_path << " != " << rule.field_path);
}
- #define GET_BRANCHES(fld, var) (({if( fld.is_Unset() ) {\
- fld = Values::make_##var({}); \
- } \
- else if( !fld.is_##var() ) { \
- BUG(sp, "Mismatched rules - have " #var ", but have seen " << fld.tag_str()); \
- }}), \
- fld.as_##var())
+ struct GET_BRANCHES_H {
+ static void unexpected_type(const Span& sp, const char* exp, const char* have) {
+ BUG(sp, "Mismatched rules - have " << exp << ", but have seen " << have);
+ }
+ };
+ #define GET_BRANCHES(fld, var) (fld.is_Unset()\
+ ? (fld = Values::make_##var({})).as_##var() \
+ : (fld.is_##var() \
+ ? fld.as_##var() : (GET_BRANCHES_H::unexpected_type(sp, #var, fld.tag_str()), fld.as_##var()) \
+ )\
+ )
TU_MATCHA( (rule), (e),
@@ -2437,7 +2441,7 @@ void DecisionTreeNode::populate_tree_from_rule(const Span& sp, const PatternRule
if( e.sub_rules.size() > 0 && rule_count > 1 )
{
- subtree.populate_tree_from_rule(sp, e.sub_rules.data(), e.sub_rules.size(), [&](auto& branch){
+ subtree.populate_tree_from_rule(sp, e.sub_rules.data(), e.sub_rules.size(), [&](Branch& branch){
TU_MATCH_DEF(Branch, (branch), (be),
(
BUG(sp, "Duplicate terminator");
@@ -2482,7 +2486,7 @@ void DecisionTreeNode::populate_tree_from_rule(const Span& sp, const PatternRule
if( e.sub_rules.size() > 0 && rule_count > 1 )
{
- subtree.populate_tree_from_rule(sp, e.sub_rules.data(), e.sub_rules.size(), [&](auto& branch){
+ subtree.populate_tree_from_rule(sp, e.sub_rules.data(), e.sub_rules.size(), [&](Branch& branch){
TU_MATCH_DEF(Branch, (branch), (be),
(
BUG(sp, "Duplicate terminator");
diff --git a/src/mir/helpers.hpp b/src/mir/helpers.hpp
index e8f52651..c91e4198 100644
--- a/src/mir/helpers.hpp
+++ b/src/mir/helpers.hpp
@@ -13,8 +13,8 @@
namespace HIR {
class Crate;
class TypeRef;
-class Pattern;
-class SimplePath;
+struct Pattern;
+struct SimplePath;
}
namespace MIR {
@@ -22,7 +22,7 @@ namespace MIR {
class Function;
class LValue;
class Constant;
-class BasicBlock;
+struct BasicBlock;
typedef unsigned int BasicBlockId;
diff --git a/src/mir/mir.hpp b/src/mir/mir.hpp
index aed7e2fc..75bb29a8 100644
--- a/src/mir/mir.hpp
+++ b/src/mir/mir.hpp
@@ -262,7 +262,7 @@ TAGGED_UNION(Statement, Assign,
(SetDropFlag, struct {
unsigned int idx;
bool new_val; // If `other` is populated, this indicates that the other value should be negated
- unsigned int other = ~0u;
+ unsigned int other;
}),
// Drop a value
(Drop, struct {
diff --git a/src/mir/mir_builder.cpp b/src/mir/mir_builder.cpp
index aa42cbc1..296dfa91 100644
--- a/src/mir/mir_builder.cpp
+++ b/src/mir/mir_builder.cpp
@@ -190,7 +190,7 @@ void MirBuilder::define_variable(unsigned int idx)
{
auto temp = new_temporary(ty);
push_stmt_assign( sp, ::MIR::LValue(temp.clone()), mv$(rv) );
- return temp;
+ return ::MIR::Param( mv$(temp) );
}
}
void MirBuilder::set_result(const Span& sp, ::MIR::RValue val)
@@ -1627,10 +1627,10 @@ void MirBuilder::moved_lvalue(const Span& sp, const ::MIR::LValue& lv)
BUG(sp, "Box move out of invalid LValue " << inner_lv << " - should have been moved");
),
(Variable,
- get_variable_state_mut(sp, ei) = VarState::make_Partial({ mv$(ivs) });
+ get_variable_state_mut(sp, ei) = VarState::make_Partial({ mv$(ivs), ~0u });
),
(Temporary,
- get_temp_state_mut(sp, ei.idx) = VarState::make_Partial({ mv$(ivs) });
+ get_temp_state_mut(sp, ei.idx) = VarState::make_Partial({ mv$(ivs), ~0u });
),
(Argument,
TODO(sp, "Mark arg " << ei.idx << " for shallow drop");
diff --git a/src/parse/expr.cpp b/src/parse/expr.cpp
index d4edb208..6227dca4 100644
--- a/src/parse/expr.cpp
+++ b/src/parse/expr.cpp
@@ -950,7 +950,7 @@ ExprNodeP Parse_ExprVal_StructLiteral(TokenStream& lex, AST::Path path)
::std::map<unsigned int, ExprNodeP> nodes;
while( GET_TOK(tok, lex) == TOK_INTEGER )
{
- unsigned int ofs = tok.intval();
+ unsigned int ofs = static_cast<unsigned int>(tok.intval());
GET_CHECK_TOK(tok, lex, TOK_COLON);
ExprNodeP val = Parse_Stmt(lex);
if( ! nodes.insert( ::std::make_pair(ofs, mv$(val)) ).second ) {
diff --git a/src/parse/lex.cpp b/src/parse/lex.cpp
index 4e5b4c2d..caa640f9 100644
--- a/src/parse/lex.cpp
+++ b/src/parse/lex.cpp
@@ -14,6 +14,7 @@
#include <cstdlib> // strtol
#include <typeinfo>
#include <algorithm> // std::count
+#include <cctype>
Lexer::Lexer(const ::std::string& filename):
m_path(filename.c_str()),
@@ -222,7 +223,9 @@ signed int Lexer::getSymbol()
bool issym(Codepoint ch)
{
- if( ::std::isalnum(ch.v) )
+ if('0' <= ch.v && ch.v <= '9')
+ return true;
+ if( ::std::isalpha(ch.v) )
return true;
if( ch == '_' )
return true;
@@ -659,11 +662,11 @@ Token Lexer::getTokenInt()
}
}
}
- catch(const Lexer::EndOfFile& e)
+ catch(const Lexer::EndOfFile& /*e*/)
{
return Token(TOK_EOF);
}
- //assert(!"bugcheck");
+ throw "Fell off the end of getTokenInt";
}
Token Lexer::getTokenInt_RawString(bool is_byte)
@@ -693,7 +696,7 @@ Token Lexer::getTokenInt_RawString(bool is_byte)
try {
ch = this->getc();
}
- catch( Lexer::EndOfFile e ) {
+ catch( const Lexer::EndOfFile& /*e*/ ) {
throw ParseError::Generic(*this, "EOF reached in raw string");
}
@@ -981,7 +984,7 @@ bool Codepoint::isspace() const {
case ' ':
case 0xC: // ^L
case 0x85:
- case 0x200E ... 0x200F: // LTR / RTL markers
+ case 0x200E: case 0x200F: // LTR / RTL markers
case 0x2028: // Line Separator
case 0x2029: // Paragrah Separator
return true;
diff --git a/src/parse/pattern.cpp b/src/parse/pattern.cpp
index 699e7fae..72b3eac4 100644
--- a/src/parse/pattern.cpp
+++ b/src/parse/pattern.cpp
@@ -409,7 +409,7 @@ AST::Pattern Parse_PatternStruct(TokenStream& lex, AST::Path path, bool is_refut
::std::map<unsigned int, AST::Pattern> pats;
while( GET_TOK(tok, lex) == TOK_INTEGER )
{
- unsigned int ofs = tok.intval();
+ unsigned int ofs = static_cast<unsigned int>(tok.intval());
GET_CHECK_TOK(tok, lex, TOK_COLON);
auto val = Parse_Pattern(lex, is_refutable);
if( ! pats.insert( ::std::make_pair(ofs, mv$(val)) ).second ) {
diff --git a/src/parse/token.cpp b/src/parse/token.cpp
index 69b952cc..c7d11d03 100644
--- a/src/parse/token.cpp
+++ b/src/parse/token.cpp
@@ -244,11 +244,10 @@ enum eTokenType Token::typefromstr(const ::std::string& s)
{
if(s == "")
return TOK_NULL;
- #define _(t) else if( s == #t ) return t;
+ #define _(t) if( s == #t ) return t;
#include "eTokenType.enum.h"
#undef _
- else
- return TOK_NULL;
+ return TOK_NULL;
}
struct EscapedString {
diff --git a/src/parse/token.hpp b/src/parse/token.hpp
index 03117981..0ef8f009 100644
--- a/src/parse/token.hpp
+++ b/src/parse/token.hpp
@@ -108,7 +108,7 @@ public:
enum eTokenType type() const { return m_type; }
::std::string& str() { return m_data.as_String(); }
const ::std::string& str() const { return m_data.as_String(); }
- enum eCoreType datatype() const { TU_MATCH_DEF(Data, (m_data), (e), (assert(!"Getting datatype of invalid token type");), (Integer, return e.m_datatype;), (Float, return e.m_datatype;)) }
+ enum eCoreType datatype() const { TU_MATCH_DEF(Data, (m_data), (e), (assert(!"Getting datatype of invalid token type");), (Integer, return e.m_datatype;), (Float, return e.m_datatype;)) throw ""; }
uint64_t intval() const { return m_data.as_Integer().m_intval; }
double floatval() const { return m_data.as_Float().m_floatval; }
diff --git a/src/parse/tokenstream.cpp b/src/parse/tokenstream.cpp
index 9a961a04..491b2a3e 100644
--- a/src/parse/tokenstream.cpp
+++ b/src/parse/tokenstream.cpp
@@ -105,9 +105,8 @@ ProtoSpan TokenStream::start_span() const
{
auto p = this->getPosition();
return ProtoSpan {
- .filename = p.filename,
- .start_line = p.line,
- .start_ofs = p.ofs,
+ p.filename,
+ p.line, p.ofs
};
}
Span TokenStream::end_span(ProtoSpan ps) const
diff --git a/src/resolve/use.cpp b/src/resolve/use.cpp
index 55c949b8..4e2874f0 100644
--- a/src/resolve/use.cpp
+++ b/src/resolve/use.cpp
@@ -262,7 +262,7 @@ void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path
BUG(span, "Invalid anon path segment '" << des_item_name << "'");
}
assert( mod.anon_mods()[idx] );
- return ::AST::PathBinding::make_Module({&*mod.anon_mods()[idx]});
+ return ::AST::PathBinding::make_Module({&*mod.anon_mods()[idx], nullptr});
}
// Seach for the name defined in the module.
diff --git a/vsproject/mrustc.vcxproj b/vsproject/mrustc.vcxproj
index 1f277488..0fb37029 100644
--- a/vsproject/mrustc.vcxproj
+++ b/vsproject/mrustc.vcxproj
@@ -146,7 +146,10 @@
<ClCompile Include="..\src\expand\mod.cpp" />
<ClCompile Include="..\src\expand\std_prelude.cpp" />
<ClCompile Include="..\src\expand\stringify.cpp" />
+ <ClCompile Include="..\src\hir\crate_post_load.cpp" />
<ClCompile Include="..\src\hir\crate_ptr.cpp" />
+ <ClCompile Include="..\src\hir\deserialise.cpp" />
+ <ClCompile Include="..\src\hir\dump.cpp" />
<ClCompile Include="..\src\hir\expr.cpp" />
<ClCompile Include="..\src\hir\expr_ptr.cpp" />
<ClCompile Include="..\src\hir\from_ast.cpp" />
@@ -155,16 +158,23 @@
<ClCompile Include="..\src\hir\hir.cpp" />
<ClCompile Include="..\src\hir\path.cpp" />
<ClCompile Include="..\src\hir\pattern.cpp" />
+ <ClCompile Include="..\src\hir\serialise.cpp" />
+ <ClCompile Include="..\src\hir\serialise_lowlevel.cpp" />
<ClCompile Include="..\src\hir\type.cpp" />
- <ClCompile Include="..\src\hir\type_ptr.cpp" />
<ClCompile Include="..\src\hir\visitor.cpp" />
<ClCompile Include="..\src\hir_conv\bind.cpp" />
<ClCompile Include="..\src\hir_conv\constant_evaluation.cpp" />
<ClCompile Include="..\src\hir_conv\expand_type.cpp" />
+ <ClCompile Include="..\src\hir_conv\markings.cpp" />
<ClCompile Include="..\src\hir_conv\resolve_ufcs.cpp" />
<ClCompile Include="..\src\hir_expand\annotate_value_usage.cpp" />
<ClCompile Include="..\src\hir_expand\closures.cpp" />
+ <ClCompile Include="..\src\hir_expand\const_eval_full.cpp" />
+ <ClCompile Include="..\src\hir_expand\erased_types.cpp" />
+ <ClCompile Include="..\src\hir_expand\reborrow.cpp" />
<ClCompile Include="..\src\hir_expand\ufcs_everything.cpp" />
+ <ClCompile Include="..\src\hir_expand\vtable.cpp" />
+ <ClCompile Include="..\src\hir_typeck\common.cpp" />
<ClCompile Include="..\src\hir_typeck\expr_check.cpp" />
<ClCompile Include="..\src\hir_typeck\expr_cs.cpp" />
<ClCompile Include="..\src\hir_typeck\expr_visit.cpp" />
@@ -172,14 +182,22 @@
<ClCompile Include="..\src\hir_typeck\impl_ref.cpp" />
<ClCompile Include="..\src\hir_typeck\outer.cpp" />
<ClCompile Include="..\src\hir_typeck\static.cpp" />
+ <ClCompile Include="..\src\ident.cpp" />
<ClCompile Include="..\src\macro_rules\eval.cpp" />
<ClCompile Include="..\src\macro_rules\mod.cpp" />
<ClCompile Include="..\src\macro_rules\parse.cpp" />
<ClCompile Include="..\src\main.cpp" />
+ <ClCompile Include="..\src\mir\check.cpp" />
+ <ClCompile Include="..\src\mir\cleanup.cpp" />
+ <ClCompile Include="..\src\mir\dump.cpp" />
<ClCompile Include="..\src\mir\from_hir.cpp" />
<ClCompile Include="..\src\mir\from_hir_match.cpp" />
+ <ClCompile Include="..\src\mir\helpers.cpp" />
<ClCompile Include="..\src\mir\mir.cpp" />
+ <ClCompile Include="..\src\mir\mir_builder.cpp" />
<ClCompile Include="..\src\mir\mir_ptr.cpp" />
+ <ClCompile Include="..\src\mir\optimise.cpp" />
+ <ClCompile Include="..\src\mir\visit_crate_mir.cpp" />
<ClCompile Include="..\src\parse\expr.cpp" />
<ClCompile Include="..\src\parse\interpolated_fragment.cpp" />
<ClCompile Include="..\src\parse\lex.cpp" />
@@ -188,6 +206,9 @@
<ClCompile Include="..\src\parse\pattern.cpp" />
<ClCompile Include="..\src\parse\root.cpp" />
<ClCompile Include="..\src\parse\token.cpp" />
+ <ClCompile Include="..\src\parse\tokenstream.cpp" />
+ <ClCompile Include="..\src\parse\tokentree.cpp" />
+ <ClCompile Include="..\src\parse\ttstream.cpp" />
<ClCompile Include="..\src\parse\types.cpp" />
<ClCompile Include="..\src\rc_string.cpp" />
<ClCompile Include="..\src\resolve\absolute.cpp" />
@@ -195,6 +216,12 @@
<ClCompile Include="..\src\resolve\use.cpp" />
<ClCompile Include="..\src\serialise.cpp" />
<ClCompile Include="..\src\span.cpp" />
+ <ClCompile Include="..\src\trans\codegen.cpp" />
+ <ClCompile Include="..\src\trans\codegen_c.cpp" />
+ <ClCompile Include="..\src\trans\enumerate.cpp" />
+ <ClCompile Include="..\src\trans\mangling.cpp" />
+ <ClCompile Include="..\src\trans\monomorphise.cpp" />
+ <ClCompile Include="..\src\trans\trans_list.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\ast\ast.hpp" />
@@ -220,7 +247,6 @@
<ClInclude Include="..\src\hir\path.hpp" />
<ClInclude Include="..\src\hir\pattern.hpp" />
<ClInclude Include="..\src\hir\type.hpp" />
- <ClInclude Include="..\src\hir\type_ptr.hpp" />
<ClInclude Include="..\src\hir\visitor.hpp" />
<ClInclude Include="..\src\hir_conv\main_bindings.hpp" />
<ClInclude Include="..\src\hir_expand\main_bindings.hpp" />
@@ -246,19 +272,41 @@
<ClInclude Include="..\src\macro_rules\macro_rules_ptr.hpp" />
<ClInclude Include="..\src\macro_rules\pattern_checks.hpp" />
<ClInclude Include="..\src\mir\from_hir.hpp" />
+ <ClInclude Include="..\src\mir\helpers.hpp" />
<ClInclude Include="..\src\mir\main_bindings.hpp" />
<ClInclude Include="..\src\mir\mir.hpp" />
<ClInclude Include="..\src\mir\mir_ptr.hpp" />
+ <ClInclude Include="..\src\mir\operations.hpp" />
+ <ClInclude Include="..\src\mir\visit_crate_mir.hpp" />
<ClInclude Include="..\src\parse\common.hpp" />
<ClInclude Include="..\src\parse\eTokenType.enum.h" />
<ClInclude Include="..\src\parse\interpolated_fragment.hpp" />
<ClInclude Include="..\src\parse\lex.hpp" />
<ClInclude Include="..\src\parse\parseerror.hpp" />
<ClInclude Include="..\src\parse\token.hpp" />
+ <ClInclude Include="..\src\parse\tokenstream.hpp" />
<ClInclude Include="..\src\parse\tokentree.hpp" />
+ <ClInclude Include="..\src\parse\ttstream.hpp" />
<ClInclude Include="..\src\resolve\main_bindings.hpp" />
+ <ClInclude Include="..\src\trans\codegen.hpp" />
+ <ClInclude Include="..\src\trans\main_bindings.hpp" />
+ <ClInclude Include="..\src\trans\mangling.hpp" />
+ <ClInclude Include="..\src\trans\monomorphise.hpp" />
+ <ClInclude Include="..\src\trans\trans_list.hpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
+ <Import Project="packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets" Condition="Exists('packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets')" />
+ <Import Project="packages\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.targets" Condition="Exists('packages\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.targets')" />
</ImportGroup>
+ <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+ <PropertyGroup>
+ <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
+ </PropertyGroup>
+ <Error Condition="!Exists('packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets'))" />
+ <Error Condition="!Exists('packages\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v140.windesktop.msvcstl.dyn.rt-dyn.targets'))" />
+ </Target>
</Project> \ No newline at end of file
diff --git a/vsproject/mrustc.vcxproj.filters b/vsproject/mrustc.vcxproj.filters
index a25022bf..b8a44339 100644
--- a/vsproject/mrustc.vcxproj.filters
+++ b/vsproject/mrustc.vcxproj.filters
@@ -13,6 +13,50 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
+ <Filter Include="Source Files\mir">
+ <UniqueIdentifier>{37f428ea-aa89-4cf7-94b8-38a1ed530917}</UniqueIdentifier>
+ <Extensions>src/mir/*</Extensions>
+ </Filter>
+ <Filter Include="Source Files\hir_expand">
+ <UniqueIdentifier>{9b7b8a58-8e87-4c7f-a418-f5e3820e93e9}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Source Files\ast">
+ <UniqueIdentifier>{cbf97f1c-f415-42a8-bf0e-d2331ee7fb30}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Source Files\expand">
+ <UniqueIdentifier>{a1148def-ba0b-4c18-a118-a1441ae50815}</UniqueIdentifier>
+ <Extensions>src\expand\*.cpp</Extensions>
+ </Filter>
+ <Filter Include="Source Files\hir_conv">
+ <UniqueIdentifier>{23c5e44e-55f1-4a88-ae1e-93bf2ae910ce}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Source Files\hir">
+ <UniqueIdentifier>{b04c313f-020b-48cc-b2a2-b0bb143ef4c4}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Source Files\macro_rules">
+ <UniqueIdentifier>{176e70ec-ebc0-4362-8946-5eab5d9c7970}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Source Files\resolve">
+ <UniqueIdentifier>{afb300e4-b247-43e7-ac13-6c367fa28bf3}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Source Files\parse">
+ <UniqueIdentifier>{152623f5-cdba-4d35-a378-24ced1e05809}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Source Files\trans">
+ <UniqueIdentifier>{26d5bc90-94b8-45b4-82cb-29a624246d83}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Source Files\hir_typeck">
+ <UniqueIdentifier>{813e552f-43d8-429a-afc0-0d1998a376b7}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Header Files\ast">
+ <UniqueIdentifier>{7d11d59d-5894-417c-ae2e-a85c79d9490e}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Header Files\hir_typeck">
+ <UniqueIdentifier>{6e602432-c609-4771-ab76-55f5e4998035}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Header Files\mir">
+ <UniqueIdentifier>{1233e2f6-7b44-4379-9f43-d572b8944ba0}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\debug.cpp">
@@ -30,190 +74,271 @@
<ClCompile Include="..\src\span.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\src\ast\ast.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\mir\dump.cpp">
+ <Filter>Source Files\mir</Filter>
</ClCompile>
- <ClCompile Include="..\src\ast\crate.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\mir\check.cpp">
+ <Filter>Source Files\mir</Filter>
</ClCompile>
- <ClCompile Include="..\src\ast\expr.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\hir_expand\annotate_value_usage.cpp">
+ <Filter>Source Files\hir_expand</Filter>
</ClCompile>
- <ClCompile Include="..\src\ast\path.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\mir\cleanup.cpp">
+ <Filter>Source Files\mir</Filter>
</ClCompile>
- <ClCompile Include="..\src\ast\pattern.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\hir_expand\closures.cpp">
+ <Filter>Source Files\hir_expand</Filter>
</ClCompile>
- <ClCompile Include="..\src\ast\types.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\hir_expand\const_eval_full.cpp">
+ <Filter>Source Files\hir_expand</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\hir_conv\bind.cpp">
+ <Filter>Source Files\hir_conv</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\hir_conv\constant_evaluation.cpp">
+ <Filter>Source Files\hir_conv</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\hir_expand\erased_types.cpp">
+ <Filter>Source Files\hir_expand</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\ast\ast.cpp">
+ <Filter>Source Files\ast</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\ast\crate.cpp">
+ <Filter>Source Files\ast</Filter>
</ClCompile>
<ClCompile Include="..\src\expand\cfg.cpp">
- <Filter>Source Files</Filter>
+ <Filter>Source Files\expand</Filter>
</ClCompile>
<ClCompile Include="..\src\expand\concat.cpp">
- <Filter>Source Files</Filter>
+ <Filter>Source Files\expand</Filter>
</ClCompile>
<ClCompile Include="..\src\expand\derive.cpp">
- <Filter>Source Files</Filter>
+ <Filter>Source Files\expand</Filter>
</ClCompile>
- <ClCompile Include="..\src\expand\file_line.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\ast\dump.cpp">
+ <Filter>Source Files\ast</Filter>
</ClCompile>
- <ClCompile Include="..\src\expand\format_args.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\hir_conv\expand_type.cpp">
+ <Filter>Source Files\hir_conv</Filter>
</ClCompile>
- <ClCompile Include="..\src\expand\lang_item.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\macro_rules\eval.cpp">
+ <Filter>Source Files\macro_rules</Filter>
</ClCompile>
- <ClCompile Include="..\src\expand\macro_rules.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\hir\expr.cpp">
+ <Filter>Source Files\hir</Filter>
</ClCompile>
- <ClCompile Include="..\src\expand\mod.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\resolve\absolute.cpp">
+ <Filter>Source Files\resolve</Filter>
</ClCompile>
- <ClCompile Include="..\src\expand\std_prelude.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\trans\codegen_c.cpp">
+ <Filter>Source Files\trans</Filter>
</ClCompile>
- <ClCompile Include="..\src\expand\stringify.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\trans\codegen.cpp">
+ <Filter>Source Files\trans</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\hir\crate_post_load.cpp">
+ <Filter>Source Files\hir</Filter>
</ClCompile>
<ClCompile Include="..\src\hir\crate_ptr.cpp">
- <Filter>Source Files</Filter>
+ <Filter>Source Files\hir</Filter>
</ClCompile>
- <ClCompile Include="..\src\hir\expr.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\hir\deserialise.cpp">
+ <Filter>Source Files\hir</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\hir\dump.cpp">
+ <Filter>Source Files\hir</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\parse\expr.cpp">
+ <Filter>Source Files\parse</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\ast\expr.cpp">
+ <Filter>Source Files\ast</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\trans\enumerate.cpp">
+ <Filter>Source Files\trans</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\hir_typeck\expr_visit.cpp">
+ <Filter>Source Files\hir</Filter>
</ClCompile>
<ClCompile Include="..\src\hir\expr_ptr.cpp">
- <Filter>Source Files</Filter>
+ <Filter>Source Files\hir</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\expand\format_args.cpp">
+ <Filter>Source Files\expand</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\mir\from_hir.cpp">
+ <Filter>Source Files\mir</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\mir\from_hir_match.cpp">
+ <Filter>Source Files\mir</Filter>
</ClCompile>
<ClCompile Include="..\src\hir\from_ast.cpp">
- <Filter>Source Files</Filter>
+ <Filter>Source Files\hir</Filter>
</ClCompile>
<ClCompile Include="..\src\hir\from_ast_expr.cpp">
- <Filter>Source Files</Filter>
+ <Filter>Source Files\hir</Filter>
</ClCompile>
- <ClCompile Include="..\src\hir\generic_params.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\expand\file_line.cpp">
+ <Filter>Source Files\expand</Filter>
</ClCompile>
- <ClCompile Include="..\src\hir\hir.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\expand\mod.cpp">
+ <Filter>Source Files\expand</Filter>
</ClCompile>
- <ClCompile Include="..\src\hir\path.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\macro_rules\mod.cpp">
+ <Filter>Source Files\macro_rules</Filter>
</ClCompile>
- <ClCompile Include="..\src\hir\pattern.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\expand\macro_rules.cpp">
+ <Filter>Source Files\macro_rules</Filter>
</ClCompile>
- <ClCompile Include="..\src\hir\type.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\mir\mir_ptr.cpp">
+ <Filter>Source Files\mir</Filter>
</ClCompile>
- <ClCompile Include="..\src\hir\type_ptr.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\mir\mir_builder.cpp">
+ <Filter>Source Files\mir</Filter>
</ClCompile>
- <ClCompile Include="..\src\hir\visitor.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\mir\mir.cpp">
+ <Filter>Source Files\mir</Filter>
</ClCompile>
- <ClCompile Include="..\src\hir_conv\bind.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\trans\monomorphise.cpp">
+ <Filter>Source Files\trans</Filter>
</ClCompile>
- <ClCompile Include="..\src\hir_conv\constant_evaluation.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\trans\mangling.cpp">
+ <Filter>Source Files\trans</Filter>
</ClCompile>
- <ClCompile Include="..\src\hir_conv\expand_type.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\expand\lang_item.cpp">
+ <Filter>Source Files\expand</Filter>
</ClCompile>
- <ClCompile Include="..\src\hir_conv\resolve_ufcs.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\parse\lex.cpp">
+ <Filter>Source Files\parse</Filter>
</ClCompile>
- <ClCompile Include="..\src\hir_expand\annotate_value_usage.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\hir\serialise.cpp">
+ <Filter>Source Files\hir</Filter>
</ClCompile>
- <ClCompile Include="..\src\hir_expand\closures.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\hir\pattern.cpp">
+ <Filter>Source Files\hir</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\mir\optimise.cpp">
+ <Filter>Source Files\mir</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\hir_expand\vtable.cpp">
+ <Filter>Source Files\hir_expand</Filter>
</ClCompile>
<ClCompile Include="..\src\hir_expand\ufcs_everything.cpp">
- <Filter>Source Files</Filter>
+ <Filter>Source Files\hir_expand</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\parse\paths.cpp">
+ <Filter>Source Files\parse</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\parse\pattern.cpp">
+ <Filter>Source Files\parse</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\macro_rules\parse.cpp">
+ <Filter>Source Files\parse</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\parse\root.cpp">
+ <Filter>Source Files\parse</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\parse\token.cpp">
+ <Filter>Source Files\parse</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\parse\tokenstream.cpp">
+ <Filter>Source Files\parse</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\parse\tokentree.cpp">
+ <Filter>Source Files\parse</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\parse\ttstream.cpp">
+ <Filter>Source Files\parse</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\hir\serialise_lowlevel.cpp">
+ <Filter>Source Files\hir</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\hir_conv\resolve_ufcs.cpp">
+ <Filter>Source Files\hir_conv</Filter>
</ClCompile>
<ClCompile Include="..\src\hir_typeck\expr_check.cpp">
- <Filter>Source Files</Filter>
+ <Filter>Source Files\hir_typeck</Filter>
</ClCompile>
<ClCompile Include="..\src\hir_typeck\expr_cs.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\src\hir_typeck\expr_visit.cpp">
- <Filter>Source Files</Filter>
+ <Filter>Source Files\hir_typeck</Filter>
</ClCompile>
<ClCompile Include="..\src\hir_typeck\helpers.cpp">
- <Filter>Source Files</Filter>
+ <Filter>Source Files\hir_typeck</Filter>
</ClCompile>
<ClCompile Include="..\src\hir_typeck\impl_ref.cpp">
- <Filter>Source Files</Filter>
+ <Filter>Source Files\hir_typeck</Filter>
</ClCompile>
- <ClCompile Include="..\src\hir_typeck\outer.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\mir\helpers.cpp">
+ <Filter>Source Files\mir</Filter>
</ClCompile>
- <ClCompile Include="..\src\hir_typeck\static.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\hir_expand\reborrow.cpp">
+ <Filter>Source Files\hir_expand</Filter>
</ClCompile>
- <ClCompile Include="..\src\macro_rules\eval.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\hir\hir.cpp">
+ <Filter>Source Files\hir</Filter>
</ClCompile>
- <ClCompile Include="..\src\macro_rules\mod.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\parse\interpolated_fragment.cpp">
+ <Filter>Source Files\parse</Filter>
</ClCompile>
- <ClCompile Include="..\src\macro_rules\parse.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\ast\pattern.cpp">
+ <Filter>Source Files\ast</Filter>
</ClCompile>
- <ClCompile Include="..\src\mir\from_hir.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\ast\path.cpp">
+ <Filter>Source Files\ast</Filter>
</ClCompile>
- <ClCompile Include="..\src\mir\from_hir_match.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\hir\path.cpp">
+ <Filter>Source Files\hir</Filter>
</ClCompile>
- <ClCompile Include="..\src\mir\mir.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\hir\generic_params.cpp">
+ <Filter>Source Files\ast</Filter>
</ClCompile>
- <ClCompile Include="..\src\mir\mir_ptr.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\resolve\index.cpp">
+ <Filter>Source Files\resolve</Filter>
</ClCompile>
- <ClCompile Include="..\src\parse\expr.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\hir_typeck\outer.cpp">
+ <Filter>Source Files\hir_typeck</Filter>
</ClCompile>
- <ClCompile Include="..\src\parse\interpolated_fragment.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\resolve\use.cpp">
+ <Filter>Source Files\resolve</Filter>
</ClCompile>
- <ClCompile Include="..\src\parse\lex.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\mir\visit_crate_mir.cpp">
+ <Filter>Source Files\mir</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\hir\type.cpp">
+ <Filter>Source Files\hir</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\expand\std_prelude.cpp">
+ <Filter>Source Files\expand</Filter>
</ClCompile>
<ClCompile Include="..\src\parse\parseerror.cpp">
- <Filter>Source Files</Filter>
+ <Filter>Source Files\parse</Filter>
</ClCompile>
- <ClCompile Include="..\src\parse\paths.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\hir_typeck\static.cpp">
+ <Filter>Source Files\hir_typeck</Filter>
</ClCompile>
- <ClCompile Include="..\src\parse\pattern.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\parse\types.cpp">
+ <Filter>Source Files\parse</Filter>
</ClCompile>
- <ClCompile Include="..\src\parse\root.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\ast\types.cpp">
+ <Filter>Source Files\ast</Filter>
</ClCompile>
- <ClCompile Include="..\src\parse\token.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\hir\visitor.cpp">
+ <Filter>Source Files\hir</Filter>
</ClCompile>
- <ClCompile Include="..\src\parse\types.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\expand\stringify.cpp">
+ <Filter>Source Files\expand</Filter>
</ClCompile>
- <ClCompile Include="..\src\resolve\absolute.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\trans\trans_list.cpp">
+ <Filter>Source Files\trans</Filter>
</ClCompile>
- <ClCompile Include="..\src\resolve\index.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\hir_conv\markings.cpp">
+ <Filter>Source Files\hir_conv</Filter>
</ClCompile>
- <ClCompile Include="..\src\resolve\use.cpp">
- <Filter>Source Files</Filter>
+ <ClCompile Include="..\src\hir_typeck\common.cpp">
+ <Filter>Source Files\hir_typeck</Filter>
</ClCompile>
- <ClCompile Include="..\src\ast\dump.cpp">
+ <ClCompile Include="..\src\ident.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
@@ -224,36 +349,12 @@
<ClInclude Include="..\src\coretypes.hpp">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="..\src\ast\ast.hpp">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\src\ast\attrs.hpp">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="..\src\ast\crate.hpp">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="..\src\ast\expr.hpp">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\src\ast\generics.hpp">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\src\ast\item.hpp">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\src\ast\macro.hpp">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\src\ast\path.hpp">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="..\src\ast\pattern.hpp">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="..\src\ast\types.hpp">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="..\src\expand\cfg.hpp">
<Filter>Header Files</Filter>
</ClInclude>
@@ -287,9 +388,6 @@
<ClInclude Include="..\src\hir\type.hpp">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="..\src\hir\type_ptr.hpp">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="..\src\hir\visitor.hpp">
<Filter>Header Files</Filter>
</ClInclude>
@@ -302,12 +400,6 @@
<ClInclude Include="..\src\hir_typeck\expr_visit.hpp">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="..\src\hir_typeck\helpers.hpp">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\src\hir_typeck\impl_ref.hpp">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="..\src\hir_typeck\main_bindings.hpp">
<Filter>Header Files</Filter>
</ClInclude>
@@ -368,12 +460,6 @@
<ClInclude Include="..\src\mir\main_bindings.hpp">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="..\src\mir\mir.hpp">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\src\mir\mir_ptr.hpp">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="..\src\parse\eTokenType.enum.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -398,5 +484,74 @@
<ClInclude Include="..\src\resolve\main_bindings.hpp">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\src\parse\ttstream.hpp">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\parse\tokenstream.hpp">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\trans\codegen.hpp">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\trans\main_bindings.hpp">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\trans\mangling.hpp">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\trans\trans_list.hpp">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\mir\visit_crate_mir.hpp">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\ast\attrs.hpp">
+ <Filter>Header Files\ast</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\ast\ast.hpp">
+ <Filter>Header Files\ast</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\ast\expr.hpp">
+ <Filter>Header Files\ast</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\ast\generics.hpp">
+ <Filter>Header Files\ast</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\ast\macro.hpp">
+ <Filter>Header Files\ast</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\ast\item.hpp">
+ <Filter>Header Files\ast</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\hir_typeck\helpers.hpp">
+ <Filter>Header Files\hir_typeck</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\mir\mir.hpp">
+ <Filter>Header Files\mir</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\mir\mir_ptr.hpp">
+ <Filter>Header Files\mir</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\trans\monomorphise.hpp">
+ <Filter>Header Files\mir</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\mir\operations.hpp">
+ <Filter>Header Files\mir</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\hir_typeck\impl_ref.hpp">
+ <Filter>Header Files\hir_typeck</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\ast\path.hpp">
+ <Filter>Header Files\ast</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\mir\helpers.hpp">
+ <Filter>Header Files\mir</Filter>
+ </ClInclude>
+ <ClInclude Include="..\src\ast\types.hpp">
+ <Filter>Header Files\ast</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/vsproject/packages.config b/vsproject/packages.config
new file mode 100644
index 00000000..bb65eec4
--- /dev/null
+++ b/vsproject/packages.config
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="zlib" version="1.2.8.8" targetFramework="native" />
+ <package id="zlib.v120.windesktop.msvcstl.dyn.rt-dyn" version="1.2.8.8" targetFramework="native" />
+ <package id="zlib.v140.windesktop.msvcstl.dyn.rt-dyn" version="1.2.8.8" targetFramework="native" />
+</packages> \ No newline at end of file