rustc: Make AST paths use interior vectors
This commit is contained in:
parent
b108280db1
commit
1591955adf
12 changed files with 71 additions and 43 deletions
|
|
@ -18,6 +18,7 @@ import syntax::ast::respan;
|
|||
import middle::ty::constr_table;
|
||||
import syntax::visit;
|
||||
import visit::vt;
|
||||
import std::ivec;
|
||||
import std::map::hashmap;
|
||||
import std::list;
|
||||
import std::list::list;
|
||||
|
|
@ -554,9 +555,9 @@ fn mk_unresolved_msg(&ident id, &str kind) -> str {
|
|||
}
|
||||
|
||||
// Lookup helpers
|
||||
fn lookup_path_strict(&env e, &scopes sc, &span sp, vec[ident] idents,
|
||||
fn lookup_path_strict(&env e, &scopes sc, &span sp, &ident[] idents,
|
||||
namespace ns) -> option::t[def] {
|
||||
auto n_idents = vec::len(idents);
|
||||
auto n_idents = ivec::len(idents);
|
||||
auto headns = if (n_idents == 1u) { ns } else { ns_module };
|
||||
auto dcur = lookup_in_scope_strict(e, sc, sp, idents.(0), headns);
|
||||
auto i = 1u;
|
||||
|
|
|
|||
|
|
@ -641,7 +641,7 @@ fn substitute_arg(&ty::ctxt cx, &(@expr)[] actuals, @constr_arg a) ->
|
|||
}
|
||||
|
||||
fn path_to_ident(&ty::ctxt cx, &path p) -> ident {
|
||||
alt (std::vec::last(p.node.idents)) {
|
||||
alt (ivec::last(p.node.idents)) {
|
||||
case (none) { cx.sess.span_fatal(p.span, "Malformed path"); }
|
||||
case (some(?i)) { ret i; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ fn kill_poststate(&fn_ctxt fcx, node_id id, &constr_ c) -> bool {
|
|||
fn clear_in_poststate_expr(&fn_ctxt fcx, &@expr e, &poststate t) {
|
||||
alt (e.node) {
|
||||
case (expr_path(?p)) {
|
||||
alt (std::vec::last(p.node.idents)) {
|
||||
alt (ivec::last(p.node.idents)) {
|
||||
case (some(?i)) {
|
||||
alt (local_node_id_to_def(fcx, e.id)) {
|
||||
case (some(def_local(?d_id))) {
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ fn instantiate_path(&@fn_ctxt fcx, &ast::path pth, &ty_param_count_and_ty tpt,
|
|||
ty_param_count);
|
||||
auto ty_param_vars = bind_result._0;
|
||||
auto ty_substs_opt;
|
||||
auto ty_substs_len = vec::len[@ast::ty](pth.node.types);
|
||||
auto ty_substs_len = ivec::len[@ast::ty](pth.node.types);
|
||||
if (ty_substs_len > 0u) {
|
||||
let ty::t[] ty_substs = ~[];
|
||||
auto i = 0u;
|
||||
|
|
@ -256,7 +256,7 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
|
|||
ret rec(ty=ast_ty_to_ty(tcx, getter, mt.ty), mut=mt.mut);
|
||||
}
|
||||
fn instantiate(&ty::ctxt tcx, &span sp, &ty_getter getter,
|
||||
&ast::def_id id, &vec[@ast::ty] args) -> ty::t {
|
||||
&ast::def_id id, &(@ast::ty)[] args) -> ty::t {
|
||||
// TODO: maybe record cname chains so we can do
|
||||
// "foo = int" like OCaml?
|
||||
|
||||
|
|
@ -344,9 +344,8 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
|
|||
case (ast::ty_path(?path, ?id)) {
|
||||
alt (tcx.def_map.find(id)) {
|
||||
case (some(ast::def_ty(?id))) {
|
||||
typ =
|
||||
instantiate(tcx, ast_ty.span, getter, id,
|
||||
path.node.types);
|
||||
typ = instantiate(tcx, ast_ty.span, getter, id,
|
||||
path.node.types);
|
||||
}
|
||||
case (some(ast::def_native_ty(?id))) { typ = getter(id)._1; }
|
||||
case (some(ast::def_ty_arg(?id))) {
|
||||
|
|
@ -1665,7 +1664,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
|||
// The definition doesn't take type parameters. If the programmer
|
||||
// supplied some, that's an error.
|
||||
|
||||
if (vec::len[@ast::ty](pth.node.types) > 0u) {
|
||||
if (ivec::len[@ast::ty](pth.node.types) > 0u) {
|
||||
fcx.ccx.tcx.sess.span_fatal(expr.span,
|
||||
"this kind of value does not \
|
||||
take type parameters");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue