Convert misc compiler bits to istrs. Issue #855
This commit is contained in:
parent
cffd9b8044
commit
5f57a508af
@ -47,21 +47,21 @@ fn default_configuration(sess: session::session,
|
|||||||
ast::crate_cfg {
|
ast::crate_cfg {
|
||||||
let libc =
|
let libc =
|
||||||
alt sess.get_targ_cfg().os {
|
alt sess.get_targ_cfg().os {
|
||||||
session::os_win32. { "msvcrt.dll" }
|
session::os_win32. { ~"msvcrt.dll" }
|
||||||
session::os_macos. { "libc.dylib" }
|
session::os_macos. { ~"libc.dylib" }
|
||||||
session::os_linux. { "libc.so.6" }
|
session::os_linux. { ~"libc.so.6" }
|
||||||
_ { "libc.so" }
|
_ { ~"libc.so" }
|
||||||
};
|
};
|
||||||
|
|
||||||
let mk = attr::mk_name_value_item_str;
|
let mk = attr::mk_name_value_item_str;
|
||||||
|
|
||||||
ret [ // Target bindings.
|
ret [ // Target bindings.
|
||||||
mk(~"target_os", istr::to_estr(std::os::target_os())),
|
mk(~"target_os", std::os::target_os()),
|
||||||
mk(~"target_arch", "x86"),
|
mk(~"target_arch", ~"x86"),
|
||||||
mk(~"target_libc", libc),
|
mk(~"target_libc", libc),
|
||||||
// Build bindings.
|
// Build bindings.
|
||||||
mk(~"build_compiler", istr::to_estr(argv0)),
|
mk(~"build_compiler", argv0),
|
||||||
mk(~"build_input", istr::to_estr(input))];
|
mk(~"build_input", input)];
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_configuration(sess: session::session, argv0: &istr, input: &istr) ->
|
fn build_configuration(sess: session::session, argv0: &istr, input: &istr) ->
|
||||||
|
@ -197,8 +197,9 @@ fn span<@T>(item: &T) -> ast::spanned<T> {
|
|||||||
ret {node: item, span: ast_util::dummy_sp()};
|
ret {node: item, span: ast_util::dummy_sp()};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mk_name_value_item_str(name: ast::ident, value: str) -> @ast::meta_item {
|
fn mk_name_value_item_str(name: ast::ident,
|
||||||
let value_lit = span(ast::lit_str(istr::from_estr(value), ast::sk_rc));
|
value: &istr) -> @ast::meta_item {
|
||||||
|
let value_lit = span(ast::lit_str(value, ast::sk_rc));
|
||||||
ret mk_name_value_item(name, value_lit);
|
ret mk_name_value_item(name, value_lit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ fn get_meta_items(md: &ebml::doc) -> [@ast::meta_item] {
|
|||||||
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
|
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
|
||||||
let vd = ebml::get_doc(meta_item_doc, tag_meta_item_value);
|
let vd = ebml::get_doc(meta_item_doc, tag_meta_item_value);
|
||||||
let n = istr::unsafe_from_bytes(ebml::doc_data(nd));
|
let n = istr::unsafe_from_bytes(ebml::doc_data(nd));
|
||||||
let v = str::unsafe_from_bytes(ebml::doc_data(vd));
|
let v = istr::unsafe_from_bytes(ebml::doc_data(vd));
|
||||||
// FIXME (#611): Should be able to decode meta_name_value variants,
|
// FIXME (#611): Should be able to decode meta_name_value variants,
|
||||||
// but currently they can't be encoded
|
// but currently they can't be encoded
|
||||||
items += [attr::mk_name_value_item_str(n, v)];
|
items += [attr::mk_name_value_item_str(n, v)];
|
||||||
|
@ -511,10 +511,10 @@ fn synthesize_crate_attrs(ecx: &@encode_ctxt, crate: &@crate) -> [attribute] {
|
|||||||
|
|
||||||
let name_item =
|
let name_item =
|
||||||
attr::mk_name_value_item_str(
|
attr::mk_name_value_item_str(
|
||||||
~"name", istr::to_estr(ecx.ccx.link_meta.name));
|
~"name", ecx.ccx.link_meta.name);
|
||||||
let vers_item =
|
let vers_item =
|
||||||
attr::mk_name_value_item_str(
|
attr::mk_name_value_item_str(
|
||||||
~"vers", istr::to_estr(ecx.ccx.link_meta.vers));
|
~"vers", ecx.ccx.link_meta.vers);
|
||||||
|
|
||||||
let other_items =
|
let other_items =
|
||||||
{
|
{
|
||||||
|
@ -112,44 +112,45 @@ fn type_and_kind(tcx: &ty::ctxt, e: &@ast::expr) ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn need_expr_kind(tcx: &ty::ctxt, e: &@ast::expr, k_need: ast::kind,
|
fn need_expr_kind(tcx: &ty::ctxt, e: &@ast::expr, k_need: ast::kind,
|
||||||
descr: &str) {
|
descr: &istr) {
|
||||||
let tk = type_and_kind(tcx, e);
|
let tk = type_and_kind(tcx, e);
|
||||||
log #fmt["for %s: want %s type, got %s type %s", descr,
|
log #fmt["for %s: want %s type, got %s type %s", istr::to_estr(descr),
|
||||||
kind_to_str(k_need), kind_to_str(tk.kind),
|
kind_to_str(k_need), kind_to_str(tk.kind),
|
||||||
istr::to_estr(util::ppaux::ty_to_str(tcx, tk.ty))];
|
istr::to_estr(util::ppaux::ty_to_str(tcx, tk.ty))];
|
||||||
|
|
||||||
if !kind_lteq(k_need, tk.kind) {
|
if !kind_lteq(k_need, tk.kind) {
|
||||||
let s =
|
let s =
|
||||||
#fmt["mismatched kinds for %s: needed %s type, got %s type %s",
|
#fmt["mismatched kinds for %s: needed %s type, got %s type %s",
|
||||||
descr, kind_to_str(k_need), kind_to_str(tk.kind),
|
istr::to_estr(descr), kind_to_str(k_need),
|
||||||
|
kind_to_str(tk.kind),
|
||||||
istr::to_estr(util::ppaux::ty_to_str(tcx, tk.ty))];
|
istr::to_estr(util::ppaux::ty_to_str(tcx, tk.ty))];
|
||||||
tcx.sess.span_err(e.span, istr::from_estr(s));
|
tcx.sess.span_err(e.span, istr::from_estr(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn need_shared_lhs_rhs(tcx: &ty::ctxt, a: &@ast::expr, b: &@ast::expr,
|
fn need_shared_lhs_rhs(tcx: &ty::ctxt, a: &@ast::expr, b: &@ast::expr,
|
||||||
op: &str) {
|
op: &istr) {
|
||||||
need_expr_kind(tcx, a, ast::kind_shared, op + " lhs");
|
need_expr_kind(tcx, a, ast::kind_shared, op + ~" lhs");
|
||||||
need_expr_kind(tcx, b, ast::kind_shared, op + " rhs");
|
need_expr_kind(tcx, b, ast::kind_shared, op + ~" rhs");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_expr(tcx: &ty::ctxt, e: &@ast::expr) {
|
fn check_expr(tcx: &ty::ctxt, e: &@ast::expr) {
|
||||||
alt e.node {
|
alt e.node {
|
||||||
ast::expr_move(a, b) { need_shared_lhs_rhs(tcx, a, b, "<-"); }
|
ast::expr_move(a, b) { need_shared_lhs_rhs(tcx, a, b, ~"<-"); }
|
||||||
ast::expr_assign(a, b) { need_shared_lhs_rhs(tcx, a, b, "="); }
|
ast::expr_assign(a, b) { need_shared_lhs_rhs(tcx, a, b, ~"="); }
|
||||||
ast::expr_assign_op(_, a, b) { need_shared_lhs_rhs(tcx, a, b, "op="); }
|
ast::expr_assign_op(_, a, b) { need_shared_lhs_rhs(tcx, a, b, ~"op="); }
|
||||||
ast::expr_swap(a, b) { need_shared_lhs_rhs(tcx, a, b, "<->"); }
|
ast::expr_swap(a, b) { need_shared_lhs_rhs(tcx, a, b, ~"<->"); }
|
||||||
ast::expr_copy(a) {
|
ast::expr_copy(a) {
|
||||||
need_expr_kind(tcx, a, ast::kind_shared, "'copy' operand");
|
need_expr_kind(tcx, a, ast::kind_shared, ~"'copy' operand");
|
||||||
}
|
}
|
||||||
ast::expr_ret(option::some(a)) {
|
ast::expr_ret(option::some(a)) {
|
||||||
need_expr_kind(tcx, a, ast::kind_shared, "'ret' operand");
|
need_expr_kind(tcx, a, ast::kind_shared, ~"'ret' operand");
|
||||||
}
|
}
|
||||||
ast::expr_be(a) {
|
ast::expr_be(a) {
|
||||||
need_expr_kind(tcx, a, ast::kind_shared, "'be' operand");
|
need_expr_kind(tcx, a, ast::kind_shared, ~"'be' operand");
|
||||||
}
|
}
|
||||||
ast::expr_fail(option::some(a)) {
|
ast::expr_fail(option::some(a)) {
|
||||||
need_expr_kind(tcx, a, ast::kind_shared, "'fail' operand");
|
need_expr_kind(tcx, a, ast::kind_shared, ~"'fail' operand");
|
||||||
}
|
}
|
||||||
ast::expr_call(callee, _) {
|
ast::expr_call(callee, _) {
|
||||||
let tpt = ty::expr_ty_params_and_ty(tcx, callee);
|
let tpt = ty::expr_ty_params_and_ty(tcx, callee);
|
||||||
|
@ -58,9 +58,9 @@ fn variant_opt(ccx: &@crate_ctxt, pat_id: ast::node_id) -> opt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type bind_map = [{ident: ast::ident, val: ValueRef}];
|
type bind_map = [{ident: ast::ident, val: ValueRef}];
|
||||||
fn assoc(key: str, list: &bind_map) -> option::t<ValueRef> {
|
fn assoc(key: &istr, list: &bind_map) -> option::t<ValueRef> {
|
||||||
for elt: {ident: ast::ident, val: ValueRef} in list {
|
for elt: {ident: ast::ident, val: ValueRef} in list {
|
||||||
if istr::eq(elt.ident, istr::from_estr(key)) { ret some(elt.val); }
|
if istr::eq(elt.ident, key) { ret some(elt.val); }
|
||||||
}
|
}
|
||||||
ret none;
|
ret none;
|
||||||
}
|
}
|
||||||
@ -304,7 +304,7 @@ fn compile_submatch(bcx: @block_ctxt, m: &match, vals: [ValueRef],
|
|||||||
// the actual arm block.
|
// the actual arm block.
|
||||||
for each @{key, val} in data.id_map.items() {
|
for each @{key, val} in data.id_map.items() {
|
||||||
bcx.fcx.lllocals.insert
|
bcx.fcx.lllocals.insert
|
||||||
(val, option::get(assoc(istr::to_estr(key),
|
(val, option::get(assoc(key,
|
||||||
m[0].bound)));
|
m[0].bound)));
|
||||||
}
|
}
|
||||||
let {bcx: guard_bcx, val: guard_val} =
|
let {bcx: guard_bcx, val: guard_val} =
|
||||||
@ -474,7 +474,7 @@ fn make_phi_bindings(bcx: &@block_ctxt, map: &[exit_node],
|
|||||||
let vals = [];
|
let vals = [];
|
||||||
for ex: exit_node in map {
|
for ex: exit_node in map {
|
||||||
if ex.to as uint == our_block {
|
if ex.to as uint == our_block {
|
||||||
alt assoc(istr::to_estr(item.key), ex.bound) {
|
alt assoc(item.key, ex.bound) {
|
||||||
some(val) { llbbs += [ex.from]; vals += [val]; }
|
some(val) { llbbs += [ex.from]; vals += [val]; }
|
||||||
none. { }
|
none. { }
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ fn method_ty_to_fn_ty(cx: &ctxt, m: method) -> t {
|
|||||||
// Never construct these manually. These are interned.
|
// Never construct these manually. These are interned.
|
||||||
type raw_t =
|
type raw_t =
|
||||||
{struct: sty,
|
{struct: sty,
|
||||||
cname: option::t<str>,
|
cname: option::t<istr>,
|
||||||
hash: uint,
|
hash: uint,
|
||||||
has_params: bool,
|
has_params: bool,
|
||||||
has_vars: bool};
|
has_vars: bool};
|
||||||
@ -427,8 +427,8 @@ fn mk_ctxt(s: session::session, dm: resolve::def_map,
|
|||||||
|
|
||||||
|
|
||||||
// Type constructors
|
// Type constructors
|
||||||
fn mk_raw_ty(cx: &ctxt, st: &sty, _in_cname: &option::t<str>) -> @raw_t {
|
fn mk_raw_ty(cx: &ctxt, st: &sty, _in_cname: &option::t<istr>) -> @raw_t {
|
||||||
let cname = none;
|
let cname: option::t<istr> = none;
|
||||||
let h = hash_type_info(st, cname);
|
let h = hash_type_info(st, cname);
|
||||||
let has_params: bool = false;
|
let has_params: bool = false;
|
||||||
let has_vars: bool = false;
|
let has_vars: bool = false;
|
||||||
@ -505,11 +505,11 @@ fn mk_raw_ty(cx: &ctxt, st: &sty, _in_cname: &option::t<str>) -> @raw_t {
|
|||||||
has_vars: has_vars};
|
has_vars: has_vars};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn intern(cx: &ctxt, st: &sty, cname: &option::t<str>) {
|
fn intern(cx: &ctxt, st: &sty, cname: &option::t<istr>) {
|
||||||
interner::intern(*cx.ts, mk_raw_ty(cx, st, cname));
|
interner::intern(*cx.ts, mk_raw_ty(cx, st, cname));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gen_ty_full(cx: &ctxt, st: &sty, cname: &option::t<str>) -> t {
|
fn gen_ty_full(cx: &ctxt, st: &sty, cname: &option::t<istr>) -> t {
|
||||||
let raw_type = mk_raw_ty(cx, st, cname);
|
let raw_type = mk_raw_ty(cx, st, cname);
|
||||||
ret interner::intern(*cx.ts, raw_type);
|
ret interner::intern(*cx.ts, raw_type);
|
||||||
}
|
}
|
||||||
@ -617,7 +617,7 @@ fn struct(cx: &ctxt, typ: t) -> sty {
|
|||||||
|
|
||||||
|
|
||||||
// Returns the canonical name of the given type.
|
// Returns the canonical name of the given type.
|
||||||
fn cname(cx: &ctxt, typ: t) -> option::t<str> {
|
fn cname(cx: &ctxt, typ: t) -> option::t<istr> {
|
||||||
ret interner::get(*cx.ts, typ).cname;
|
ret interner::get(*cx.ts, typ).cname;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,7 +794,7 @@ fn fold_ty(cx: &ctxt, fld: fold_mode, ty_0: t) -> t {
|
|||||||
|
|
||||||
// Type utilities
|
// Type utilities
|
||||||
|
|
||||||
fn rename(cx: &ctxt, typ: t, new_cname: str) -> t {
|
fn rename(cx: &ctxt, typ: t, new_cname: &istr) -> t {
|
||||||
ret gen_ty_full(cx, struct(cx, typ), some(new_cname));
|
ret gen_ty_full(cx, struct(cx, typ), some(new_cname));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1538,11 +1538,11 @@ fn hash_type_structure(st: &sty) -> uint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hash_type_info(st: &sty, cname_opt: &option::t<str>) -> uint {
|
fn hash_type_info(st: &sty, cname_opt: &option::t<istr>) -> uint {
|
||||||
let h = hash_type_structure(st);
|
let h = hash_type_structure(st);
|
||||||
alt cname_opt {
|
alt cname_opt {
|
||||||
none. {/* no-op */ }
|
none. {/* no-op */ }
|
||||||
some(s) { h += h << 5u + str::hash(s); }
|
some(s) { h += h << 5u + istr::hash(s); }
|
||||||
}
|
}
|
||||||
ret h;
|
ret h;
|
||||||
}
|
}
|
||||||
@ -1606,7 +1606,7 @@ fn eq_raw_ty(a: &@raw_t, b: &@raw_t) -> bool {
|
|||||||
none. { alt b.cname { none. {/* ok */ } _ { ret false; } } }
|
none. { alt b.cname { none. {/* ok */ } _ { ret false; } } }
|
||||||
some(s_a) {
|
some(s_a) {
|
||||||
alt b.cname {
|
alt b.cname {
|
||||||
some(s_b) { if !str::eq(s_a, s_b) { ret false; } }
|
some(s_b) { if !istr::eq(s_a, s_b) { ret false; } }
|
||||||
_ { ret false; }
|
_ { ret false; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -417,7 +417,7 @@ fn ast_ty_to_ty(tcx: &ty::ctxt, getter: &ty_getter, ast_ty: &@ast::ty) ->
|
|||||||
alt cname {
|
alt cname {
|
||||||
none. {/* no-op */ }
|
none. {/* no-op */ }
|
||||||
some(cname_str) {
|
some(cname_str) {
|
||||||
typ = ty::rename(tcx, typ, istr::to_estr(cname_str));
|
typ = ty::rename(tcx, typ, cname_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tcx.ast_ty_to_ty_cache.insert(ast_ty, some(typ));
|
tcx.ast_ty_to_ty_cache.insert(ast_ty, some(typ));
|
||||||
@ -629,7 +629,7 @@ mod collect {
|
|||||||
ty_params: &[ast::ty_param]) -> ty::ty_param_kinds_and_ty {
|
ty_params: &[ast::ty_param]) -> ty::ty_param_kinds_and_ty {
|
||||||
let methods = get_obj_method_types(cx, ob);
|
let methods = get_obj_method_types(cx, ob);
|
||||||
let t_obj = ty::mk_obj(cx.tcx, ty::sort_methods(methods));
|
let t_obj = ty::mk_obj(cx.tcx, ty::sort_methods(methods));
|
||||||
t_obj = ty::rename(cx.tcx, t_obj, istr::to_estr(id));
|
t_obj = ty::rename(cx.tcx, t_obj, id);
|
||||||
ret {kinds: ty_param_kinds(ty_params), ty: t_obj};
|
ret {kinds: ty_param_kinds(ty_params), ty: t_obj};
|
||||||
}
|
}
|
||||||
fn ty_of_obj_ctor(cx: @ctxt, id: &ast::ident, ob: &ast::_obj,
|
fn ty_of_obj_ctor(cx: @ctxt, id: &ast::ident, ob: &ast::_obj,
|
||||||
|
@ -28,15 +28,15 @@ fn expand_syntax_ext(cx: &ext_ctxt, sp: codemap::span, arg: @ast::expr,
|
|||||||
|
|
||||||
let var = expr_to_str(cx, args[0], ~"#env requires a string");
|
let var = expr_to_str(cx, args[0], ~"#env requires a string");
|
||||||
alt generic_os::getenv(var) {
|
alt generic_os::getenv(var) {
|
||||||
option::none. { ret make_new_str(cx, sp, ""); }
|
option::none. { ret make_new_str(cx, sp, ~""); }
|
||||||
option::some(s) {
|
option::some(s) {
|
||||||
ret make_new_str(cx, sp, istr::to_estr(s));
|
ret make_new_str(cx, sp, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_new_str(cx: &ext_ctxt, sp: codemap::span, s: str) -> @ast::expr {
|
fn make_new_str(cx: &ext_ctxt, sp: codemap::span, s: &istr) -> @ast::expr {
|
||||||
ret make_new_lit(cx, sp, ast::lit_str(istr::from_estr(s), ast::sk_rc));
|
ret make_new_lit(cx, sp, ast::lit_str(s, ast::sk_rc));
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
|
@ -52,8 +52,8 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
|
|||||||
let sp_lit = @{node: lit, span: sp};
|
let sp_lit = @{node: lit, span: sp};
|
||||||
ret @{id: cx.next_id(), node: ast::expr_lit(sp_lit), span: sp};
|
ret @{id: cx.next_id(), node: ast::expr_lit(sp_lit), span: sp};
|
||||||
}
|
}
|
||||||
fn make_new_str(cx: &ext_ctxt, sp: span, s: str) -> @ast::expr {
|
fn make_new_str(cx: &ext_ctxt, sp: span, s: &istr) -> @ast::expr {
|
||||||
let lit = ast::lit_str(istr::from_estr(s), ast::sk_rc);
|
let lit = ast::lit_str(s, ast::sk_rc);
|
||||||
ret make_new_lit(cx, sp, lit);
|
ret make_new_lit(cx, sp, lit);
|
||||||
}
|
}
|
||||||
fn make_new_int(cx: &ext_ctxt, sp: span, i: int) -> @ast::expr {
|
fn make_new_int(cx: &ext_ctxt, sp: span, i: int) -> @ast::expr {
|
||||||
@ -109,8 +109,9 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
|
|||||||
ret [~"extfmt", ~"rt", ident];
|
ret [~"extfmt", ~"rt", ident];
|
||||||
} else { ret [~"std", ~"extfmt", ~"rt", ident]; }
|
} else { ret [~"std", ~"extfmt", ~"rt", ident]; }
|
||||||
}
|
}
|
||||||
fn make_rt_path_expr(cx: &ext_ctxt, sp: span, ident: str) -> @ast::expr {
|
fn make_rt_path_expr(cx: &ext_ctxt, sp: span,
|
||||||
let path = make_path_vec(cx, istr::from_estr(ident));
|
ident: &istr) -> @ast::expr {
|
||||||
|
let path = make_path_vec(cx, ident);
|
||||||
ret make_path_expr(cx, sp, path);
|
ret make_path_expr(cx, sp, path);
|
||||||
}
|
}
|
||||||
// Produces an AST expression that represents a RT::conv record,
|
// Produces an AST expression that represents a RT::conv record,
|
||||||
@ -122,11 +123,11 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
|
|||||||
for f: flag in flags {
|
for f: flag in flags {
|
||||||
let fstr;
|
let fstr;
|
||||||
alt f {
|
alt f {
|
||||||
flag_left_justify. { fstr = "flag_left_justify"; }
|
flag_left_justify. { fstr = ~"flag_left_justify"; }
|
||||||
flag_left_zero_pad. { fstr = "flag_left_zero_pad"; }
|
flag_left_zero_pad. { fstr = ~"flag_left_zero_pad"; }
|
||||||
flag_space_for_sign. { fstr = "flag_space_for_sign"; }
|
flag_space_for_sign. { fstr = ~"flag_space_for_sign"; }
|
||||||
flag_sign_always. { fstr = "flag_sign_always"; }
|
flag_sign_always. { fstr = ~"flag_sign_always"; }
|
||||||
flag_alternate. { fstr = "flag_alternate"; }
|
flag_alternate. { fstr = ~"flag_alternate"; }
|
||||||
}
|
}
|
||||||
flagexprs += [make_rt_path_expr(cx, sp, fstr)];
|
flagexprs += [make_rt_path_expr(cx, sp, fstr)];
|
||||||
}
|
}
|
||||||
@ -135,14 +136,14 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
|
|||||||
// this is a hack placeholder flag
|
// this is a hack placeholder flag
|
||||||
|
|
||||||
if vec::len::<@ast::expr>(flagexprs) == 0u {
|
if vec::len::<@ast::expr>(flagexprs) == 0u {
|
||||||
flagexprs += [make_rt_path_expr(cx, sp, "flag_none")];
|
flagexprs += [make_rt_path_expr(cx, sp, ~"flag_none")];
|
||||||
}
|
}
|
||||||
ret make_vec_expr(cx, sp, flagexprs);
|
ret make_vec_expr(cx, sp, flagexprs);
|
||||||
}
|
}
|
||||||
fn make_count(cx: &ext_ctxt, sp: span, cnt: &count) -> @ast::expr {
|
fn make_count(cx: &ext_ctxt, sp: span, cnt: &count) -> @ast::expr {
|
||||||
alt cnt {
|
alt cnt {
|
||||||
count_implied. {
|
count_implied. {
|
||||||
ret make_rt_path_expr(cx, sp, "count_implied");
|
ret make_rt_path_expr(cx, sp, ~"count_implied");
|
||||||
}
|
}
|
||||||
count_is(c) {
|
count_is(c) {
|
||||||
let count_lit = make_new_int(cx, sp, c);
|
let count_lit = make_new_int(cx, sp, c);
|
||||||
@ -158,13 +159,13 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
|
|||||||
alt t {
|
alt t {
|
||||||
ty_hex(c) {
|
ty_hex(c) {
|
||||||
alt c {
|
alt c {
|
||||||
case_upper. { rt_type = "ty_hex_upper"; }
|
case_upper. { rt_type = ~"ty_hex_upper"; }
|
||||||
case_lower. { rt_type = "ty_hex_lower"; }
|
case_lower. { rt_type = ~"ty_hex_lower"; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty_bits. { rt_type = "ty_bits"; }
|
ty_bits. { rt_type = ~"ty_bits"; }
|
||||||
ty_octal. { rt_type = "ty_octal"; }
|
ty_octal. { rt_type = ~"ty_octal"; }
|
||||||
_ { rt_type = "ty_default"; }
|
_ { rt_type = ~"ty_default"; }
|
||||||
}
|
}
|
||||||
ret make_rt_path_expr(cx, sp, rt_type);
|
ret make_rt_path_expr(cx, sp, rt_type);
|
||||||
}
|
}
|
||||||
@ -184,9 +185,9 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
|
|||||||
ret make_conv_rec(cx, sp, rt_conv_flags, rt_conv_width,
|
ret make_conv_rec(cx, sp, rt_conv_flags, rt_conv_width,
|
||||||
rt_conv_precision, rt_conv_ty);
|
rt_conv_precision, rt_conv_ty);
|
||||||
}
|
}
|
||||||
fn make_conv_call(cx: &ext_ctxt, sp: span, conv_type: str, cnv: &conv,
|
fn make_conv_call(cx: &ext_ctxt, sp: span, conv_type: &istr,
|
||||||
arg: @ast::expr) -> @ast::expr {
|
cnv: &conv, arg: @ast::expr) -> @ast::expr {
|
||||||
let fname = ~"conv_" + istr::from_estr(conv_type);
|
let fname = ~"conv_" + conv_type;
|
||||||
let path = make_path_vec(cx, fname);
|
let path = make_path_vec(cx, fname);
|
||||||
let cnv_expr = make_rt_conv_expr(cx, sp, cnv);
|
let cnv_expr = make_rt_conv_expr(cx, sp, cnv);
|
||||||
let args = [cnv_expr, arg];
|
let args = [cnv_expr, arg];
|
||||||
@ -241,21 +242,21 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
|
|||||||
_ { cx.span_unimpl(sp, unsupported); }
|
_ { cx.span_unimpl(sp, unsupported); }
|
||||||
}
|
}
|
||||||
alt cnv.ty {
|
alt cnv.ty {
|
||||||
ty_str. { ret make_conv_call(cx, arg.span, "str", cnv, arg); }
|
ty_str. { ret make_conv_call(cx, arg.span, ~"str", cnv, arg); }
|
||||||
ty_istr. { ret make_conv_call(cx, arg.span, "istr", cnv, arg); }
|
ty_istr. { ret make_conv_call(cx, arg.span, ~"istr", cnv, arg); }
|
||||||
ty_int(sign) {
|
ty_int(sign) {
|
||||||
alt sign {
|
alt sign {
|
||||||
signed. { ret make_conv_call(cx, arg.span, "int", cnv, arg); }
|
signed. { ret make_conv_call(cx, arg.span, ~"int", cnv, arg); }
|
||||||
unsigned. {
|
unsigned. {
|
||||||
ret make_conv_call(cx, arg.span, "uint", cnv, arg);
|
ret make_conv_call(cx, arg.span, ~"uint", cnv, arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty_bool. { ret make_conv_call(cx, arg.span, "bool", cnv, arg); }
|
ty_bool. { ret make_conv_call(cx, arg.span, ~"bool", cnv, arg); }
|
||||||
ty_char. { ret make_conv_call(cx, arg.span, "char", cnv, arg); }
|
ty_char. { ret make_conv_call(cx, arg.span, ~"char", cnv, arg); }
|
||||||
ty_hex(_) { ret make_conv_call(cx, arg.span, "uint", cnv, arg); }
|
ty_hex(_) { ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); }
|
||||||
ty_bits. { ret make_conv_call(cx, arg.span, "uint", cnv, arg); }
|
ty_bits. { ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); }
|
||||||
ty_octal. { ret make_conv_call(cx, arg.span, "uint", cnv, arg); }
|
ty_octal. { ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); }
|
||||||
_ { cx.span_unimpl(sp, unsupported); }
|
_ { cx.span_unimpl(sp, unsupported); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -319,12 +320,12 @@ fn pieces_to_expr(cx: &ext_ctxt, sp: span, pieces: &[piece],
|
|||||||
}
|
}
|
||||||
let fmt_sp = args[0].span;
|
let fmt_sp = args[0].span;
|
||||||
let n = 0u;
|
let n = 0u;
|
||||||
let tmp_expr = make_new_str(cx, sp, "");
|
let tmp_expr = make_new_str(cx, sp, ~"");
|
||||||
let nargs = vec::len::<@ast::expr>(args);
|
let nargs = vec::len::<@ast::expr>(args);
|
||||||
for pc: piece in pieces {
|
for pc: piece in pieces {
|
||||||
alt pc {
|
alt pc {
|
||||||
piece_string(s) {
|
piece_string(s) {
|
||||||
let s_expr = make_new_str(cx, fmt_sp, s);
|
let s_expr = make_new_str(cx, fmt_sp, istr::from_estr(s));
|
||||||
tmp_expr = make_add_expr(cx, fmt_sp, tmp_expr, s_expr);
|
tmp_expr = make_add_expr(cx, fmt_sp, tmp_expr, s_expr);
|
||||||
}
|
}
|
||||||
piece_conv(conv) {
|
piece_conv(conv) {
|
||||||
|
@ -57,8 +57,7 @@ tag matchable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* for when given an incompatible bit of AST */
|
/* for when given an incompatible bit of AST */
|
||||||
fn match_error(cx: &ext_ctxt, m: &matchable, expected: &str) -> ! {
|
fn match_error(cx: &ext_ctxt, m: &matchable, expected: &istr) -> ! {
|
||||||
let expected = istr::from_estr(expected);
|
|
||||||
alt m {
|
alt m {
|
||||||
match_expr(x) {
|
match_expr(x) {
|
||||||
cx.span_fatal(x.span,
|
cx.span_fatal(x.span,
|
||||||
@ -355,7 +354,7 @@ fn transcribe_ident(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint],
|
|||||||
i: &ident, _fld: ast_fold) -> ident {
|
i: &ident, _fld: ast_fold) -> ident {
|
||||||
ret alt follow_for_trans(cx, b.find(i), idx_path) {
|
ret alt follow_for_trans(cx, b.find(i), idx_path) {
|
||||||
some(match_ident(a_id)) { a_id.node }
|
some(match_ident(a_id)) { a_id.node }
|
||||||
some(m) { match_error(cx, m, "an identifier") }
|
some(m) { match_error(cx, m, ~"an identifier") }
|
||||||
none. { i }
|
none. { i }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -370,7 +369,7 @@ fn transcribe_path(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint],
|
|||||||
{global: false, idents: [id.node], types: []}
|
{global: false, idents: [id.node], types: []}
|
||||||
}
|
}
|
||||||
some(match_path(a_pth)) { a_pth.node }
|
some(match_path(a_pth)) { a_pth.node }
|
||||||
some(m) { match_error(cx, m, "a path") }
|
some(m) { match_error(cx, m, ~"a path") }
|
||||||
none. { p }
|
none. { p }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -395,7 +394,7 @@ fn transcribe_expr(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint],
|
|||||||
}
|
}
|
||||||
some(match_path(a_pth)) { expr_path(a_pth) }
|
some(match_path(a_pth)) { expr_path(a_pth) }
|
||||||
some(match_expr(a_exp)) { a_exp.node }
|
some(match_expr(a_exp)) { a_exp.node }
|
||||||
some(m) { match_error(cx, m, "an expression") }
|
some(m) { match_error(cx, m, ~"an expression") }
|
||||||
none. { orig(e, fld) }
|
none. { orig(e, fld) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -412,7 +411,7 @@ fn transcribe_type(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint],
|
|||||||
some(id) {
|
some(id) {
|
||||||
alt follow_for_trans(cx, b.find(id), idx_path) {
|
alt follow_for_trans(cx, b.find(id), idx_path) {
|
||||||
some(match_ty(ty)) { ty.node }
|
some(match_ty(ty)) { ty.node }
|
||||||
some(m) { match_error(cx, m, "a type") }
|
some(m) { match_error(cx, m, ~"a type") }
|
||||||
none. { orig(t, fld) }
|
none. { orig(t, fld) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -439,7 +438,7 @@ fn transcribe_block(cx: &ext_ctxt, b: &bindings, idx_path: @mutable [uint],
|
|||||||
|
|
||||||
// possibly allow promotion of ident/path/expr to blocks?
|
// possibly allow promotion of ident/path/expr to blocks?
|
||||||
some(m) {
|
some(m) {
|
||||||
match_error(cx, m, "a block")
|
match_error(cx, m, ~"a block")
|
||||||
}
|
}
|
||||||
none. { orig(blk, fld) }
|
none. { orig(blk, fld) }
|
||||||
}
|
}
|
||||||
@ -564,13 +563,13 @@ fn p_t_s_r_mac(cx: &ext_ctxt, mac: &ast::mac, s: &selector, b: &binders) {
|
|||||||
_ { cx.bug(~"broken traversal in p_t_s_r") }
|
_ { cx.bug(~"broken traversal in p_t_s_r") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn no_des(cx: &ext_ctxt, sp: &span, syn: &str) -> ! {
|
fn no_des(cx: &ext_ctxt, sp: &span, syn: &istr) -> ! {
|
||||||
cx.span_fatal(sp, ~"destructuring "
|
cx.span_fatal(sp, ~"destructuring "
|
||||||
+ istr::from_estr(syn) + ~" is not yet supported");
|
+ syn + ~" is not yet supported");
|
||||||
}
|
}
|
||||||
alt mac.node {
|
alt mac.node {
|
||||||
ast::mac_ellipsis. { cx.span_fatal(mac.span, ~"misused `...`"); }
|
ast::mac_ellipsis. { cx.span_fatal(mac.span, ~"misused `...`"); }
|
||||||
ast::mac_invoc(_, _, _) { no_des(cx, mac.span, "macro calls"); }
|
ast::mac_invoc(_, _, _) { no_des(cx, mac.span, ~"macro calls"); }
|
||||||
ast::mac_embed_type(ty) {
|
ast::mac_embed_type(ty) {
|
||||||
alt ty.node {
|
alt ty.node {
|
||||||
ast::ty_path(pth, _) {
|
ast::ty_path(pth, _) {
|
||||||
@ -587,10 +586,10 @@ fn p_t_s_r_mac(cx: &ext_ctxt, mac: &ast::mac, s: &selector, b: &binders) {
|
|||||||
b.real_binders.insert(
|
b.real_binders.insert(
|
||||||
id, compose_sels(s, final_step));
|
id, compose_sels(s, final_step));
|
||||||
}
|
}
|
||||||
none. { no_des(cx, pth.span, "under `#<>`"); }
|
none. { no_des(cx, pth.span, ~"under `#<>`"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ { no_des(cx, ty.span, "under `#<>`"); }
|
_ { no_des(cx, ty.span, ~"under `#<>`"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::mac_embed_block(blk) {
|
ast::mac_embed_block(blk) {
|
||||||
@ -608,7 +607,7 @@ fn p_t_s_r_mac(cx: &ext_ctxt, mac: &ast::mac, s: &selector, b: &binders) {
|
|||||||
b.real_binders.insert(id,
|
b.real_binders.insert(id,
|
||||||
compose_sels(s, final_step));
|
compose_sels(s, final_step));
|
||||||
}
|
}
|
||||||
none. { no_des(cx, blk.span, "under `#{}`"); }
|
none. { no_des(cx, blk.span, ~"under `#{}`"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> istr {
|
|||||||
}
|
}
|
||||||
alt cname(cx, typ) {
|
alt cname(cx, typ) {
|
||||||
some(cs) {
|
some(cs) {
|
||||||
ret istr::from_estr(cs);
|
ret cs;
|
||||||
}
|
}
|
||||||
_ { }
|
_ { }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user