diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/hir/from_ast.cpp | 31 | ||||
-rw-r--r-- | src/hir/path.cpp | 2 | ||||
-rw-r--r-- | src/hir/path.hpp | 16 |
3 files changed, 41 insertions, 8 deletions
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp index 4752d000..827ac973 100644 --- a/src/hir/from_ast.cpp +++ b/src/hir/from_ast.cpp @@ -394,12 +394,31 @@ (UFCS, if( e.nodes.size() != 1 ) throw "TODO: Handle UFCS with multiple nodes"; - return ::HIR::Path( - LowerHIR_Type(*e.type), - LowerHIR_GenericPath(*e.trait), - e.nodes[0].name(), - {} - ); + if( ! e.trait ) + { + return ::HIR::Path(::HIR::Path::Data::make_UfcsInherent({ + LowerHIR_Type(*e.type), + e.nodes[0].name(), + {} + })); + } + else if( ! e.trait->is_valid() ) + { + return ::HIR::Path(::HIR::Path::Data::make_UfcsUnknown({ + LowerHIR_Type(*e.type), + e.nodes[0].name(), + {} + })); + } + else + { + return ::HIR::Path( + LowerHIR_Type(*e.type), + LowerHIR_GenericPath(*e.trait), + e.nodes[0].name(), + {} + ); + } ) ) throw "BUGCHECK: Reached end of LowerHIR_Path"; diff --git a/src/hir/path.cpp b/src/hir/path.cpp index 3c955f6a..e5243958 100644 --- a/src/hir/path.cpp +++ b/src/hir/path.cpp @@ -54,7 +54,7 @@ namespace HIR { { } ::HIR::Path::Path(::HIR::TypeRefPtr type, ::HIR::GenericPath trait, ::std::string item, ::HIR::PathParams params): - m_data( ::HIR::Path::Data::make_UFCS({ + m_data( ::HIR::Path::Data::make_UfcsKnown({ mv$(type), mv$(trait), mv$(item), mv$(params) }) ) { diff --git a/src/hir/path.hpp b/src/hir/path.hpp index 584d598b..05ceab3d 100644 --- a/src/hir/path.hpp +++ b/src/hir/path.hpp @@ -64,11 +64,22 @@ public: // - Generic path TAGGED_UNION(Data, Generic, (Generic, GenericPath), - (UFCS, struct { + (UfcsInherent, struct { + TypeRefPtr type; + ::std::string item; + PathParams params; + }), + (UfcsKnown, struct { TypeRefPtr type; GenericPath trait; ::std::string item; PathParams params; + }), + (UfcsUnknown, struct { + TypeRefPtr type; + //GenericPath ??; + ::std::string item; + PathParams params; }) ); @@ -76,6 +87,9 @@ private: Data m_data; public: + Path(Data data): + m_data(mv$(data)) + {} Path(GenericPath _); Path(TypeRefPtr type, GenericPath trait, ::std::string item, PathParams params); Path(SimplePath _); |