diff options
author | John Hodge (bugs) <tpg@mutabah.net> | 2017-02-25 22:24:40 +0800 |
---|---|---|
committer | John Hodge (bugs) <tpg@mutabah.net> | 2017-02-25 22:24:40 +0800 |
commit | 03addc877bab648ccde022edec29f5b051ce7cb9 (patch) | |
tree | 51089cf2abbda1d48a7105da1cb18ec84f2f4590 /src/ast | |
parent | 12c012c69235fd90c855881f2c07c91dbb052635 (diff) | |
download | mrust-03addc877bab648ccde022edec29f5b051ce7cb9.tar.gz |
Add visual studio project files, little tweaks to codebase to allow compiling on visual studio (not complete)
Diffstat (limited to 'src/ast')
-rw-r--r-- | src/ast/path.cpp | 20 | ||||
-rw-r--r-- | src/ast/types.cpp | 2 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/ast/path.cpp b/src/ast/path.cpp index da86b066..ebec5d5a 100644 --- a/src/ast/path.cpp +++ b/src/ast/path.cpp @@ -190,18 +190,18 @@ void Path::bind_variable(unsigned int slot) } void Path::bind_enum_var(const Enum& ent, const ::std::string& name, const ::std::vector<TypeRef>& /*args*/) { - unsigned int idx = 0; - for( idx = 0; idx < ent.variants().size(); idx ++ ) - { - if( ent.variants()[idx].m_name == name ) { - break; - } - } - if( idx == ent.variants().size() ) - throw ParseError::Generic("Enum variant not found"); + auto it = ::std::find_if(ent.variants().begin(), ent.variants().end(), [&](const auto& x) { return x.m_name == name; }); + if( it == ent.variants().end() ) + { + throw ParseError::Generic("Enum variant not found"); + } + unsigned int idx = it - ent.variants().begin(); DEBUG("Bound to enum variant '" << name << "' (#" << idx << ")"); - m_binding = PathBinding::make_EnumVar({ &ent, idx }); + ::AST::PathBinding::Data_EnumVar tmp; + tmp.enum_ = &ent; + tmp.idx = idx; + m_binding = PathBinding::make_EnumVar(tmp); } Path& Path::operator+=(const Path& other) diff --git a/src/ast/types.cpp b/src/ast/types.cpp index ccd169d7..d49feccd 100644 --- a/src/ast/types.cpp +++ b/src/ast/types.cpp @@ -118,7 +118,7 @@ TypeRef TypeRef::clone() const { case TypeData::TAGDEAD: assert(!"Copying a destructed type"); #define _COPY(VAR) case TypeData::TAG_##VAR: return TypeRef(m_span, TypeData::make_##VAR(m_data.as_##VAR()) ); break; - #define _CLONE(VAR, code...) case TypeData::TAG_##VAR: { auto& old = m_data.as_##VAR(); return TypeRef(m_span, TypeData::make_##VAR(code) ); } break; + #define _CLONE(VAR, ...) case TypeData::TAG_##VAR: { auto& old = m_data.as_##VAR(); return TypeRef(m_span, TypeData::make_##VAR(__VA_ARGS__) ); } break; _COPY(None) _COPY(Any) _COPY(Bang) |