1
Fork 0

Now imports are not re-exported unless 'export' is explicitly used.

This commit is contained in:
Paul Stansifer 2011-05-31 18:24:06 -07:00
parent 8b141d5d37
commit 9f5dddf08c
21 changed files with 148 additions and 227 deletions

View file

@ -1,10 +1,6 @@
import middle::trans; import middle::trans;
import trans::decl_cdecl_fn; import trans::decl_cdecl_fn;
import trans::type_names;
import trans::ModuleRef;
import trans::TypeRef;
import trans::ValueRef;
import trans::T_f32; import trans::T_f32;
import trans::T_f64; import trans::T_f64;
@ -23,6 +19,11 @@ import trans::T_taskptr;
import trans::T_tydesc; import trans::T_tydesc;
import trans::T_void; import trans::T_void;
import lib::llvm::type_names;
import lib::llvm::llvm::ModuleRef;
import lib::llvm::llvm::ValueRef;
import lib::llvm::llvm::TypeRef;
type upcalls = rec( type upcalls = rec(
ValueRef grow_task, ValueRef grow_task,
ValueRef log_int, ValueRef log_int,

View file

@ -103,7 +103,7 @@ fn compile_input(session::session sess,
} }
auto llmod = auto llmod =
time[llvm::ModuleRef](time_passes, "translation", time[llvm::llvm::ModuleRef](time_passes, "translation",
bind trans::trans_crate(sess, crate, bind trans::trans_crate(sess, crate,
ty_cx, output)); ty_cx, output));

View file

@ -438,20 +438,40 @@ tag native_item_ {
} }
fn is_exported(ident i, _mod m) -> bool { fn is_exported(ident i, _mod m) -> bool {
auto count = 0; auto nonlocal = true;
for (@ast::item it in m.items) {
if (item_ident(it) == i) {
nonlocal = false;
}
alt (it.node) {
case (item_tag(_, ?variants, _, _, _)) {
for (variant v in variants) {
if (v.node.name == i) {
nonlocal = false;
}
}
}
case (_) {}
}
}
auto count = 0u;
for (@ast::view_item vi in m.view_items) { for (@ast::view_item vi in m.view_items) {
alt (vi.node) { alt (vi.node) {
case (ast::view_item_export(?id)) { case (ast::view_item_export(?id)) {
if (str::eq(i, id)) { if (str::eq(i, id)) {
// even if it's nonlocal (since it's explicit)
ret true; ret true;
} }
count += 1; count += 1u;
} }
case (_) { /* fall through */ } case (_) { /* fall through */ }
} }
} }
// If there are no declared exports then everything is exported // If there are no declared exports then
if (count == 0) { // everything not imported is exported
if (count == 0u && !nonlocal) {
ret true; ret true;
} else { } else {
ret false; ret false;

View file

@ -231,7 +231,7 @@ fn expect(&parser p, token::token t) {
} }
} }
fn spanned[T](uint lo, uint hi, &T node) -> ast::spanned[T] { fn spanned[T](uint lo, uint hi, &T node) -> common::spanned[T] {
ret rec(node=node, span=rec(lo=lo, hi=hi)); ret rec(node=node, span=rec(lo=lo, hi=hi));
} }
@ -1008,7 +1008,7 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
* loading rust crates to process extensions. * loading rust crates to process extensions.
*/ */
fn expand_syntax_ext(&parser p, ast::span sp, fn expand_syntax_ext(&parser p, common::span sp,
&ast::path path, vec[@ast::expr] args, &ast::path path, vec[@ast::expr] args,
option::t[str] body) -> ast::expr_ { option::t[str] body) -> ast::expr_ {

View file

@ -26,6 +26,7 @@ import util::common::istr;
import util::common::new_def_hash; import util::common::new_def_hash;
import util::common::new_str_hash; import util::common::new_str_hash;
import util::common::local_rhs_span; import util::common::local_rhs_span;
import util::common::span;
import lib::llvm::llvm; import lib::llvm::llvm;
import lib::llvm::builder; import lib::llvm::builder;
@ -215,7 +216,7 @@ state type fn_ctxt = rec(
hashmap[ty::t, derived_tydesc_info] derived_tydescs, hashmap[ty::t, derived_tydesc_info] derived_tydescs,
// The source span where this function comes from, for error reporting. // The source span where this function comes from, for error reporting.
ast::span sp, span sp,
// This function's enclosing local context. // This function's enclosing local context.
@local_ctxt lcx @local_ctxt lcx
@ -273,7 +274,7 @@ state type block_ctxt = rec(
mutable vec[cleanup] cleanups, mutable vec[cleanup] cleanups,
// The source span where this block comes from, for error reporting. // The source span where this block comes from, for error reporting.
ast::span sp, span sp,
// The function context for the function to which this block is attached. // The function context for the function to which this block is attached.
@fn_ctxt fcx @fn_ctxt fcx
@ -502,7 +503,7 @@ fn T_glue_fn(&type_names tn) -> TypeRef {
ret t; ret t;
} }
fn T_dtor(&@crate_ctxt ccx, &ast::span sp, TypeRef llself_ty) -> TypeRef { fn T_dtor(&@crate_ctxt ccx, &span sp, TypeRef llself_ty) -> TypeRef {
ret type_of_fn_full(ccx, sp, ast::proto_fn, some[TypeRef](llself_ty), ret type_of_fn_full(ccx, sp, ast::proto_fn, some[TypeRef](llself_ty),
vec::empty[ty::arg](), ty::mk_nil(ccx.tcx), 0u); vec::empty[ty::arg](), ty::mk_nil(ccx.tcx), 0u);
} }
@ -693,7 +694,7 @@ fn T_opaque_chan_ptr() -> TypeRef { ret T_ptr(T_i8()); }
// return value was always meaningless in that case anyhow). Beware! // return value was always meaningless in that case anyhow). Beware!
// //
// TODO: Enforce via a predicate. // TODO: Enforce via a predicate.
fn type_of(&@crate_ctxt cx, &ast::span sp, &ty::t t) -> TypeRef { fn type_of(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef {
if (ty::type_has_dynamic_size(cx.tcx, t)) { if (ty::type_has_dynamic_size(cx.tcx, t)) {
cx.sess.span_err (sp, cx.sess.span_err (sp,
"type_of() called on a type with dynamic size: " + "type_of() called on a type with dynamic size: " +
@ -704,7 +705,7 @@ fn type_of(&@crate_ctxt cx, &ast::span sp, &ty::t t) -> TypeRef {
ret type_of_inner(cx, sp, t); ret type_of_inner(cx, sp, t);
} }
fn type_of_explicit_args(&@crate_ctxt cx, &ast::span sp, fn type_of_explicit_args(&@crate_ctxt cx, &span sp,
&vec[ty::arg] inputs) -> vec[TypeRef] { &vec[ty::arg] inputs) -> vec[TypeRef] {
let vec[TypeRef] atys = []; let vec[TypeRef] atys = [];
for (ty::arg arg in inputs) { for (ty::arg arg in inputs) {
@ -735,7 +736,7 @@ fn type_of_explicit_args(&@crate_ctxt cx, &ast::span sp,
// - trans_args // - trans_args
fn type_of_fn_full(&@crate_ctxt cx, fn type_of_fn_full(&@crate_ctxt cx,
&ast::span sp, &span sp,
ast::proto proto, ast::proto proto,
&option::t[TypeRef] obj_self, &option::t[TypeRef] obj_self,
&vec[ty::arg] inputs, &vec[ty::arg] inputs,
@ -792,7 +793,7 @@ fn type_of_fn_full(&@crate_ctxt cx,
} }
fn type_of_fn(&@crate_ctxt cx, fn type_of_fn(&@crate_ctxt cx,
&ast::span sp, &span sp,
ast::proto proto, ast::proto proto,
&vec[ty::arg] inputs, &vec[ty::arg] inputs,
&ty::t output, &ty::t output,
@ -801,7 +802,7 @@ fn type_of_fn(&@crate_ctxt cx,
ty_param_count); ty_param_count);
} }
fn type_of_native_fn(&@crate_ctxt cx, &ast::span sp, ast::native_abi abi, fn type_of_native_fn(&@crate_ctxt cx, &span sp, ast::native_abi abi,
&vec[ty::arg] inputs, &vec[ty::arg] inputs,
&ty::t output, &ty::t output,
uint ty_param_count) -> TypeRef { uint ty_param_count) -> TypeRef {
@ -819,7 +820,7 @@ fn type_of_native_fn(&@crate_ctxt cx, &ast::span sp, ast::native_abi abi,
ret T_fn(atys, type_of_inner(cx, sp, output)); ret T_fn(atys, type_of_inner(cx, sp, output));
} }
fn type_of_inner(&@crate_ctxt cx, &ast::span sp, &ty::t t) -> TypeRef { fn type_of_inner(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef {
// Check the cache. // Check the cache.
if (cx.lltypes.contains_key(t)) { if (cx.lltypes.contains_key(t)) {
ret cx.lltypes.get(t); ret cx.lltypes.get(t);
@ -939,7 +940,7 @@ fn type_of_inner(&@crate_ctxt cx, &ast::span sp, &ty::t t) -> TypeRef {
ret llty; ret llty;
} }
fn type_of_arg(@local_ctxt cx, &ast::span sp, &ty::arg arg) -> TypeRef { fn type_of_arg(@local_ctxt cx, &span sp, &ty::arg arg) -> TypeRef {
alt (ty::struct(cx.ccx.tcx, arg.ty)) { alt (ty::struct(cx.ccx.tcx, arg.ty)) {
case (ty::ty_param(_)) { case (ty::ty_param(_)) {
if (arg.mode == ty::mo_alias) { if (arg.mode == ty::mo_alias) {
@ -960,7 +961,7 @@ fn type_of_arg(@local_ctxt cx, &ast::span sp, &ty::arg arg) -> TypeRef {
ret typ; ret typ;
} }
fn type_of_ty_param_count_and_ty(@local_ctxt lcx, &ast::span sp, fn type_of_ty_param_count_and_ty(@local_ctxt lcx, &span sp,
&ty::ty_param_count_and_ty tpt) -> TypeRef { &ty::ty_param_count_and_ty tpt) -> TypeRef {
alt (ty::struct(lcx.ccx.tcx, tpt._1)) { alt (ty::struct(lcx.ccx.tcx, tpt._1)) {
case (ty::ty_fn(?proto, ?inputs, ?output, _)) { case (ty::ty_fn(?proto, ?inputs, ?output, _)) {
@ -1284,7 +1285,7 @@ fn simplify_type(&@crate_ctxt ccx, &ty::t typ) -> ty::t {
} }
// Computes the size of the data part of a non-dynamically-sized tag. // Computes the size of the data part of a non-dynamically-sized tag.
fn static_size_of_tag(&@crate_ctxt cx, &ast::span sp, &ty::t t) -> uint { fn static_size_of_tag(&@crate_ctxt cx, &span sp, &ty::t t) -> uint {
if (ty::type_has_dynamic_size(cx.tcx, t)) { if (ty::type_has_dynamic_size(cx.tcx, t)) {
log_err "dynamically sized type passed to static_size_of_tag()"; log_err "dynamically sized type passed to static_size_of_tag()";
fail; fail;
@ -1841,7 +1842,7 @@ fn set_glue_inlining(&@local_ctxt cx, ValueRef f, &ty::t t) {
// Generates the declaration for (but doesn't emit) a type descriptor. // Generates the declaration for (but doesn't emit) a type descriptor.
fn declare_tydesc(&@local_ctxt cx, &ast::span sp, &ty::t t, fn declare_tydesc(&@local_ctxt cx, &span sp, &ty::t t,
vec[uint] ty_params) -> @tydesc_info { vec[uint] ty_params) -> @tydesc_info {
log "+++ declare_tydesc " + ty::ty_to_str(cx.ccx.tcx, t); log "+++ declare_tydesc " + ty::ty_to_str(cx.ccx.tcx, t);
auto ccx = cx.ccx; auto ccx = cx.ccx;
@ -1905,7 +1906,7 @@ fn declare_generic_glue(&@local_ctxt cx,
ret llfn; ret llfn;
} }
fn make_generic_glue(&@local_ctxt cx, &ast::span sp, fn make_generic_glue(&@local_ctxt cx, &span sp,
&ty::t t, &ty::t t,
ValueRef llfn, ValueRef llfn,
&make_generic_glue_helper_fn helper, &make_generic_glue_helper_fn helper,
@ -3356,7 +3357,7 @@ fn node_ann_type(&@crate_ctxt cx, &ast::ann a) -> ty::t {
ret ty::ann_to_monotype(cx.tcx, a); ret ty::ann_to_monotype(cx.tcx, a);
} }
fn node_type(&@crate_ctxt cx, &ast::span sp, &ast::ann a) -> TypeRef { fn node_type(&@crate_ctxt cx, &span sp, &ast::ann a) -> TypeRef {
ret type_of(cx, sp, node_ann_type(cx, a)); ret type_of(cx, sp, node_ann_type(cx, a));
} }
@ -4539,7 +4540,7 @@ fn trans_path(&@block_ctxt cx, &ast::path p, &ast::ann ann) -> lval_result {
} }
} }
fn trans_field(&@block_ctxt cx, &ast::span sp, ValueRef v, &ty::t t0, fn trans_field(&@block_ctxt cx, &span sp, ValueRef v, &ty::t t0,
&ast::ident field, &ast::ann ann) -> lval_result { &ast::ident field, &ast::ann ann) -> lval_result {
auto r = autoderef(cx, v, t0); auto r = autoderef(cx, v, t0);
@ -4580,7 +4581,7 @@ fn trans_field(&@block_ctxt cx, &ast::span sp, ValueRef v, &ty::t t0,
fail; fail;
} }
fn trans_index(&@block_ctxt cx, &ast::span sp, &@ast::expr base, fn trans_index(&@block_ctxt cx, &span sp, &@ast::expr base,
&@ast::expr idx, &ast::ann ann) -> lval_result { &@ast::expr idx, &ast::ann ann) -> lval_result {
auto lv = trans_expr(cx, base); auto lv = trans_expr(cx, base);
@ -4727,7 +4728,7 @@ fn trans_cast(&@block_ctxt cx, &@ast::expr e, &ast::ann ann) -> result {
} }
fn trans_bind_thunk(&@local_ctxt cx, fn trans_bind_thunk(&@local_ctxt cx,
&ast::span sp, &span sp,
&ty::t incoming_fty, &ty::t incoming_fty,
&ty::t outgoing_fty, &ty::t outgoing_fty,
&vec[option::t[@ast::expr]] args, &vec[option::t[@ast::expr]] args,
@ -6318,7 +6319,7 @@ fn recv_val(&@block_ctxt cx, ValueRef lhs, &@ast::expr rhs,
wrapped inner object. wrapped inner object.
*/ */
fn trans_anon_obj(&@block_ctxt cx, &ast::span sp, fn trans_anon_obj(&@block_ctxt cx, &span sp,
&ast::anon_obj anon_obj, &ast::anon_obj anon_obj,
&vec[ast::ty_param] ty_params, &vec[ast::ty_param] ty_params,
&ast::obj_def_ids oid, &ast::obj_def_ids oid,
@ -6669,7 +6670,7 @@ fn mk_standard_basic_blocks(ValueRef llfn) ->
// - new_fn_ctxt // - new_fn_ctxt
// - trans_args // - trans_args
fn new_fn_ctxt(@local_ctxt cx, &ast::span sp, fn new_fn_ctxt(@local_ctxt cx, &span sp,
ValueRef llfndecl) -> @fn_ctxt { ValueRef llfndecl) -> @fn_ctxt {
let ValueRef llretptr = llvm::LLVMGetParam(llfndecl, 0u); let ValueRef llretptr = llvm::LLVMGetParam(llfndecl, 0u);
@ -6919,7 +6920,7 @@ fn finish_fn(&@fn_ctxt fcx, BasicBlockRef lltop) {
// trans_fn: creates an LLVM function corresponding to a source language // trans_fn: creates an LLVM function corresponding to a source language
// function. // function.
fn trans_fn(@local_ctxt cx, &ast::span sp, &ast::_fn f, ast::def_id fid, fn trans_fn(@local_ctxt cx, &span sp, &ast::_fn f, ast::def_id fid,
option::t[tup(TypeRef, ty::t)] ty_self, option::t[tup(TypeRef, ty::t)] ty_self,
&vec[ast::ty_param] ty_params, &ast::ann ann) { &vec[ast::ty_param] ty_params, &ast::ann ann) {
auto llfndecl = cx.ccx.item_ids.get(fid); auto llfndecl = cx.ccx.item_ids.get(fid);
@ -7043,7 +7044,7 @@ fn trans_dtor(@local_ctxt cx,
// trans_obj: creates an LLVM function that is the object constructor for the // trans_obj: creates an LLVM function that is the object constructor for the
// object being translated. // object being translated.
fn trans_obj(@local_ctxt cx, &ast::span sp, &ast::_obj ob, ast::def_id oid, fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::def_id oid,
&vec[ast::ty_param] ty_params, &ast::ann ann) { &vec[ast::ty_param] ty_params, &ast::ann ann) {
// To make a function, we have to create a function context and, inside // To make a function, we have to create a function context and, inside
// that, a number of block contexts for which code is generated. // that, a number of block contexts for which code is generated.
@ -7368,7 +7369,7 @@ fn get_pair_fn_ty(TypeRef llpairty) -> TypeRef {
ret llvm::LLVMGetElementType(pair_tys.(0)); ret llvm::LLVMGetElementType(pair_tys.(0));
} }
fn decl_fn_and_pair(&@crate_ctxt ccx, &ast::span sp, fn decl_fn_and_pair(&@crate_ctxt ccx, &span sp,
vec[str] path, vec[str] path,
str flav, str flav,
vec[ast::ty_param] ty_params, vec[ast::ty_param] ty_params,
@ -7434,7 +7435,7 @@ fn native_fn_ty_param_count(&@crate_ctxt cx, &ast::def_id id) -> uint {
ret count; ret count;
} }
fn native_fn_wrapper_type(&@crate_ctxt cx, &ast::span sp, uint ty_param_count, fn native_fn_wrapper_type(&@crate_ctxt cx, &span sp, uint ty_param_count,
ty::t x) -> TypeRef { ty::t x) -> TypeRef {
alt (ty::struct(cx.tcx, x)) { alt (ty::struct(cx.tcx, x)) {
case (ty::ty_native_fn(?abi, ?args, ?out)) { case (ty::ty_native_fn(?abi, ?args, ?out)) {
@ -7445,7 +7446,7 @@ fn native_fn_wrapper_type(&@crate_ctxt cx, &ast::span sp, uint ty_param_count,
} }
fn decl_native_fn_and_pair(&@crate_ctxt ccx, fn decl_native_fn_and_pair(&@crate_ctxt ccx,
&ast::span sp, &span sp,
vec[str] path, vec[str] path,
str name, str name,
&ast::ann ann, &ast::ann ann,

View file

@ -23,7 +23,6 @@ import front::ast::ident;
import middle::walk::walk_crate; import middle::walk::walk_crate;
import middle::walk::walk_fn; import middle::walk::walk_fn;
import middle::walk::ast_visitor; import middle::walk::ast_visitor;
import front::ast::span;
import aux::fn_info; import aux::fn_info;
import aux::var_info; import aux::var_info;
@ -31,6 +30,7 @@ import aux::crate_ctxt;
import util::common::new_def_hash; import util::common::new_def_hash;
import util::common::uistr; import util::common::uistr;
import util::common::span;
type identifier = rec(ident name, def_id id, span sp); type identifier = rec(ident name, def_id id, span sp);

View file

@ -48,98 +48,7 @@ import bitvectors::declare_var;
import bitvectors::bit_num; import bitvectors::bit_num;
import bitvectors::gen; import bitvectors::gen;
import front::ast::_mod; import front::ast::*;
import front::ast;
import front::ast::method;
import front::ast::ann;
import front::ast::ty;
import front::ast::mutability;
import front::ast::item_const;
import front::ast::item_mod;
import front::ast::item_ty;
import front::ast::item_tag;
import front::ast::item_native_mod;
import front::ast::obj_field;
import front::ast::stmt;
import front::ast::stmt_;
import front::ast::ident;
import front::ast::def_id;
import front::ast::expr;
import front::ast::path;
import front::ast::crate_directive;
import front::ast::fn_decl;
import front::ast::native_mod;
import front::ast::variant;
import front::ast::ty_param;
import front::ast::proto;
import front::ast::pat;
import front::ast::binop;
import front::ast::unop;
import front::ast::def;
import front::ast::lit;
import front::ast::init_op;
import front::ast::controlflow;
import front::ast::noreturn;
import front::ast::return;
import front::ast::_fn;
import front::ast::_obj;
import front::ast::crate;
import front::ast::item_fn;
import front::ast::item_obj;
import front::ast::def_local;
import front::ast::def_fn;
import front::ast::item;
import front::ast::elt;
import front::ast::field;
import front::ast::decl;
import front::ast::decl_local;
import front::ast::decl_item;
import front::ast::initializer;
import front::ast::local;
import front::ast::arm;
import front::ast::expr_call;
import front::ast::expr_vec;
import front::ast::expr_tup;
import front::ast::expr_path;
import front::ast::expr_field;
import front::ast::expr_index;
import front::ast::expr_log;
import front::ast::expr_block;
import front::ast::expr_rec;
import front::ast::expr_if;
import front::ast::expr_binary;
import front::ast::expr_unary;
import front::ast::expr_move;
import front::ast::expr_assign;
import front::ast::expr_assign_op;
import front::ast::expr_while;
import front::ast::expr_do_while;
import front::ast::expr_alt;
import front::ast::expr_lit;
import front::ast::expr_ret;
import front::ast::expr_self_method;
import front::ast::expr_bind;
import front::ast::expr_spawn;
import front::ast::expr_ext;
import front::ast::expr_fail;
import front::ast::expr_break;
import front::ast::expr_cont;
import front::ast::expr_send;
import front::ast::expr_recv;
import front::ast::expr_put;
import front::ast::expr_port;
import front::ast::expr_chan;
import front::ast::expr_be;
import front::ast::expr_check;
import front::ast::expr_assert;
import front::ast::expr_cast;
import front::ast::expr_for;
import front::ast::expr_for_each;
import front::ast::expr_anon_obj;
import front::ast::stmt_decl;
import front::ast::stmt_expr;
import front::ast::block;
import front::ast::block_;
import middle::ty::expr_ann; import middle::ty::expr_ann;
@ -155,8 +64,7 @@ import util::common::log_stmt;
import util::common::log_expr_err; import util::common::log_expr_err;
import util::common::log_block_err; import util::common::log_block_err;
import util::common::log_block; import util::common::log_block;
import util::common::span;
import front::ast::span;
fn find_pre_post_mod(&_mod m) -> _mod { fn find_pre_post_mod(&_mod m) -> _mod {
log("implement find_pre_post_mod!"); log("implement find_pre_post_mod!");

View file

@ -59,97 +59,7 @@ import bitvectors::gen_poststate;
import bitvectors::kill_poststate; import bitvectors::kill_poststate;
import front::ast; import front::ast;
import front::ast::_fn; import front::ast::*;
import front::ast::method;
import front::ast::ty;
import front::ast::mutability;
import front::ast::item;
import front::ast::obj_field;
import front::ast::stmt;
import front::ast::stmt_;
import front::ast::def_id;
import front::ast::ann;
import front::ast::expr;
import front::ast::path;
import front::ast::crate_directive;
import front::ast::fn_decl;
import front::ast::_obj;
import front::ast::native_mod;
import front::ast::variant;
import front::ast::ty_param;
import front::ast::proto;
import front::ast::pat;
import front::ast::binop;
import front::ast::unop;
import front::ast::def;
import front::ast::lit;
import front::ast::init_op;
import front::ast::controlflow;
import front::ast::return;
import front::ast::noreturn;
import front::ast::_mod;
import front::ast::crate;
import front::ast::item_fn;
import front::ast::item_mod;
import front::ast::item_ty;
import front::ast::item_tag;
import front::ast::item_native_mod;
import front::ast::item_obj;
import front::ast::item_const;
import front::ast::def_local;
import front::ast::def_fn;
import front::ast::ident;
import front::ast::elt;
import front::ast::field;
import front::ast::decl;
import front::ast::decl_local;
import front::ast::decl_item;
import front::ast::initializer;
import front::ast::local;
import front::ast::arm;
import front::ast::expr_call;
import front::ast::expr_vec;
import front::ast::expr_tup;
import front::ast::expr_path;
import front::ast::expr_field;
import front::ast::expr_index;
import front::ast::expr_log;
import front::ast::expr_block;
import front::ast::expr_rec;
import front::ast::expr_if;
import front::ast::expr_binary;
import front::ast::expr_unary;
import front::ast::expr_move;
import front::ast::expr_assign;
import front::ast::expr_assign_op;
import front::ast::expr_while;
import front::ast::expr_do_while;
import front::ast::expr_alt;
import front::ast::expr_lit;
import front::ast::expr_ret;
import front::ast::expr_self_method;
import front::ast::expr_bind;
import front::ast::expr_spawn;
import front::ast::expr_ext;
import front::ast::expr_fail;
import front::ast::expr_break;
import front::ast::expr_cont;
import front::ast::expr_send;
import front::ast::expr_recv;
import front::ast::expr_put;
import front::ast::expr_port;
import front::ast::expr_chan;
import front::ast::expr_be;
import front::ast::expr_check;
import front::ast::expr_assert;
import front::ast::expr_cast;
import front::ast::expr_for;
import front::ast::expr_for_each;
import front::ast::expr_anon_obj;
import front::ast::stmt_decl;
import front::ast::stmt_expr;
import front::ast::block;
import front::ast::block_;
import middle::ty::expr_ann; import middle::ty::expr_ann;
import middle::ty::expr_ty; import middle::ty::expr_ty;

View file

@ -115,7 +115,7 @@ fn substitute_ty_params(&@crate_ctxt ccx,
// Returns the type parameter count and the type for the given definition. // Returns the type parameter count and the type for the given definition.
fn ty_param_count_and_ty_for_def(&@fn_ctxt fcx, &ast::span sp, &ast::def defn) fn ty_param_count_and_ty_for_def(&@fn_ctxt fcx, &span sp, &ast::def defn)
-> ty_param_count_and_ty { -> ty_param_count_and_ty {
alt (defn) { alt (defn) {
case (ast::def_arg(?id)) { case (ast::def_arg(?id)) {

View file

@ -4,7 +4,7 @@ import std::option;
import std::option::some; import std::option::some;
import std::option::none; import std::option::none;
import front::ast::span; import util::common::span;
// FIXME: Should visit patterns as well. // FIXME: Should visit patterns as well.
type ast_visitor = type ast_visitor =

View file

@ -220,7 +220,7 @@ fn has_nonlocal_exits(&ast::block b) -> bool {
ret *has_exits; ret *has_exits;
} }
fn local_rhs_span(&@ast::local l, &ast::span def) -> ast::span { fn local_rhs_span(&@ast::local l, &span def) -> span {
alt (l.init) { alt (l.init) {
case (some(?i)) { ret i.expr.span; } case (some(?i)) { ret i.expr.span; }
case (_) { ret def; } case (_) { ret def; }

View file

@ -2,6 +2,51 @@ import rustrt::sbuf;
import vec::rustrt::vbuf; import vec::rustrt::vbuf;
export sbuf;
export rustrt;
export eq;
export lteq;
export hash;
export is_utf8;
export is_ascii;
export alloc;
export byte_len;
export buf;
export bytes;
export from_bytes;
export unsafe_from_bytes;
export unsafe_from_byte;
export str_from_cstr;
export str_from_buf;
export push_utf8_bytes;
export from_char;
export from_chars;
export utf8_char_width;
export char_range_at;
export char_at;
export char_len;
export to_chars;
export push_char;
export pop_char;
export shift_char;
export unshift_char;
export refcount;
export index;
export rindex;
export find;
export starts_with;
export ends_with;
export substr;
export slice;
export shift_byte;
export pop_byte;
export push_byte;
export unshift_byte;
export split;
export concat;
export connect;
export to_upper;
native "rust" mod rustrt { native "rust" mod rustrt {
type sbuf; type sbuf;
fn str_buf(str s) -> sbuf; fn str_buf(str s) -> sbuf;

View file

@ -2,6 +2,9 @@
// error-pattern: unresolved name // error-pattern: unresolved name
mod circ1 { mod circ1 {
import circ1::*; import circ1::*;
export f1;
export f2;
export common;
fn f1() { fn f1() {
log "f1"; log "f1";
} }
@ -12,6 +15,9 @@ mod circ1 {
mod circ2 { mod circ2 {
import circ2::*; import circ2::*;
export f1;
export f2;
export common;
fn f2() { fn f2() {
log "f2"; log "f2";
} }

View file

@ -2,10 +2,12 @@
mod a { mod a {
import b::x; import b::x;
export x;
} }
mod b { mod b {
import a::x; import a::x;
export x;
fn main() { fn main() {
auto y = x; auto y = x;

View file

@ -4,6 +4,7 @@ import y::x;
mod y { mod y {
import x; import x;
export x;
} }
fn main() { fn main() {

View file

@ -0,0 +1,15 @@
// error-pattern:unresolved import: foo
mod m1 {
fn foo() { log "foo"; }
}
mod m2 {
import m1::foo;
}
mod m3 {
import m2::foo;
}
fn main () {}

View file

@ -3,15 +3,18 @@ import a1::b1::word_traveler;
mod a1 { // mod a1 { //
mod b1 { // mod b1 { //
import a2::b1::*; // <-\ import a2::b1::*; // <-\
export word_traveler; // |
} // | } // |
mod b2 { // | mod b2 { // |
import a2::b2::*; // <-\ -\ | import a2::b2::*; // <-\ -\ |
export word_traveler; // | | |
} // | | | } // | | |
} // | | | } // | | |
// | | | // | | |
mod a2 { // | | | mod a2 { // | | |
native mod b1 { // | | | native mod b1 { // | | |
import a1::b2::*; // | <-/ -/ import a1::b2::*; // | <-/ -/
export word_traveler; // |
} // | } // |
mod b2 { // | mod b2 { // |
fn word_traveler() { // | fn word_traveler() { // |

View file

@ -3,6 +3,9 @@ import test2::*;
mod circ1 { mod circ1 {
import circ1::*; import circ1::*;
export f1;
export f2;
export common;
fn f1() -> uint { fn f1() -> uint {
ret 1u ret 1u
} }
@ -13,6 +16,9 @@ mod circ1 {
mod circ2 { mod circ2 {
import circ2::*; import circ2::*;
export f1;
export f2;
export common;
fn f2() -> uint { fn f2() -> uint {
ret 2u; ret 2u;
} }

View file

@ -1,6 +1,7 @@
import foo::bar; import foo::bar;
mod foo { mod foo {
import zed::bar; import zed::bar;
export bar;
mod zed { mod zed {
fn bar() { fn bar() {
log "foo"; log "foo";

View file

@ -9,6 +9,7 @@ mod foo {
} }
mod bar { mod bar {
import zed::baz; import zed::baz;
export baz;
} }
fn main(vec[str] args) { fn main(vec[str] args) {
baz(); baz();

View file

@ -9,6 +9,7 @@ mod foo {
} }
mod bar { mod bar {
import zed::baz; import zed::baz;
export baz;
mod foo { mod foo {
mod zed { mod zed {
} }