diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-12 11:24:52 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-12 11:24:52 +0800 |
commit | cf5d3d1349df9c5fe4b526476c4262abed8e5eef (patch) | |
tree | 1d159b2e85a8449ca84bc9f33dc8bcdd47438237 /src | |
parent | a4a4c80b9111e8442f8371bd6428d1295f1f48d3 (diff) | |
download | mrust-cf5d3d1349df9c5fe4b526476c4262abed8e5eef.tar.gz |
HIR From AST - Correct paths for range ops
Diffstat (limited to 'src')
-rw-r--r-- | src/hir/from_ast.cpp | 9 | ||||
-rw-r--r-- | src/hir/from_ast.hpp | 9 | ||||
-rw-r--r-- | src/hir/from_ast_expr.cpp | 17 |
3 files changed, 28 insertions, 7 deletions
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp index aabfc3ef..17bbb2c3 100644 --- a/src/hir/from_ast.cpp +++ b/src/hir/from_ast.cpp @@ -1,4 +1,9 @@ /* + * MRustC - Rust Compiler + * - By John Hodge (Mutabah/thePowersGang) + * + * hir/from_ast.cpp + * - Constructs the HIR module tree from the AST module tree */ #include "common.hpp" #include "hir.hpp" @@ -14,7 +19,8 @@ ::HIR::PathParams LowerHIR_PathParams(const Span& sp, const ::AST::PathParams& src_params, bool allow_assoc); ::HIR::TraitPath LowerHIR_TraitPath(const Span& sp, const ::AST::Path& path); -::HIR::SimplePath path_Sized = ::HIR::SimplePath("", {"marker", "Sized"}); +::HIR::SimplePath path_Sized; +::std::string g_core_crate; ::HIR::Crate* g_crate_ptr = nullptr; // -------------------------------------------------------------------- @@ -1259,6 +1265,7 @@ public: { ::HIR::Crate rv; g_crate_ptr = &rv; + g_core_crate = (crate.m_load_std == ::AST::Crate::LOAD_NONE ? "" : "core"); auto& macros = rv.m_exported_macros; // - Extract macros from root module diff --git a/src/hir/from_ast.hpp b/src/hir/from_ast.hpp index 231f1286..4625f479 100644 --- a/src/hir/from_ast.hpp +++ b/src/hir/from_ast.hpp @@ -1,3 +1,10 @@ +/* + * MRustC - Rust Compiler + * - By John Hodge (Mutabah/thePowersGang) + * + * hir/from_ast.hpp + * - Shared code definitions for constructing the HIR from AST + */ #pragma once #include <hir/expr_ptr.hpp> @@ -9,3 +16,5 @@ extern ::HIR::SimplePath LowerHIR_SimplePath(const Span& sp, const ::AST::Pat extern ::HIR::TypeRef LowerHIR_Type(const ::TypeRef& ty); extern ::HIR::Pattern LowerHIR_Pattern(const ::AST::Pattern& pat); +extern ::std::string g_core_crate; +extern ::HIR::Crate* g_crate_ptr; diff --git a/src/hir/from_ast_expr.cpp b/src/hir/from_ast_expr.cpp index 5e3908aa..35d27b24 100644 --- a/src/hir/from_ast_expr.cpp +++ b/src/hir/from_ast_expr.cpp @@ -1,4 +1,9 @@ /* + * MRustC - Rust Compiler + * - By John Hodge (Mutabah/thePowersGang) + * + * hir/from_ast_expr.cpp + * - Constructs a HIR expression tree from an AST expression tree */ #include <hir/expr_ptr.hpp> #include <hir/expr.hpp> @@ -104,10 +109,10 @@ struct LowerHIR_ExprNode_Visitor: { case ::AST::ExprNode_BinOp::RANGE: { // NOTE: Not language items - auto path_Range = ::HIR::GenericPath( ::HIR::SimplePath("", {"ops", "Range"}) ); - auto path_RangeFrom = ::HIR::GenericPath( ::HIR::SimplePath("", {"ops", "RangeFrom"}) ); - auto path_RangeTo = ::HIR::GenericPath( ::HIR::SimplePath("", {"ops", "RangeTo"}) ); - auto path_RangeFull = ::HIR::GenericPath( ::HIR::SimplePath("", {"ops", "RangeFull"}) ); + auto path_Range = ::HIR::GenericPath( ::HIR::SimplePath(g_core_crate, {"ops", "Range"}) ); + auto path_RangeFrom = ::HIR::GenericPath( ::HIR::SimplePath(g_core_crate, {"ops", "RangeFrom"}) ); + auto path_RangeTo = ::HIR::GenericPath( ::HIR::SimplePath(g_core_crate, {"ops", "RangeTo"}) ); + auto path_RangeFull = ::HIR::GenericPath( ::HIR::SimplePath(g_core_crate, {"ops", "RangeFull"}) ); ::HIR::ExprNode_StructLiteral::t_values values; if( v.m_left ) @@ -134,8 +139,8 @@ struct LowerHIR_ExprNode_Visitor: break; } case ::AST::ExprNode_BinOp::RANGE_INC: { // NOTE: Not language items - auto path_RangeInclusive_NonEmpty = ::HIR::GenericPath( ::HIR::SimplePath("", {"ops", "RangeInclusive", "NonEmpty"}) ); - auto path_RangeToInclusive = ::HIR::GenericPath( ::HIR::SimplePath("", {"ops", "RangeToInclusive"}) ); + auto path_RangeInclusive_NonEmpty = ::HIR::GenericPath( ::HIR::SimplePath(g_core_crate, {"ops", "RangeInclusive", "NonEmpty"}) ); + auto path_RangeToInclusive = ::HIR::GenericPath( ::HIR::SimplePath(g_core_crate, {"ops", "RangeToInclusive"}) ); if( v.m_left ) { |