summaryrefslogtreecommitdiff
path: root/src/expand/include.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2019-11-02 11:07:23 +0800
committerJohn Hodge <tpg@ucc.asn.au>2019-11-02 11:07:23 +0800
commit1d02810c3cf908bfba7c15ae50eb5314603b9d85 (patch)
tree79dd5e4ef4c3ff79db0912ba546f08e61a7a8c10 /src/expand/include.cpp
parent7111acba04d72fe4084b1a1f3209ff83efe8614d (diff)
parent8b53b38f40625ab0510f541d69db3f83332a830a (diff)
downloadmrust-1d02810c3cf908bfba7c15ae50eb5314603b9d85.tar.gz
Merge branch 'nightly-1.29' - #95 Working support for rustc 1.29
Diffstat (limited to 'src/expand/include.cpp')
-rw-r--r--src/expand/include.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/expand/include.cpp b/src/expand/include.cpp
index 59f33d47..14a7bc7b 100644
--- a/src/expand/include.cpp
+++ b/src/expand/include.cpp
@@ -12,6 +12,7 @@
#include <parse/ttstream.hpp>
#include <parse/lex.hpp> // Lexer (new files)
#include <ast/expr.hpp>
+#include <ast/crate.hpp>
namespace {
@@ -63,11 +64,8 @@ namespace {
class CIncludeExpander:
public ExpandProcMacro
{
- ::std::unique_ptr<TokenStream> expand(const Span& sp, const AST::Crate& crate, const ::std::string& ident, const TokenTree& tt, AST::Module& mod) override
+ ::std::unique_ptr<TokenStream> expand(const Span& sp, const AST::Crate& crate, const TokenTree& tt, AST::Module& mod) override
{
- if( ident != "" )
- ERROR(sp, E0000, "include! doesn't take an ident");
-
Token tok;
auto lex = TTStream(sp, tt);
@@ -75,6 +73,7 @@ class CIncludeExpander:
GET_CHECK_TOK(tok, lex, TOK_EOF);
::std::string file_path = get_path_relative_to(mod.m_file_info.path, mv$(path));
+ crate.m_extra_files.push_back(file_path);
try {
return box$( Lexer(file_path) );
@@ -89,11 +88,8 @@ class CIncludeExpander:
class CIncludeBytesExpander:
public ExpandProcMacro
{
- ::std::unique_ptr<TokenStream> expand(const Span& sp, const AST::Crate& crate, const ::std::string& ident, const TokenTree& tt, AST::Module& mod) override
+ ::std::unique_ptr<TokenStream> expand(const Span& sp, const AST::Crate& crate, const TokenTree& tt, AST::Module& mod) override
{
- if( ident != "" )
- ERROR(sp, E0000, "include_bytes! doesn't take an ident");
-
Token tok;
auto lex = TTStream(sp, tt);
@@ -101,6 +97,7 @@ class CIncludeBytesExpander:
GET_CHECK_TOK(tok, lex, TOK_EOF);
::std::string file_path = get_path_relative_to(mod.m_file_info.path, mv$(path));
+ crate.m_extra_files.push_back(file_path);
::std::ifstream is(file_path);
if( !is.good() ) {
@@ -118,11 +115,8 @@ class CIncludeBytesExpander:
class CIncludeStrExpander:
public ExpandProcMacro
{
- ::std::unique_ptr<TokenStream> expand(const Span& sp, const AST::Crate& crate, const ::std::string& ident, const TokenTree& tt, AST::Module& mod) override
+ ::std::unique_ptr<TokenStream> expand(const Span& sp, const AST::Crate& crate, const TokenTree& tt, AST::Module& mod) override
{
- if( ident != "" )
- ERROR(sp, E0000, "include_str! doesn't take an ident");
-
Token tok;
auto lex = TTStream(sp, tt);
@@ -130,6 +124,7 @@ class CIncludeStrExpander:
GET_CHECK_TOK(tok, lex, TOK_EOF);
::std::string file_path = get_path_relative_to(mod.m_file_info.path, mv$(path));
+ crate.m_extra_files.push_back(file_path);
::std::ifstream is(file_path);
if( !is.good() ) {