aboutsummaryrefslogtreecommitdiff
path: root/src/comp/middle
diff options
context:
space:
mode:
authorMarijn Haverbeke <[email protected]>2011-05-12 17:20:07 +0200
committerMarijn Haverbeke <[email protected]>2011-05-12 21:30:35 +0200
commit6510f1ce7cb026ceb98689583c13f18c1e7c2c12 (patch)
treedaee2983e121887082fbba929919d2a2dccef36c /src/comp/middle
parentRemove some truly wrong logic in parse_constrs (diff)
downloadrust-6510f1ce7cb026ceb98689583c13f18c1e7c2c12.tar.xz
rust-6510f1ce7cb026ceb98689583c13f18c1e7c2c12.zip
Change module dereference syntax from . to ::
This will need to be a snapshot.
Diffstat (limited to 'src/comp/middle')
-rw-r--r--src/comp/middle/metadata.rs2
-rw-r--r--src/comp/middle/resolve.rs54
-rw-r--r--src/comp/middle/trans.rs2
-rw-r--r--src/comp/middle/ty.rs2
4 files changed, 9 insertions, 51 deletions
diff --git a/src/comp/middle/metadata.rs b/src/comp/middle/metadata.rs
index eedff3bf..ee628643 100644
--- a/src/comp/middle/metadata.rs
+++ b/src/comp/middle/metadata.rs
@@ -301,7 +301,7 @@ fn add_to_index(&EBML.writer ebml_w,
&mutable vec[tup(str, uint)] index,
&str name) {
auto full_path = path + vec(name);
- index += vec(tup(Str.connect(full_path, "."), ebml_w.writer.tell()));
+ index += vec(tup(Str.connect(full_path, "::"), ebml_w.writer.tell()));
}
fn encode_native_module_item_paths(&EBML.writer ebml_w,
diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs
index 1305ad5f..7b7d6369 100644
--- a/src/comp/middle/resolve.rs
+++ b/src/comp/middle/resolve.rs
@@ -170,6 +170,7 @@ fn resolve_imports(&env e) {
}
}
+// FIXME this should use walk (will need to add walk_arm)
fn resolve_names(&@env e, &ast.crate c) -> @ast.crate {
auto fld = @rec(fold_pat_tag = bind fold_pat_tag(e,_,_,_,_,_),
fold_expr_path = bind fold_expr_path(e,_,_,_,_),
@@ -277,54 +278,11 @@ fn resolve_import(&env e, &@ast.view_item it, &list[scope] sc) {
}
}
-// We received a path expression of the following form:
-//
-// a.b.c.d
-//
-// Somewhere along this path there might be a split from a path-expr
-// to a runtime field-expr. For example:
-//
-// 'a' could be the name of a variable in the local scope
-// and 'b.c.d' could be a field-sequence inside it.
-//
-// Or:
-//
-// 'a.b' could be a module path to a constant record, and 'c.d'
-// could be a field within it.
-//
-// Our job here is to figure out what the prefix of 'a.b.c.d' is that
-// corresponds to a static binding-name (a module or slot, with no type info)
-// and split that off as the 'primary' expr_path, with secondary expr_field
-// expressions tacked on the end.
-
fn fold_expr_path(@env e, &list[scope] sc, &span sp, &ast.path p, &ann a)
-> @ast.expr {
- auto idents = p.node.idents;
- auto n_idents = Vec.len(idents);
- assert (n_idents != 0u);
-
- auto dcur = lookup_in_scope_strict(*e, sc, sp, idents.(0), ns_value);
- auto i = 1u;
- while (i < n_idents) {
- if (!is_module(dcur)) { break; }
- dcur = lookup_in_mod_strict(*e, dcur, sp, idents.(i), ns_value,
- outside);
- i += 1u;
- }
- if (is_module(dcur)) {
- e.sess.span_err(sp, "can't refer to a module as a first-class value");
- }
-
- p = rec(node=rec(idents=Vec.slice(idents, 0u, i) with p.node) with p);
- auto ex = @fold.respan(sp, ast.expr_path(p, a));
- e.def_map.insert(ast.ann_tag(a), dcur);
- // FIXME this duplicates the ann. Is that a problem? How will we deal with
- // splitting this into path and field exprs when we don't fold?
- while (i < n_idents) {
- ex = @fold.respan(sp, ast.expr_field(ex, idents.(i), a));
- i += 1u;
- }
- ret ex;
+ auto df = lookup_path_strict(*e, sc, sp, p.node.idents, ns_value);
+ e.def_map.insert(ast.ann_tag(a), df);
+ ret @fold.respan(sp, ast.expr_path(p, a));
}
@@ -337,7 +295,7 @@ fn fold_pat_tag(@env e, &list[scope] sc, &span sp, &ast.path p,
}
case (_) {
e.sess.span_err(sp, "not a tag variant: " +
- Str.connect(p.node.idents, "."));
+ Str.connect(p.node.idents, "::"));
fail;
}
}
@@ -383,7 +341,7 @@ fn lookup_path_strict(&env e, &list[scope] sc, &span sp, vec[ident] idents,
i += 1u;
}
if (is_module(dcur)) {
- e.sess.span_err(sp, Str.connect(idents, ".") +
+ e.sess.span_err(sp, Str.connect(idents, "::") +
" is a module, not a " + ns_name(ns));
}
ret dcur;
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index d6e86045..ecdf78cf 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -5439,7 +5439,7 @@ fn load_if_immediate(&@block_ctxt cx, ValueRef v, &ty.t t) -> ValueRef {
fn trans_log(int lvl, &@block_ctxt cx, &@ast.expr e) -> result {
auto lcx = cx.fcx.lcx;
- auto modname = Str.connect(lcx.module_path, ".");
+ auto modname = Str.connect(lcx.module_path, "::");
auto global;
if (lcx.ccx.module_data.contains_key(modname)) {
global = lcx.ccx.module_data.get(modname);
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index c749b220..8c79c605 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -484,7 +484,7 @@ fn cname(&ctxt cx, &t typ) -> Option.t[str] { ret cx.ts.others.(typ).cname; }
// Stringification
fn path_to_str(&ast.path pth) -> str {
- auto result = Str.connect(pth.node.idents, ".");
+ auto result = Str.connect(pth.node.idents, "::");
if (Vec.len[@ast.ty](pth.node.types) > 0u) {
auto f = pretty.pprust.ty_to_str;
result += "[";