diff options
author | John Hodge (sonata) <tpg@mutabah.net> | 2015-01-14 11:59:15 +0800 |
---|---|---|
committer | John Hodge (sonata) <tpg@mutabah.net> | 2015-01-14 11:59:15 +0800 |
commit | 6e0dfa94d9206d10514c337cee3d704f559381b3 (patch) | |
tree | 34684f8c785ee996945e4038e9970d5bb49e6721 | |
parent | b28f21a27b355fef18bb8daf75f447c69ddad8ee (diff) | |
download | mrust-6e0dfa94d9206d10514c337cee3d704f559381b3.tar.gz |
Path bind to struct (removed todo that wasn't needed in that location)
-rw-r--r-- | src/ast/ast.hpp | 1 | ||||
-rw-r--r-- | src/ast/path.cpp | 13 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/ast/ast.hpp b/src/ast/ast.hpp index f1289940..fe07ae7d 100644 --- a/src/ast/ast.hpp +++ b/src/ast/ast.hpp @@ -172,6 +172,7 @@ public: m_fields( move(fields) )
{}
+ const ::std::vector<TypeParam> params() const { return m_params; }
const ::std::vector<StructItem> fields() const { return m_fields; }
SERIALISABLE_PROTOTYPES();
diff --git a/src/ast/path.cpp b/src/ast/path.cpp index a868be5d..0bce09c1 100644 --- a/src/ast/path.cpp +++ b/src/ast/path.cpp @@ -213,7 +213,18 @@ void Path::bind_enum_var(const Enum& ent, const ::std::string& name, const ::std } void Path::bind_struct(const Struct& ent, const ::std::vector<TypeRef>& args) { - throw ParseError::Todo("Path::resolve() bind to struct type"); + if( args.size() > 0 ) + { + if( args.size() != ent.params().size() ) + throw ParseError::Generic("Parameter count mismatch"); + // TODO: Is it the role of this section of code to ensure that the passed args are valid? + // - Probably not, it should instead be the type checker that does it + // - Count validation is OK here though + } + + DEBUG("Bound to struct"); + m_binding_type = STRUCT; + m_binding.struct_ = &ent; } void Path::bind_static(const Static& ent) { |