Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/comp/back/upcall.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import middle::trans;

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_f64;
Expand All @@ -23,6 +19,11 @@ import trans::T_taskptr;
import trans::T_tydesc;
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(
ValueRef grow_task,
ValueRef log_int,
Expand Down
6 changes: 3 additions & 3 deletions src/comp/driver/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ fn compile_input(session::session sess,
}

auto llmod =
time[llvm::ModuleRef](time_passes, "translation",
bind trans::trans_crate(sess, crate,
ty_cx, output));
time[llvm::llvm::ModuleRef](time_passes, "translation",
bind trans::trans_crate(sess, crate,
ty_cx, output));

time[()](time_passes, "LLVM passes",
bind link::write::run_passes(sess, llmod, output));
Expand Down
28 changes: 24 additions & 4 deletions src/comp/front/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,20 +438,40 @@ tag native_item_ {
}

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) {
alt (vi.node) {
case (ast::view_item_export(?id)) {
if (str::eq(i, id)) {
// even if it's nonlocal (since it's explicit)
ret true;
}
count += 1;
count += 1u;
}
case (_) { /* fall through */ }
}
}
// If there are no declared exports then everything is exported
if (count == 0) {
// If there are no declared exports then
// everything not imported is exported
if (count == 0u && !nonlocal) {
ret true;
} else {
ret false;
Expand Down
4 changes: 2 additions & 2 deletions src/comp/front/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -1008,7 +1008,7 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
* 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,
option::t[str] body) -> ast::expr_ {

Expand Down
51 changes: 26 additions & 25 deletions src/comp/middle/trans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import util::common::istr;
import util::common::new_def_hash;
import util::common::new_str_hash;
import util::common::local_rhs_span;
import util::common::span;

import lib::llvm::llvm;
import lib::llvm::builder;
Expand Down Expand Up @@ -215,7 +216,7 @@ state type fn_ctxt = rec(
hashmap[ty::t, derived_tydesc_info] derived_tydescs,

// The source span where this function comes from, for error reporting.
ast::span sp,
span sp,

// This function's enclosing local context.
@local_ctxt lcx
Expand Down Expand Up @@ -273,7 +274,7 @@ state type block_ctxt = rec(
mutable vec[cleanup] cleanups,

// 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.
@fn_ctxt fcx
Expand Down Expand Up @@ -502,7 +503,7 @@ fn T_glue_fn(&type_names tn) -> TypeRef {
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),
vec::empty[ty::arg](), ty::mk_nil(ccx.tcx), 0u);
}
Expand Down Expand Up @@ -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!
//
// 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)) {
cx.sess.span_err (sp,
"type_of() called on a type with dynamic size: " +
Expand All @@ -704,7 +705,7 @@ fn type_of(&@crate_ctxt cx, &ast::span sp, &ty::t t) -> TypeRef {
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] {
let vec[TypeRef] atys = [];
for (ty::arg arg in inputs) {
Expand Down Expand Up @@ -735,7 +736,7 @@ fn type_of_explicit_args(&@crate_ctxt cx, &ast::span sp,
// - trans_args

fn type_of_fn_full(&@crate_ctxt cx,
&ast::span sp,
&span sp,
ast::proto proto,
&option::t[TypeRef] obj_self,
&vec[ty::arg] inputs,
Expand Down Expand Up @@ -792,7 +793,7 @@ fn type_of_fn_full(&@crate_ctxt cx,
}

fn type_of_fn(&@crate_ctxt cx,
&ast::span sp,
&span sp,
ast::proto proto,
&vec[ty::arg] inputs,
&ty::t output,
Expand All @@ -801,7 +802,7 @@ fn type_of_fn(&@crate_ctxt cx,
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,
&ty::t output,
uint ty_param_count) -> TypeRef {
Expand All @@ -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));
}

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.
if (cx.lltypes.contains_key(t)) {
ret cx.lltypes.get(t);
Expand Down Expand Up @@ -939,7 +940,7 @@ fn type_of_inner(&@crate_ctxt cx, &ast::span sp, &ty::t t) -> TypeRef {
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)) {
case (ty::ty_param(_)) {
if (arg.mode == ty::mo_alias) {
Expand All @@ -960,7 +961,7 @@ fn type_of_arg(@local_ctxt cx, &ast::span sp, &ty::arg arg) -> TypeRef {
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 {
alt (ty::struct(lcx.ccx.tcx, tpt._1)) {
case (ty::ty_fn(?proto, ?inputs, ?output, _)) {
Expand Down Expand Up @@ -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.
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)) {
log_err "dynamically sized type passed to static_size_of_tag()";
fail;
Expand Down Expand Up @@ -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.
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 {
log "+++ declare_tydesc " + ty::ty_to_str(cx.ccx.tcx, t);
auto ccx = cx.ccx;
Expand Down Expand Up @@ -1905,7 +1906,7 @@ fn declare_generic_glue(&@local_ctxt cx,
ret llfn;
}

fn make_generic_glue(&@local_ctxt cx, &ast::span sp,
fn make_generic_glue(&@local_ctxt cx, &span sp,
&ty::t t,
ValueRef llfn,
&make_generic_glue_helper_fn helper,
Expand Down Expand Up @@ -3356,7 +3357,7 @@ fn node_ann_type(&@crate_ctxt cx, &ast::ann a) -> ty::t {
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));
}

Expand Down Expand Up @@ -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 {

auto r = autoderef(cx, v, t0);
Expand Down Expand Up @@ -4580,7 +4581,7 @@ fn trans_field(&@block_ctxt cx, &ast::span sp, ValueRef v, &ty::t t0,
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 {

auto lv = trans_expr(cx, base);
Expand Down Expand Up @@ -4727,7 +4728,7 @@ fn trans_cast(&@block_ctxt cx, &@ast::expr e, &ast::ann ann) -> result {
}

fn trans_bind_thunk(&@local_ctxt cx,
&ast::span sp,
&span sp,
&ty::t incoming_fty,
&ty::t outgoing_fty,
&vec[option::t[@ast::expr]] args,
Expand Down Expand Up @@ -6318,7 +6319,7 @@ fn recv_val(&@block_ctxt cx, ValueRef lhs, &@ast::expr rhs,
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,
&vec[ast::ty_param] ty_params,
&ast::obj_def_ids oid,
Expand Down Expand Up @@ -6669,7 +6670,7 @@ fn mk_standard_basic_blocks(ValueRef llfn) ->
// - new_fn_ctxt
// - 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 {

let ValueRef llretptr = llvm::LLVMGetParam(llfndecl, 0u);
Expand Down Expand Up @@ -6919,7 +6920,7 @@ fn finish_fn(&@fn_ctxt fcx, BasicBlockRef lltop) {

// trans_fn: creates an LLVM function corresponding to a source language
// 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,
&vec[ast::ty_param] ty_params, &ast::ann ann) {
auto llfndecl = cx.ccx.item_ids.get(fid);
Expand Down Expand Up @@ -7043,7 +7044,7 @@ fn trans_dtor(@local_ctxt cx,

// trans_obj: creates an LLVM function that is the object constructor for the
// 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) {
// To make a function, we have to create a function context and, inside
// that, a number of block contexts for which code is generated.
Expand Down Expand Up @@ -7368,7 +7369,7 @@ fn get_pair_fn_ty(TypeRef llpairty) -> TypeRef {
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,
str flav,
vec[ast::ty_param] ty_params,
Expand Down Expand Up @@ -7434,7 +7435,7 @@ fn native_fn_ty_param_count(&@crate_ctxt cx, &ast::def_id id) -> uint {
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 {
alt (ty::struct(cx.tcx, x)) {
case (ty::ty_native_fn(?abi, ?args, ?out)) {
Expand All @@ -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,
&ast::span sp,
&span sp,
vec[str] path,
str name,
&ast::ann ann,
Expand Down
2 changes: 1 addition & 1 deletion src/comp/middle/tstate/collect_locals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import front::ast::ident;
import middle::walk::walk_crate;
import middle::walk::walk_fn;
import middle::walk::ast_visitor;
import front::ast::span;

import aux::fn_info;
import aux::var_info;
import aux::crate_ctxt;

import util::common::new_def_hash;
import util::common::uistr;
import util::common::span;

type identifier = rec(ident name, def_id id, span sp);

Expand Down
Loading