Change ast::path into a struct.
This commit is contained in:
parent
1be4bfb8cc
commit
bea67bde21
@ -76,7 +76,7 @@ fn inject_libcore_ref(sess: Session,
|
||||
fold_mod: |module, fld| {
|
||||
let n2 = sess.next_node_id();
|
||||
|
||||
let prelude_path = @{
|
||||
let prelude_path = @ast::path {
|
||||
span: dummy_sp(),
|
||||
global: false,
|
||||
idents: ~[
|
||||
|
@ -244,11 +244,19 @@ fn nospan<T: Copy>(t: T) -> ast::spanned<T> {
|
||||
}
|
||||
|
||||
fn path_node(+ids: ~[ast::ident]) -> @ast::path {
|
||||
@{span: dummy_sp(), global: false, idents: ids, rp: None, types: ~[]}
|
||||
@ast::path { span: dummy_sp(),
|
||||
global: false,
|
||||
idents: ids,
|
||||
rp: None,
|
||||
types: ~[] }
|
||||
}
|
||||
|
||||
fn path_node_global(+ids: ~[ast::ident]) -> @ast::path {
|
||||
@{span: dummy_sp(), global: true, idents: ids, rp: None, types: ~[]}
|
||||
@ast::path { span: dummy_sp(),
|
||||
global: true,
|
||||
idents: ids,
|
||||
rp: None,
|
||||
types: ~[] }
|
||||
}
|
||||
|
||||
fn mk_std(cx: test_ctxt) -> @ast::view_item {
|
||||
|
@ -101,9 +101,11 @@ fn parse_path(st: @pstate) -> @ast::path {
|
||||
':' => { next(st); next(st); }
|
||||
c => {
|
||||
if c == '(' {
|
||||
return @{span: ast_util::dummy_sp(),
|
||||
global: false, idents: idents,
|
||||
rp: None, types: ~[]};
|
||||
return @ast::path { span: ast_util::dummy_sp(),
|
||||
global: false,
|
||||
idents: idents,
|
||||
rp: None,
|
||||
types: ~[] };
|
||||
} else { idents.push(parse_ident_(st, is_last)); }
|
||||
}
|
||||
}
|
||||
|
@ -79,11 +79,13 @@ type fn_ident = Option<ident>;
|
||||
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
type path = {span: span,
|
||||
global: bool,
|
||||
idents: ~[ident],
|
||||
rp: Option<@region>,
|
||||
types: ~[@Ty]};
|
||||
struct path {
|
||||
span: span,
|
||||
global: bool,
|
||||
idents: ~[ident],
|
||||
rp: Option<@region>,
|
||||
types: ~[@Ty],
|
||||
}
|
||||
|
||||
type crate_num = int;
|
||||
|
||||
|
@ -294,8 +294,11 @@ fn default_block(+stmts1: ~[@stmt], expr1: Option<@expr>, id1: node_id) ->
|
||||
}
|
||||
|
||||
fn ident_to_path(s: span, +i: ident) -> @path {
|
||||
@{span: s, global: false, idents: ~[i],
|
||||
rp: None, types: ~[]}
|
||||
@ast::path { span: s,
|
||||
global: false,
|
||||
idents: ~[i],
|
||||
rp: None,
|
||||
types: ~[] }
|
||||
}
|
||||
|
||||
fn ident_to_pat(id: node_id, s: span, +i: ident) -> @pat {
|
||||
|
@ -264,21 +264,45 @@ priv impl ext_ctxt {
|
||||
}
|
||||
|
||||
fn path(span: span, strs: ~[ast::ident]) -> @ast::path {
|
||||
@{span: span, global: false, idents: strs, rp: None, types: ~[]}
|
||||
@ast::path {
|
||||
span: span,
|
||||
global: false,
|
||||
idents: strs,
|
||||
rp: None,
|
||||
types: ~[]
|
||||
}
|
||||
}
|
||||
|
||||
fn path_global(span: span, strs: ~[ast::ident]) -> @ast::path {
|
||||
@{span: span, global: true, idents: strs, rp: None, types: ~[]}
|
||||
@ast::path {
|
||||
span: span,
|
||||
global: true,
|
||||
idents: strs,
|
||||
rp: None,
|
||||
types: ~[]
|
||||
}
|
||||
}
|
||||
|
||||
fn path_tps(span: span, strs: ~[ast::ident],
|
||||
tps: ~[@ast::Ty]) -> @ast::path {
|
||||
@{span: span, global: false, idents: strs, rp: None, types: tps}
|
||||
@ast::path {
|
||||
span: span,
|
||||
global: false,
|
||||
idents: strs,
|
||||
rp: None,
|
||||
types: tps
|
||||
}
|
||||
}
|
||||
|
||||
fn path_tps_global(span: span, strs: ~[ast::ident],
|
||||
tps: ~[@ast::Ty]) -> @ast::path {
|
||||
@{span: span, global: true, idents: strs, rp: None, types: tps}
|
||||
@ast::path {
|
||||
span: span,
|
||||
global: true,
|
||||
idents: strs,
|
||||
rp: None,
|
||||
types: tps
|
||||
}
|
||||
}
|
||||
|
||||
fn ty_path(span: span, strs: ~[ast::ident],
|
||||
@ -289,11 +313,9 @@ priv impl ext_ctxt {
|
||||
}
|
||||
|
||||
fn binder_pat(span: span, nm: ast::ident) -> @ast::pat {
|
||||
let path = @{span: span, global: false, idents: ~[nm],
|
||||
rp: None, types: ~[]};
|
||||
@{id: self.next_id(),
|
||||
node: ast::pat_ident(ast::bind_by_ref(ast::m_imm),
|
||||
path,
|
||||
self.path(span, ~[nm]),
|
||||
None),
|
||||
span: span}
|
||||
}
|
||||
|
@ -53,20 +53,29 @@ fn mk_unary(cx: ext_ctxt, sp: span, op: ast::unop, e: @ast::expr)
|
||||
mk_expr(cx, sp, ast::expr_unary(op, e))
|
||||
}
|
||||
fn mk_raw_path(sp: span, idents: ~[ast::ident]) -> @ast::path {
|
||||
let p : @ast::path = @{span: sp, global: false, idents: idents,
|
||||
rp: None, types: ~[]};
|
||||
let p = @ast::path { span: sp,
|
||||
global: false,
|
||||
idents: idents,
|
||||
rp: None,
|
||||
types: ~[] };
|
||||
return p;
|
||||
}
|
||||
fn mk_raw_path_(sp: span,
|
||||
idents: ~[ast::ident],
|
||||
+types: ~[@ast::Ty])
|
||||
-> @ast::path {
|
||||
@{ span: sp, global: false, idents: idents, rp: None, types: move types }
|
||||
@ast::path { span: sp,
|
||||
global: false,
|
||||
idents: idents,
|
||||
rp: None,
|
||||
types: move types }
|
||||
}
|
||||
fn mk_raw_path_global(sp: span, idents: ~[ast::ident]) -> @ast::path {
|
||||
let p : @ast::path = @{span: sp, global: true, idents: idents,
|
||||
rp: None, types: ~[]};
|
||||
return p;
|
||||
@ast::path { span: sp,
|
||||
global: true,
|
||||
idents: idents,
|
||||
rp: None,
|
||||
types: ~[] }
|
||||
}
|
||||
fn mk_path(cx: ext_ctxt, sp: span, idents: ~[ast::ident]) ->
|
||||
@ast::expr {
|
||||
|
@ -36,9 +36,11 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: ~[ast::token_tree])
|
||||
|
||||
let e = @{id: cx.next_id(),
|
||||
callee_id: cx.next_id(),
|
||||
node: ast::expr_path(@{span: sp, global: false,
|
||||
idents: ~[res],
|
||||
rp: None, types: ~[]}),
|
||||
node: ast::expr_path(@ast::path { span: sp,
|
||||
global: false,
|
||||
idents: ~[res],
|
||||
rp: None,
|
||||
types: ~[] }),
|
||||
span: sp};
|
||||
mr_expr(e)
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use ast;
|
||||
use ast::{TraitTyParamBound, Ty, and, bind_by_ref, binop, deref, enum_def};
|
||||
use ast::{enum_variant_kind, expr, expr_match, ident, item, item_};
|
||||
use ast::{item_enum, item_impl, item_struct, m_imm, meta_item, method};
|
||||
@ -218,7 +219,7 @@ fn create_derived_impl(cx: ext_ctxt,
|
||||
let impl_ty_params = dvec::unwrap(move impl_ty_params);
|
||||
|
||||
// Create the reference to the trait.
|
||||
let trait_path = {
|
||||
let trait_path = ast::path {
|
||||
span: span,
|
||||
global: true,
|
||||
idents: trait_path.map(|x| *x),
|
||||
|
@ -34,19 +34,19 @@ mod syntax {
|
||||
}
|
||||
|
||||
fn path(ids: ~[ident], span: span) -> @ast::path {
|
||||
@{span: span,
|
||||
global: false,
|
||||
idents: ids,
|
||||
rp: None,
|
||||
types: ~[]}
|
||||
@ast::path { span: span,
|
||||
global: false,
|
||||
idents: ids,
|
||||
rp: None,
|
||||
types: ~[] }
|
||||
}
|
||||
|
||||
fn path_global(ids: ~[ident], span: span) -> @ast::path {
|
||||
@{span: span,
|
||||
global: true,
|
||||
idents: ids,
|
||||
rp: None,
|
||||
types: ~[]}
|
||||
@ast::path { span: span,
|
||||
global: true,
|
||||
idents: ids,
|
||||
rp: None,
|
||||
types: ~[] }
|
||||
}
|
||||
|
||||
trait append_types {
|
||||
@ -56,13 +56,13 @@ trait append_types {
|
||||
|
||||
impl @ast::path: append_types {
|
||||
fn add_ty(ty: @ast::Ty) -> @ast::path {
|
||||
@{types: vec::append_one(self.types, ty),
|
||||
.. *self}
|
||||
@ast::path { types: vec::append_one(self.types, ty),
|
||||
.. *self}
|
||||
}
|
||||
|
||||
fn add_tys(+tys: ~[@ast::Ty]) -> @ast::path {
|
||||
@{types: vec::append(self.types, tys),
|
||||
.. *self}
|
||||
@ast::path { types: vec::append(self.types, tys),
|
||||
.. *self}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -614,10 +614,11 @@ fn noop_fold_ident(&&i: ident, _fld: ast_fold) -> ident {
|
||||
}
|
||||
|
||||
fn noop_fold_path(&&p: path, fld: ast_fold) -> path {
|
||||
return {span: fld.new_span(p.span), global: p.global,
|
||||
idents: vec::map(p.idents, |x| fld.fold_ident(*x)),
|
||||
rp: p.rp,
|
||||
types: vec::map(p.types, |x| fld.fold_ty(*x))};
|
||||
ast::path { span: fld.new_span(p.span),
|
||||
global: p.global,
|
||||
idents: p.idents.map(|x| fld.fold_ident(*x)),
|
||||
rp: p.rp,
|
||||
types: p.types.map(|x| fld.fold_ty(*x)) }
|
||||
}
|
||||
|
||||
fn noop_fold_local(l: local_, fld: ast_fold) -> local_ {
|
||||
|
@ -802,8 +802,11 @@ impl Parser {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@{span: mk_sp(lo, self.last_span.hi), global: global,
|
||||
idents: ids, rp: None, types: ~[]}
|
||||
@ast::path { span: mk_sp(lo, self.last_span.hi),
|
||||
global: global,
|
||||
idents: ids,
|
||||
rp: None,
|
||||
types: ~[] }
|
||||
}
|
||||
|
||||
fn parse_value_path() -> @path {
|
||||
@ -849,9 +852,10 @@ impl Parser {
|
||||
}
|
||||
};
|
||||
|
||||
return @{span: mk_sp(lo, tps.span.hi),
|
||||
rp: rp,
|
||||
types: tps.node,.. *path};
|
||||
@ast::path { span: mk_sp(lo, tps.span.hi),
|
||||
rp: rp,
|
||||
types: tps.node,
|
||||
.. *path }
|
||||
}
|
||||
|
||||
fn parse_mutability() -> mutability {
|
||||
@ -2730,18 +2734,27 @@ impl Parser {
|
||||
typarams: ~[ty_param]) -> @path {
|
||||
let s = self.last_span;
|
||||
|
||||
@{span: s, global: false, idents: ~[i],
|
||||
rp: None,
|
||||
types: vec::map(typarams, |tp| {
|
||||
@{id: self.get_id(),
|
||||
node: ty_path(ident_to_path(s, tp.ident), self.get_id()),
|
||||
span: s}})
|
||||
@ast::path {
|
||||
span: s,
|
||||
global: false,
|
||||
idents: ~[i],
|
||||
rp: None,
|
||||
types: do typarams.map |tp| {
|
||||
@{
|
||||
id: self.get_id(),
|
||||
node: ty_path(ident_to_path(s, tp.ident), self.get_id()),
|
||||
span: s
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn ident_to_path(i: ident) -> @path {
|
||||
@{span: self.last_span, global: false, idents: ~[i],
|
||||
rp: None, types: ~[]}
|
||||
@ast::path { span: self.last_span,
|
||||
global: false,
|
||||
idents: ~[i],
|
||||
rp: None,
|
||||
types: ~[] }
|
||||
}
|
||||
|
||||
fn parse_trait_ref() -> @trait_ref {
|
||||
@ -3661,8 +3674,11 @@ impl Parser {
|
||||
let id = self.parse_ident();
|
||||
path.push(id);
|
||||
}
|
||||
let path = @{span: mk_sp(lo, self.span.hi), global: false,
|
||||
idents: path, rp: None, types: ~[]};
|
||||
let path = @ast::path { span: mk_sp(lo, self.span.hi),
|
||||
global: false,
|
||||
idents: path,
|
||||
rp: None,
|
||||
types: ~[] };
|
||||
return @spanned(lo, self.span.hi,
|
||||
view_path_simple(first_ident, path, namespace,
|
||||
self.get_id()));
|
||||
@ -3686,9 +3702,11 @@ impl Parser {
|
||||
token::LBRACE, token::RBRACE,
|
||||
seq_sep_trailing_allowed(token::COMMA),
|
||||
|p| p.parse_path_list_ident());
|
||||
let path = @{span: mk_sp(lo, self.span.hi),
|
||||
global: false, idents: path,
|
||||
rp: None, types: ~[]};
|
||||
let path = @ast::path { span: mk_sp(lo, self.span.hi),
|
||||
global: false,
|
||||
idents: path,
|
||||
rp: None,
|
||||
types: ~[] };
|
||||
return @spanned(lo, self.span.hi,
|
||||
view_path_list(path, idents, self.get_id()));
|
||||
}
|
||||
@ -3696,9 +3714,11 @@ impl Parser {
|
||||
// foo::bar::*
|
||||
token::BINOP(token::STAR) => {
|
||||
self.bump();
|
||||
let path = @{span: mk_sp(lo, self.span.hi),
|
||||
global: false, idents: path,
|
||||
rp: None, types: ~[]};
|
||||
let path = @ast::path { span: mk_sp(lo, self.span.hi),
|
||||
global: false,
|
||||
idents: path,
|
||||
rp: None,
|
||||
types: ~[] };
|
||||
return @spanned(lo, self.span.hi,
|
||||
view_path_glob(path, self.get_id()));
|
||||
}
|
||||
@ -3710,8 +3730,11 @@ impl Parser {
|
||||
_ => ()
|
||||
}
|
||||
let last = path[vec::len(path) - 1u];
|
||||
let path = @{span: mk_sp(lo, self.span.hi), global: false,
|
||||
idents: path, rp: None, types: ~[]};
|
||||
let path = @ast::path { span: mk_sp(lo, self.span.hi),
|
||||
global: false,
|
||||
idents: path,
|
||||
rp: None,
|
||||
types: ~[] };
|
||||
return @spanned(lo, self.span.hi,
|
||||
view_path_simple(last, path, namespace, self.get_id()));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user