summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ast/ast.hpp1
-rw-r--r--src/ast/path.cpp13
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)
{