// You should have received a copy of the GNU General Public License
// along with GCC; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
+
#include "rust-ast-collector.h"
#include "rust-ast.h"
#include "rust-diagnostics.h"
#include "rust-expr.h"
#include "rust-item.h"
#include "rust-keyword-values.h"
+#include "rust-path.h"
#include "rust-system.h"
#include "rust-token.h"
void
TokenCollector::visit (PathInExpression &path)
{
- if (path.opening_scope_resolution ())
+ if (path.is_lang_item ())
{
- push (Rust::Token::make (SCOPE_RESOLUTION, path.get_locus ()));
+ push (Rust::Token::make (TokenId::HASH, path.get_locus ()));
+ push (Rust::Token::make (TokenId::LEFT_SQUARE, path.get_locus ()));
+ push (Rust::Token::make_identifier (path.get_locus (), "lang"));
+ push (Rust::Token::make (TokenId::EQUAL, path.get_locus ()));
+ push (
+ Rust::Token::make_string (path.get_locus (),
+ LangItem::ToString (path.get_lang_item ())));
+ push (Rust::Token::make (TokenId::RIGHT_SQUARE, path.get_locus ()));
+
+ return;
}
+ if (path.opening_scope_resolution ())
+ push (Rust::Token::make (SCOPE_RESOLUTION, path.get_locus ()));
+
visit_items_joined_by_separator (path.get_segments (), SCOPE_RESOLUTION);
}
DefaultASTVisitor::visit (AST::PathInExpression &path)
{
visit_outer_attrs (path);
- for (auto &segment : path.get_segments ())
- visit (segment);
+
+ if (!path.is_lang_item ())
+ for (auto &segment : path.get_segments ())
+ visit (segment);
}
void
#include "rust-cfg-strip.h"
#include "rust-ast-full.h"
#include "rust-ast-visitor.h"
+#include "rust-path.h"
#include "rust-session-manager.h"
#include "rust-attribute-values.h"
return;
}
- for (auto &segment : path.get_segments ())
+ if (!path.is_lang_item ())
{
- if (segment.has_generic_args ())
- maybe_strip_generic_args (segment.get_generic_args ());
+ for (auto &segment : path.get_segments ())
+ {
+ if (segment.has_generic_args ())
+ maybe_strip_generic_args (segment.get_generic_args ());
+ }
}
}
void
ExpandVisitor::visit (AST::PathInExpression &path)
{
- for (auto &segment : path.get_segments ())
- if (segment.has_generic_args ())
- expand_generic_args (segment.get_generic_args ());
+ if (!path.is_lang_item ())
+ for (auto &segment : path.get_segments ())
+ if (segment.has_generic_args ())
+ expand_generic_args (segment.get_generic_args ());
}
void
void
ASTLoweringExprWithBlock::visit (AST::ForLoopExpr &expr)
{
- // TODO FIXME
-
- // HIR::BlockExpr *loop_block
- // = ASTLoweringBlock::translate (expr.get_loop_block ().get (),
- // &terminated);
- // HIR::LoopLabel loop_label = lower_loop_label (expr.get_loop_label ());
- // HIR::Expr *iterator_expr
- // = ASTLoweringExpr::translate (expr.get_iterator_expr ().get (),
- // &terminated);
- // HIR::Pattern *loop_pattern
- // = ASTLoweringPattern::translate (expr.get_pattern ().get ());
-
- // auto crate_num = mappings->get_current_crate ();
- // Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
- // mappings->get_next_hir_id (crate_num),
- // UNKNOWN_LOCAL_DEFID);
-
- gcc_unreachable ();
+ rust_unreachable ();
}
void
void
ASTLowerPathInExpression::visit (AST::PathInExpression &expr)
{
+ auto crate_num = mappings.get_current_crate ();
+ Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
+ mappings.get_next_hir_id (crate_num),
+ UNKNOWN_LOCAL_DEFID);
+
+ if (expr.is_lang_item ())
+ {
+ translated = new HIR::PathInExpression (mapping, expr.get_lang_item (),
+ expr.get_locus (), false);
+ return;
+ }
+
std::vector<HIR::PathExprSegment> path_segments;
auto &segments = expr.get_segments ();
for (auto &s : segments)
HIR::PathExprSegment *lowered_seg = &path_segments.back ();
mappings.insert_hir_path_expr_seg (lowered_seg);
}
- auto crate_num = mappings.get_current_crate ();
- Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
- mappings.get_next_hir_id (crate_num),
- UNKNOWN_LOCAL_DEFID);
translated = new HIR::PathInExpression (mapping, std::move (path_segments),
expr.get_locus (),
#include "rust-ast-resolve-path.h"
#include "rust-ast-resolve-type.h"
+#include "rust-hir-map.h"
#include "rust-path.h"
namespace Rust {
NodeId
ResolvePath::resolve_path (AST::PathInExpression &expr)
{
+ if (expr.is_lang_item ())
+ return Analysis::Mappings::get ().get_lang_item_node (
+ expr.get_lang_item ());
+
NodeId resolved_node_id = UNKNOWN_NODEID;
NodeId module_scope_id = resolver->peek_current_module_scope ();
NodeId previous_resolved_node_id = module_scope_id;
void
EarlyNameResolver::visit (AST::PathInExpression &path)
{
- for (auto &segment : path.get_segments ())
- if (segment.has_generic_args ())
- resolve_generic_args (segment.get_generic_args ());
+ if (!path.is_lang_item ())
+ for (auto &segment : path.get_segments ())
+ if (segment.has_generic_args ())
+ resolve_generic_args (segment.get_generic_args ());
}
void