summaryrefslogtreecommitdiff
path: root/src/ast/path.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast/path.cpp')
-rw-r--r--src/ast/path.cpp20
1 files changed, 10 insertions, 10 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)