diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2011-07-05 16:23:07 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2011-07-06 15:14:52 -0700 |
| commit | 7714cb297b5ef54690acaec26cae4828adfceab7 (patch) | |
| tree | ea7c41d9ce65d690abd27bdccb4f793f39536f58 /src/comp/syntax/ext | |
| parent | 368f1f4ba8c00a42cc9ffb91082b9462ecb61dc3 (diff) | |
| download | rust-7714cb297b5ef54690acaec26cae4828adfceab7.tar.gz rust-7714cb297b5ef54690acaec26cae4828adfceab7.zip | |
rustc: Make AST paths use interior vectors
Diffstat (limited to 'src/comp/syntax/ext')
| -rw-r--r-- | src/comp/syntax/ext/base.rs | 5 | ||||
| -rw-r--r-- | src/comp/syntax/ext/fmt.rs | 11 | ||||
| -rw-r--r-- | src/comp/syntax/ext/simplext.rs | 6 |
3 files changed, 12 insertions, 10 deletions
diff --git a/src/comp/syntax/ext/base.rs b/src/comp/syntax/ext/base.rs index a0ba306edfa..766dd9f3f28 100644 --- a/src/comp/syntax/ext/base.rs +++ b/src/comp/syntax/ext/base.rs @@ -1,3 +1,4 @@ +import std::ivec; import std::vec; import std::option; import std::map::hashmap; @@ -71,8 +72,8 @@ fn expr_to_str(&ext_ctxt cx, @ast::expr expr, str error) -> str { fn expr_to_ident(&ext_ctxt cx, @ast::expr expr, str error) -> ast::ident { alt(expr.node) { case (ast::expr_path(?p)) { - if (vec::len(p.node.types) > 0u - || vec::len(p.node.idents) != 1u) { + if (ivec::len(p.node.types) > 0u + || ivec::len(p.node.idents) != 1u) { cx.span_fatal(expr.span, error); } else { ret p.node.idents.(0); diff --git a/src/comp/syntax/ext/fmt.rs b/src/comp/syntax/ext/fmt.rs index 1ea2d694374..c7e2787d502 100644 --- a/src/comp/syntax/ext/fmt.rs +++ b/src/comp/syntax/ext/fmt.rs @@ -60,10 +60,9 @@ fn pieces_to_expr(&ext_ctxt cx, span sp, vec[piece] pieces, auto binexpr = ast::expr_binary(ast::add, lhs, rhs); ret @rec(id=cx.next_id(), node=binexpr, span=sp); } - fn make_path_expr(&ext_ctxt cx, span sp, vec[ast::ident] idents) + fn make_path_expr(&ext_ctxt cx, span sp, &ast::ident[] idents) -> @ast::expr { - let vec[@ast::ty] types = []; - auto path = rec(idents=idents, types=types); + auto path = rec(idents=idents, types=~[]); auto sp_path = rec(node=path, span=sp); auto pathexpr = ast::expr_path(sp_path); ret @rec(id=cx.next_id(), node=pathexpr, span=sp); @@ -73,7 +72,7 @@ fn pieces_to_expr(&ext_ctxt cx, span sp, vec[piece] pieces, auto vecexpr = ast::expr_vec(exprs, ast::imm, ast::sk_rc); ret @rec(id=cx.next_id(), node=vecexpr, span=sp); } - fn make_call(&ext_ctxt cx, span sp, vec[ast::ident] fn_path, + fn make_call(&ext_ctxt cx, span sp, &ast::ident[] fn_path, vec[@ast::expr] args) -> @ast::expr { auto pathexpr = make_path_expr(cx, sp, fn_path); auto callexpr = ast::expr_call(pathexpr, args); @@ -92,11 +91,11 @@ fn pieces_to_expr(&ext_ctxt cx, span sp, vec[piece] pieces, auto recexpr = ast::expr_rec(astfields, option::none[@ast::expr]); ret @rec(id=cx.next_id(), node=recexpr, span=sp); } - fn make_path_vec(str ident) -> vec[str] { + fn make_path_vec(str ident) -> str[] { // FIXME: #fmt can't currently be used from within std // because we're explicitly referencing the 'std' crate here - ret ["std", "extfmt", "rt", ident]; + ret ~["std", "extfmt", "rt", ident]; } fn make_rt_path_expr(&ext_ctxt cx, span sp, str ident) -> @ast::expr { diff --git a/src/comp/syntax/ext/simplext.rs b/src/comp/syntax/ext/simplext.rs index e214524f0b7..53b37da6c27 100644 --- a/src/comp/syntax/ext/simplext.rs +++ b/src/comp/syntax/ext/simplext.rs @@ -1,6 +1,7 @@ use std; import codemap::span; +import std::ivec; import std::vec; import std::option; import vec::map; @@ -50,7 +51,7 @@ fn subst_ident(&ext_ctxt cx, &vec[@ast::expr] args, fn subst_path(&ext_ctxt cx, &vec[@ast::expr] args, @vec[ident] param_names, &path_ p, ast_fold fld) -> path_ { // Don't substitute into qualified names. - if (len(p.types) > 0u || len(p.idents) != 1u) { ret p; } + if (ivec::len(p.types) > 0u || ivec::len(p.idents) != 1u) { ret p; } alt (position(p.idents.(0), *param_names)) { case (some[uint](?idx)) { alt (args.(idx).node) { @@ -75,7 +76,8 @@ fn subst_expr(&ext_ctxt cx, &vec[@ast::expr] args, @vec[ident] param_names, ret alt(e) { case (expr_path(?p)){ // Don't substitute into qualified names. - if (len(p.node.types) > 0u || len(p.node.idents) != 1u) { e } + if (ivec::len(p.node.types) > 0u || + ivec::len(p.node.idents) != 1u) { e } alt (position(p.node.idents.(0), *param_names)) { case (some[uint](?idx)) { args.(idx).node |
