syntax/ext: migrate build.rs functions to AstBuilder methods.

This commit is contained in:
Huon Wilson 2013-05-18 00:19:28 +10:00
parent 8c15a0ec4c
commit 6e50515530
19 changed files with 1126 additions and 925 deletions

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@ use ast;
use codemap::span;
use ext::base::*;
use ext::base;
use ext::build::{mk_u8, mk_slice_vec_e};
use ext::build::AstBuilder;
pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult {
// Gather all argument expressions
@ -28,7 +28,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) -> bas
// string literal, push each byte to vector expression
ast::lit_str(s) => {
for s.each |byte| {
bytes.push(mk_u8(cx, sp, byte));
bytes.push(cx.mk_u8(sp, byte));
}
}
@ -37,7 +37,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) -> bas
if v > 0xFF {
cx.span_err(sp, "Too large u8 literal in bytes!")
} else {
bytes.push(mk_u8(cx, sp, v as u8));
bytes.push(cx.mk_u8(sp, v as u8));
}
}
@ -48,14 +48,14 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) -> bas
} else if v < 0 {
cx.span_err(sp, "Negative integer literal in bytes!")
} else {
bytes.push(mk_u8(cx, sp, v as u8));
bytes.push(cx.mk_u8(sp, v as u8));
}
}
// char literal, push to vector expression
ast::lit_int(v, ast::ty_char) => {
if (v as char).is_ascii() {
bytes.push(mk_u8(cx, sp, v as u8));
bytes.push(cx.mk_u8(sp, v as u8));
} else {
cx.span_err(sp, "Non-ascii char literal in bytes!")
}
@ -68,6 +68,6 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) -> bas
}
}
let e = mk_slice_vec_e(cx, sp, bytes);
let e = cx.mk_slice_vec_e(sp, bytes);
MRExpr(e)
}

View File

@ -12,6 +12,7 @@ use ast::{meta_item, item, expr};
use codemap::span;
use ext::base::ExtCtxt;
use ext::build;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
@ -79,7 +80,7 @@ fn cs_clone(
let ctor_ident;
let all_fields;
let subcall = |field|
build::mk_method_call(cx, span, field, clone_ident, ~[]);
cx.mk_method_call(span, field, clone_ident, ~[]);
match *substr.fields {
Struct(ref af) => {
@ -102,7 +103,7 @@ fn cs_clone(
[(None, _, _), .. _] => {
// enum-like
let subcalls = all_fields.map(|&(_, self_f, _)| subcall(self_f));
build::mk_call(cx, span, ctor_ident, subcalls)
cx.mk_call(span, ctor_ident, subcalls)
},
_ => {
// struct-like
@ -118,9 +119,9 @@ fn cs_clone(
if fields.is_empty() {
// no fields, so construct like `None`
build::mk_path(cx, span, ctor_ident)
cx.mk_path(span, ctor_ident)
} else {
build::mk_struct_e(cx, span,
cx.mk_struct_e(span,
ctor_ident,
fields)
}

View File

@ -11,7 +11,7 @@
use ast::{meta_item, item, expr};
use codemap::span;
use ext::base::ExtCtxt;
use ext::build;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
pub fn expand_deriving_eq(cx: @ExtCtxt,
@ -21,11 +21,11 @@ pub fn expand_deriving_eq(cx: @ExtCtxt,
// structures are equal if all fields are equal, and non equal, if
// any fields are not equal or if the enum variants are different
fn cs_eq(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
cs_and(|cx, span, _, _| build::mk_bool(cx, span, false),
cs_and(|cx, span, _, _| cx.mk_bool(span, false),
cx, span, substr)
}
fn cs_ne(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
cs_or(|cx, span, _, _| build::mk_bool(cx, span, true),
cs_or(|cx, span, _, _| cx.mk_bool(span, true),
cx, span, substr)
}

View File

@ -12,7 +12,7 @@
use ast::{meta_item, item, expr_if, expr};
use codemap::span;
use ext::base::ExtCtxt;
use ext::build;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
pub fn expand_deriving_ord(cx: @ExtCtxt,
@ -62,10 +62,10 @@ fn cs_ord(less: bool, equal: bool,
} else {
cx.ident_of("gt")
};
let false_blk_expr = build::mk_block(cx, span,
let false_blk_expr = cx.mk_block(span,
~[], ~[],
Some(build::mk_bool(cx, span, false)));
let base = build::mk_bool(cx, span, equal);
Some(cx.mk_bool(span, false)));
let base = cx.mk_bool(span, equal);
cs_fold(
false, // need foldr,
@ -98,19 +98,19 @@ fn cs_ord(less: bool, equal: bool,
cx.span_bug(span, "Not exactly 2 arguments in `deriving(Ord)`");
}
let cmp = build::mk_method_call(cx, span,
let cmp = cx.mk_method_call(span,
self_f, cx.ident_of("eq"), other_fs.to_owned());
let subexpr = build::mk_simple_block(cx, span, subexpr);
let subexpr = cx.mk_simple_block(span, subexpr);
let elseif = expr_if(cmp, subexpr, Some(false_blk_expr));
let elseif = build::mk_expr(cx, span, elseif);
let elseif = cx.mk_expr(span, elseif);
let cmp = build::mk_method_call(cx, span,
let cmp = cx.mk_method_call(span,
self_f, binop, other_fs.to_owned());
let true_blk = build::mk_simple_block(cx, span,
build::mk_bool(cx, span, true));
let true_blk = cx.mk_simple_block(span,
cx.mk_bool(span, true));
let if_ = expr_if(cmp, true_blk, Some(elseif));
build::mk_expr(cx, span, if_)
cx.mk_expr(span, if_)
},
base,
|cx, span, args, _| {
@ -119,7 +119,7 @@ fn cs_ord(less: bool, equal: bool,
match args {
[(self_var, _, _),
(other_var, _, _)] =>
build::mk_bool(cx, span,
cx.mk_bool(span,
if less {
self_var < other_var
} else {

View File

@ -12,7 +12,7 @@
use ast::{meta_item, item, expr};
use codemap::span;
use ext::base::ExtCtxt;
use ext::build;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
pub fn expand_deriving_totaleq(cx: @ExtCtxt,
@ -21,7 +21,7 @@ pub fn expand_deriving_totaleq(cx: @ExtCtxt,
in_items: ~[@item]) -> ~[@item] {
fn cs_equals(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
cs_and(|cx, span, _, _| build::mk_bool(cx, span, false),
cs_and(|cx, span, _, _| cx.mk_bool(span, false),
cx, span, substr)
}

View File

@ -11,7 +11,7 @@
use ast::{meta_item, item, expr};
use codemap::span;
use ext::base::ExtCtxt;
use ext::build;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
use core::cmp::{Ordering, Equal, Less, Greater};
@ -47,7 +47,7 @@ pub fn ordering_const(cx: @ExtCtxt, span: span, cnst: Ordering) -> @expr {
Equal => "Equal",
Greater => "Greater"
};
build::mk_path_global(cx, span,
cx.mk_path_global(span,
~[cx.ident_of("core"),
cx.ident_of("cmp"),
cx.ident_of(cnst)])
@ -60,7 +60,7 @@ pub fn cs_cmp(cx: @ExtCtxt, span: span,
// foldr (possibly) nests the matches in lexical_ordering better
false,
|cx, span, old, new| {
build::mk_call_global(cx, span,
cx.mk_call_global(span,
~[cx.ident_of("core"),
cx.ident_of("cmp"),
cx.ident_of("lexical_ordering")],

View File

@ -16,7 +16,8 @@ encodable.rs for more.
use ast;
use ast::*;
use ext::base::ExtCtxt;
use ext::build;
use ext::build::Field;
use ext::build::AstBuilder;
use ext::deriving::*;
use codemap::{span, spanned};
use ast_util;
@ -44,12 +45,10 @@ fn create_derived_decodable_impl(
generics: &Generics,
method: @method
) -> @item {
let decoder_ty_param = build::mk_ty_param(
cx,
let decoder_ty_param = cx.mk_ty_param(
cx.ident_of("__D"),
@opt_vec::with(
build::mk_trait_ty_param_bound_global(
cx,
cx.mk_trait_ty_param_bound_global(
span,
~[
cx.ident_of("std"),
@ -64,7 +63,7 @@ fn create_derived_decodable_impl(
let generic_ty_params = opt_vec::with(decoder_ty_param);
let methods = [method];
let trait_path = build::mk_raw_path_global_(
let trait_path = cx.mk_raw_path_global_(
span,
~[
cx.ident_of("std"),
@ -73,7 +72,7 @@ fn create_derived_decodable_impl(
],
None,
~[
build::mk_simple_ty_path(cx, span, cx.ident_of("__D"))
cx.mk_simple_ty_path(span, cx.ident_of("__D"))
]
);
create_derived_impl(
@ -98,15 +97,14 @@ fn create_decode_method(
expr: @ast::expr
) -> @method {
// Create the `e` parameter.
let d_arg_type = build::mk_ty_rptr(
cx,
let d_arg_type = cx.mk_ty_rptr(
span,
build::mk_simple_ty_path(cx, span, cx.ident_of("__D")),
cx.mk_simple_ty_path(span, cx.ident_of("__D")),
None,
ast::m_mutbl
);
let d_ident = cx.ident_of("__d");
let d_arg = build::mk_arg(cx, span, d_ident, d_arg_type);
let d_arg = cx.mk_arg(span, d_ident, d_arg_type);
// Create the type of the return value.
let output_type = create_self_type_with_params(
@ -118,10 +116,10 @@ fn create_decode_method(
// Create the function declaration.
let inputs = ~[d_arg];
let fn_decl = build::mk_fn_decl(inputs, output_type);
let fn_decl = cx.mk_fn_decl(inputs, output_type);
// Create the body block.
let body_block = build::mk_simple_block(cx, span, expr);
let body_block = cx.mk_simple_block(span, expr);
// Create the method.
let explicit_self = spanned { node: sty_static, span: span };
@ -146,11 +144,9 @@ fn call_substructure_decode_method(
span: span
) -> @ast::expr {
// Call the substructure method.
build::mk_call_(
cx,
cx.mk_call_(
span,
build::mk_path_global(
cx,
cx.mk_path_global(
span,
~[
cx.ident_of("std"),
@ -160,7 +156,7 @@ fn call_substructure_decode_method(
]
),
~[
build::mk_path(cx, span, ~[cx.ident_of("__d")])
cx.mk_path(span, ~[cx.ident_of("__d")])
]
)
}
@ -222,32 +218,31 @@ fn create_read_struct_field(
span: span,
idx: uint,
ident: ident
) -> build::Field {
) -> Field {
// Call the substructure method.
let decode_expr = call_substructure_decode_method(cx, span);
let d_arg = build::mk_arg(cx,
let d_arg = cx.mk_arg(
span,
cx.ident_of("__d"),
build::mk_ty_infer(cx, span));
cx.mk_ty_infer(span));
let call_expr = build::mk_method_call(
cx,
let call_expr = cx.mk_method_call(
span,
build::mk_path(cx, span, ~[cx.ident_of("__d")]),
cx.mk_path(span, ~[cx.ident_of("__d")]),
cx.ident_of("read_struct_field"),
~[
build::mk_base_str(cx, span, cx.str_of(ident)),
build::mk_uint(cx, span, idx),
build::mk_lambda(cx,
cx.mk_base_str(span, cx.str_of(ident)),
cx.mk_uint(span, idx),
cx.mk_lambda(
span,
build::mk_fn_decl(~[d_arg],
build::mk_ty_infer(cx, span)),
cx.mk_fn_decl(~[d_arg],
cx.mk_ty_infer(span)),
decode_expr),
]
);
build::Field { ident: ident, ex: call_expr }
Field { ident: ident, ex: call_expr }
}
fn create_read_struct_arg(
@ -255,22 +250,21 @@ fn create_read_struct_arg(
span: span,
idx: uint,
ident: ident
) -> build::Field {
) -> Field {
// Call the substructure method.
let decode_expr = call_substructure_decode_method(cx, span);
let call_expr = build::mk_method_call(
cx,
let call_expr = cx.mk_method_call(
span,
build::mk_path(cx, span, ~[cx.ident_of("__d")]),
cx.mk_path(span, ~[cx.ident_of("__d")]),
cx.ident_of("read_struct_arg"),
~[
build::mk_uint(cx, span, idx),
build::mk_lambda_no_args(cx, span, decode_expr),
cx.mk_uint(span, idx),
cx.mk_lambda_no_args(span, decode_expr),
]
);
build::Field { ident: ident, ex: call_expr }
Field { ident: ident, ex: call_expr }
}
fn expand_deriving_decodable_struct_method(
@ -298,29 +292,25 @@ fn expand_deriving_decodable_struct_method(
i += 1;
}
let d_arg = build::mk_arg(cx,
let d_arg = cx.mk_arg(
span,
cx.ident_of("__d"),
build::mk_ty_infer(cx, span));
cx.mk_ty_infer(span));
let read_struct_expr = build::mk_method_call(
cx,
let read_struct_expr = cx.mk_method_call(
span,
build::mk_path(
cx,
cx.mk_path(
span,
~[cx.ident_of("__d")]
),
cx.ident_of("read_struct"),
~[
build::mk_base_str(cx, span, cx.str_of(type_ident)),
build::mk_uint(cx, span, fields.len()),
build::mk_lambda(
cx,
cx.mk_base_str(span, cx.str_of(type_ident)),
cx.mk_uint(span, fields.len()),
cx.mk_lambda(
span,
build::mk_fn_decl(~[d_arg], build::mk_ty_infer(cx, span)),
build::mk_struct_e(
cx,
cx.mk_fn_decl(~[d_arg], cx.mk_ty_infer(span)),
cx.mk_struct_e(
span,
~[type_ident],
fields
@ -340,14 +330,14 @@ fn create_read_variant_arg(
variant: &ast::variant
) -> ast::arm {
// Create the matching pattern.
let pat = build::mk_pat_lit(cx, span, build::mk_uint(cx, span, idx));
let pat = cx.mk_pat_lit(span, cx.mk_uint(span, idx));
// Feed each argument in this variant to the decode function
// as well.
let variant_arg_len = variant_arg_count(cx, span, variant);
let expr = if variant_arg_len == 0 {
build::mk_path(cx, span, ~[variant.node.name])
cx.mk_path(span, ~[variant.node.name])
} else {
// Feed the discriminant to the decode function.
let mut args = ~[];
@ -356,22 +346,21 @@ fn create_read_variant_arg(
// Call the substructure method.
let expr = call_substructure_decode_method(cx, span);
let d_arg = build::mk_arg(cx,
let d_arg = cx.mk_arg(
span,
cx.ident_of("__d"),
build::mk_ty_infer(cx, span));
let t_infer = build::mk_ty_infer(cx, span);
cx.mk_ty_infer(span));
let t_infer = cx.mk_ty_infer(span);
let call_expr = build::mk_method_call(
cx,
let call_expr = cx.mk_method_call(
span,
build::mk_path(cx, span, ~[cx.ident_of("__d")]),
cx.mk_path(span, ~[cx.ident_of("__d")]),
cx.ident_of("read_enum_variant_arg"),
~[
build::mk_uint(cx, span, j),
build::mk_lambda(cx,
cx.mk_uint(span, j),
cx.mk_lambda(
span,
build::mk_fn_decl(~[d_arg], t_infer),
cx.mk_fn_decl(~[d_arg], t_infer),
expr),
]
);
@ -379,8 +368,7 @@ fn create_read_variant_arg(
args.push(call_expr);
}
build::mk_call(
cx,
cx.mk_call(
span,
~[variant.node.name],
args
@ -388,7 +376,7 @@ fn create_read_variant_arg(
};
// Create the arm.
build::mk_arm(cx, span, ~[pat], expr)
cx.mk_arm(span, ~[pat], expr)
}
fn create_read_enum_variant(
@ -397,12 +385,10 @@ fn create_read_enum_variant(
enum_definition: &enum_def
) -> @expr {
// Create a vector that contains all the variant names.
let expr_arm_names = build::mk_base_vec_e(
cx,
let expr_arm_names = cx.mk_base_vec_e(
span,
do enum_definition.variants.map |variant| {
build::mk_base_str(
cx,
cx.mk_base_str(
span,
cx.str_of(variant.node.name)
)
@ -415,41 +401,36 @@ fn create_read_enum_variant(
};
// Add the impossible case arm.
arms.push(build::mk_unreachable_arm(cx, span));
arms.push(cx.mk_unreachable_arm(span));
// Create the read_enum_variant expression.
build::mk_method_call(
cx,
cx.mk_method_call(
span,
build::mk_path(cx, span, ~[cx.ident_of("__d")]),
cx.mk_path(span, ~[cx.ident_of("__d")]),
cx.ident_of("read_enum_variant"),
~[
expr_arm_names,
build::mk_lambda(
cx,
cx.mk_lambda(
span,
build::mk_fn_decl(
cx.mk_fn_decl(
~[
build::mk_arg(
cx,
cx.mk_arg(
span,
cx.ident_of("__d"),
build::mk_ty_infer(cx, span)
cx.mk_ty_infer(span)
),
build::mk_arg(
cx,
cx.mk_arg(
span,
cx.ident_of("__i"),
build::mk_ty_infer(cx, span)
cx.mk_ty_infer(span)
)
],
build::mk_ty_infer(cx, span)
cx.mk_ty_infer(span)
),
build::mk_expr(
cx,
cx.mk_expr(
span,
ast::expr_match(
build::mk_path(cx, span, ~[cx.ident_of("__i")]),
cx.mk_path(span, ~[cx.ident_of("__i")]),
arms
)
)
@ -471,23 +452,22 @@ fn expand_deriving_decodable_enum_method(
enum_definition
);
let d_arg = build::mk_arg(cx,
let d_arg = cx.mk_arg(
span,
cx.ident_of("__d"),
build::mk_ty_infer(cx, span));
cx.mk_ty_infer(span));
// Create the read_enum expression
let read_enum_expr = build::mk_method_call(
cx,
let read_enum_expr = cx.mk_method_call(
span,
build::mk_path(cx, span, ~[cx.ident_of("__d")]),
cx.mk_path(span, ~[cx.ident_of("__d")]),
cx.ident_of("read_enum"),
~[
build::mk_base_str(cx, span, cx.str_of(type_ident)),
build::mk_lambda(cx,
cx.mk_base_str(span, cx.str_of(type_ident)),
cx.mk_lambda(
span,
build::mk_fn_decl(~[d_arg],
build::mk_ty_infer(cx, span)),
cx.mk_fn_decl(~[d_arg],
cx.mk_ty_infer(span)),
read_enum_variant_expr),
]
);

View File

@ -79,7 +79,7 @@ would yield functions like:
use ast;
use ast::*;
use ext::base::ExtCtxt;
use ext::build;
use ext::build::AstBuilder;
use ext::deriving::*;
use codemap::{span, spanned};
use ast_util;
@ -107,12 +107,10 @@ fn create_derived_encodable_impl(
generics: &Generics,
method: @method
) -> @item {
let encoder_ty_param = build::mk_ty_param(
cx,
let encoder_ty_param = cx.mk_ty_param(
cx.ident_of("__E"),
@opt_vec::with(
build::mk_trait_ty_param_bound_global(
cx,
cx.mk_trait_ty_param_bound_global(
span,
~[
cx.ident_of("std"),
@ -127,7 +125,7 @@ fn create_derived_encodable_impl(
let generic_ty_params = opt_vec::with(encoder_ty_param);
let methods = [method];
let trait_path = build::mk_raw_path_global_(
let trait_path = cx.mk_raw_path_global_(
span,
~[
cx.ident_of("std"),
@ -136,7 +134,7 @@ fn create_derived_encodable_impl(
],
None,
~[
build::mk_simple_ty_path(cx, span, cx.ident_of("__E"))
cx.mk_simple_ty_path(span, cx.ident_of("__E"))
]
);
create_derived_impl(
@ -159,24 +157,23 @@ fn create_encode_method(
statements: ~[@stmt]
) -> @method {
// Create the `e` parameter.
let e_arg_type = build::mk_ty_rptr(
cx,
let e_arg_type = cx.mk_ty_rptr(
span,
build::mk_simple_ty_path(cx, span, cx.ident_of("__E")),
cx.mk_simple_ty_path(span, cx.ident_of("__E")),
None,
ast::m_mutbl
);
let e_arg = build::mk_arg(cx, span, cx.ident_of("__e"), e_arg_type);
let e_arg = cx.mk_arg(span, cx.ident_of("__e"), e_arg_type);
// Create the type of the return value.
let output_type = @ast::Ty { id: cx.next_id(), node: ty_nil, span: span };
// Create the function declaration.
let inputs = ~[e_arg];
let fn_decl = build::mk_fn_decl(inputs, output_type);
let fn_decl = cx.mk_fn_decl(inputs, output_type);
// Create the body block.
let body_block = build::mk_block_(cx, span, statements);
let body_block = cx.mk_block_(span, statements);
// Create the method.
let explicit_self = spanned { node: sty_region(None, m_imm), span: span };
@ -203,12 +200,11 @@ fn call_substructure_encode_method(
) -> @ast::expr {
// Gather up the parameters we want to chain along.
let e_ident = cx.ident_of("__e");
let e_expr = build::mk_path(cx, span, ~[e_ident]);
let e_expr = cx.mk_path(span, ~[e_ident]);
// Call the substructure method.
let encode_ident = cx.ident_of("encode");
build::mk_method_call(
cx,
cx.mk_method_call(
span,
self_field,
encode_ident,
@ -279,9 +275,9 @@ fn expand_deriving_encodable_struct_method(
match struct_field.node.kind {
named_field(ident, _) => {
// Create the accessor for this field.
let self_field = build::mk_access_(cx,
let self_field = cx.mk_access_(
span,
build::make_self(cx, span),
cx.make_self(span),
ident);
// Call the substructure method.
@ -292,31 +288,29 @@ fn expand_deriving_encodable_struct_method(
);
let e_ident = cx.ident_of("__e");
let e_arg = build::mk_arg(cx,
let e_arg = cx.mk_arg(
span,
e_ident,
build::mk_ty_infer(cx, span));
cx.mk_ty_infer(span));
let blk_expr = build::mk_lambda(
cx,
let blk_expr = cx.mk_lambda(
span,
build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)),
cx.mk_fn_decl(~[e_arg], cx.mk_ty_infer(span)),
encode_expr
);
let call_expr = build::mk_method_call(
cx,
let call_expr = cx.mk_method_call(
span,
build::mk_path(cx, span, ~[cx.ident_of("__e")]),
cx.mk_path(span, ~[cx.ident_of("__e")]),
cx.ident_of("emit_struct_field"),
~[
build::mk_base_str(cx, span, cx.str_of(ident)),
build::mk_uint(cx, span, idx),
cx.mk_base_str(span, cx.str_of(ident)),
cx.mk_uint(span, idx),
blk_expr
]
);
statements.push(build::mk_stmt(cx, span, call_expr));
statements.push(cx.mk_stmt(span, call_expr));
}
unnamed_field => {
cx.span_unimpl(
@ -328,33 +322,30 @@ fn expand_deriving_encodable_struct_method(
idx += 1;
}
let e_arg = build::mk_arg(cx,
let e_arg = cx.mk_arg(
span,
cx.ident_of("__e"),
build::mk_ty_infer(cx, span));
cx.mk_ty_infer(span));
let emit_struct_stmt = build::mk_method_call(
cx,
let emit_struct_stmt = cx.mk_method_call(
span,
build::mk_path(
cx,
cx.mk_path(
span,
~[cx.ident_of("__e")]
),
cx.ident_of("emit_struct"),
~[
build::mk_base_str(cx, span, cx.str_of(type_ident)),
build::mk_uint(cx, span, statements.len()),
build::mk_lambda_stmts(
cx,
cx.mk_base_str(span, cx.str_of(type_ident)),
cx.mk_uint(span, statements.len()),
cx.mk_lambda_stmts(
span,
build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)),
cx.mk_fn_decl(~[e_arg], cx.mk_ty_infer(span)),
statements
),
]
);
let statements = ~[build::mk_stmt(cx, span, emit_struct_stmt)];
let statements = ~[cx.mk_stmt(span, emit_struct_stmt)];
// Create the method itself.
return create_encode_method(cx, span, statements);
@ -382,56 +373,52 @@ fn expand_deriving_encodable_enum_method(
let expr = call_substructure_encode_method(cx, span, field);
let e_ident = cx.ident_of("__e");
let e_arg = build::mk_arg(cx,
let e_arg = cx.mk_arg(
span,
e_ident,
build::mk_ty_infer(cx, span));
cx.mk_ty_infer(span));
let blk_expr = build::mk_lambda(
cx,
let blk_expr = cx.mk_lambda(
span,
build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)),
cx.mk_fn_decl(~[e_arg], cx.mk_ty_infer(span)),
expr
);
let call_expr = build::mk_method_call(
cx,
let call_expr = cx.mk_method_call(
span,
build::mk_path(cx, span, ~[cx.ident_of("__e")]),
cx.mk_path(span, ~[cx.ident_of("__e")]),
cx.ident_of("emit_enum_variant_arg"),
~[
build::mk_uint(cx, span, j),
cx.mk_uint(span, j),
blk_expr,
]
);
stmts.push(build::mk_stmt(cx, span, call_expr));
stmts.push(cx.mk_stmt(span, call_expr));
}
// Create the pattern body.
let e_arg = build::mk_arg(cx,
let e_arg = cx.mk_arg(
span,
cx.ident_of("__e"),
build::mk_ty_infer(cx, span));
let call_expr = build::mk_method_call(
cx,
cx.mk_ty_infer(span));
let call_expr = cx.mk_method_call(
span,
build::mk_path(cx, span, ~[cx.ident_of("__e")]),
cx.mk_path(span, ~[cx.ident_of("__e")]),
cx.ident_of("emit_enum_variant"),
~[
build::mk_base_str(cx, span, cx.str_of(variant.node.name)),
build::mk_uint(cx, span, i),
build::mk_uint(cx, span, variant_arg_len),
build::mk_lambda_stmts(
cx,
cx.mk_base_str(span, cx.str_of(variant.node.name)),
cx.mk_uint(span, i),
cx.mk_uint(span, variant_arg_len),
cx.mk_lambda_stmts(
span,
build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)),
cx.mk_fn_decl(~[e_arg], cx.mk_ty_infer(span)),
stmts
)
]
);
let match_body_block = build::mk_simple_block(cx, span, call_expr);
let match_body_block = cx.mk_simple_block(span, call_expr);
// Create the arm.
ast::arm {
@ -442,31 +429,29 @@ fn expand_deriving_encodable_enum_method(
};
let e_ident = cx.ident_of("__e");
let e_arg = build::mk_arg(cx,
let e_arg = cx.mk_arg(
span,
e_ident,
build::mk_ty_infer(cx, span));
cx.mk_ty_infer(span));
// Create the method body.
let lambda_expr = build::mk_lambda(
cx,
let lambda_expr = cx.mk_lambda(
span,
build::mk_fn_decl(~[e_arg], build::mk_ty_infer(cx, span)),
cx.mk_fn_decl(~[e_arg], cx.mk_ty_infer(span)),
expand_enum_or_struct_match(cx, span, arms)
);
let call_expr = build::mk_method_call(
cx,
let call_expr = cx.mk_method_call(
span,
build::mk_path(cx, span, ~[cx.ident_of("__e")]),
cx.mk_path(span, ~[cx.ident_of("__e")]),
cx.ident_of("emit_enum"),
~[
build::mk_base_str(cx, span, cx.str_of(type_ident)),
cx.mk_base_str(span, cx.str_of(type_ident)),
lambda_expr,
]
);
let stmt = build::mk_stmt(cx, span, call_expr);
let stmt = cx.mk_stmt(span, call_expr);
// Create the method.
create_encode_method(cx, span, ~[stmt])

View File

@ -166,7 +166,7 @@ use ast;
use ast::{enum_def, expr, ident, Generics, struct_def};
use ext::base::ExtCtxt;
use ext::build;
use ext::build::AstBuilder;
use ext::deriving::*;
use codemap::{span,respan};
use opt_vec;
@ -431,7 +431,7 @@ impl<'self> MethodDef<'self> {
let ident = cx.ident_of(fmt!("__arg_%u", i));
arg_tys.push((ident, ast_ty));
let arg_expr = build::mk_path(cx, span, ~[ident]);
let arg_expr = cx.mk_path(span, ~[ident]);
match *ty {
// for static methods, just treat any Self
@ -440,7 +440,7 @@ impl<'self> MethodDef<'self> {
self_args.push(arg_expr);
}
Ptr(~Self, _) if nonstatic => {
self_args.push(build::mk_deref(cx, span, arg_expr))
self_args.push(cx.mk_deref(span, arg_expr))
}
_ => {
nonself_args.push(arg_expr);
@ -461,14 +461,14 @@ impl<'self> MethodDef<'self> {
let fn_generics = self.generics.to_generics(cx, span, type_ident, generics);
let args = do arg_types.map |&(id, ty)| {
build::mk_arg(cx, span, id, ty)
cx.mk_arg(span, id, ty)
};
let ret_type = self.get_ret_ty(cx, span, generics, type_ident);
let method_ident = cx.ident_of(self.name);
let fn_decl = build::mk_fn_decl(args, ret_type);
let body_block = build::mk_simple_block(cx, span, body);
let fn_decl = cx.mk_fn_decl(args, ret_type);
let body_block = cx.mk_simple_block(span, body);
// Create the method.
@ -558,10 +558,10 @@ impl<'self> MethodDef<'self> {
let match_arm = ast::arm {
pats: ~[ pat ],
guard: None,
body: build::mk_simple_block(cx, span, body)
body: cx.mk_simple_block(span, body)
};
body = build::mk_expr(cx, span, ast::expr_match(arg_expr, ~[match_arm]))
body = cx.mk_expr(span, ast::expr_match(arg_expr, ~[match_arm]))
}
body
}
@ -738,15 +738,15 @@ impl<'self> MethodDef<'self> {
matches_so_far,
match_count + 1);
matches_so_far.pop();
arms.push(build::mk_arm(cx, span, ~[ pattern ], arm_expr));
arms.push(cx.mk_arm(span, ~[ pattern ], arm_expr));
if enum_def.variants.len() > 1 {
let e = &EnumNonMatching(&[]);
let wild_expr = self.call_substructure_method(cx, span, type_ident,
self_args, nonself_args,
e);
let wild_arm = build::mk_arm(cx, span,
~[ build::mk_pat_wild(cx, span) ],
let wild_arm = cx.mk_arm(span,
~[ cx.mk_pat_wild(span) ],
wild_expr);
arms.push(wild_arm);
}
@ -774,13 +774,13 @@ impl<'self> MethodDef<'self> {
match_count + 1);
matches_so_far.pop();
let arm = build::mk_arm(cx, span, ~[ pattern ], arm_expr);
let arm = cx.mk_arm(span, ~[ pattern ], arm_expr);
arms.push(arm);
}
}
// match foo { arm, arm, arm, ... }
build::mk_expr(cx, span,
cx.mk_expr(span,
ast::expr_match(self_args[match_count], arms))
}
}
@ -887,7 +887,7 @@ pub fn cs_same_method(f: &fn(@ExtCtxt, span, ~[@expr]) -> @expr,
EnumMatching(_, _, ref all_fields) | Struct(ref all_fields) => {
// call self_n.method(other_1_n, other_2_n, ...)
let called = do all_fields.map |&(_, self_field, other_fields)| {
build::mk_method_call(cx, span,
cx.mk_method_call(span,
self_field,
substructure.method_ident,
other_fields)
@ -945,7 +945,7 @@ pub fn cs_binop(binop: ast::binop, base: @expr,
cs_same_method_fold(
true, // foldl is good enough
|cx, span, old, new| {
build::mk_binary(cx, span,
cx.mk_binary(span,
binop,
old, new)
@ -960,7 +960,7 @@ pub fn cs_binop(binop: ast::binop, base: @expr,
pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: span,
substructure: &Substructure) -> @expr {
cs_binop(ast::or, build::mk_bool(cx, span, false),
cs_binop(ast::or, cx.mk_bool(span, false),
enum_nonmatch_f,
cx, span, substructure)
}
@ -969,7 +969,7 @@ pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc,
pub fn cs_and(enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: span,
substructure: &Substructure) -> @expr {
cs_binop(ast::and, build::mk_bool(cx, span, true),
cs_binop(ast::and, cx.mk_bool(span, true),
enum_nonmatch_f,
cx, span, substructure)
}

View File

@ -11,7 +11,7 @@
use ast::{meta_item, item, expr, and};
use codemap::span;
use ext::base::ExtCtxt;
use ext::build;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
pub fn expand_deriving_iter_bytes(cx: @ExtCtxt,
@ -48,7 +48,7 @@ fn iter_bytes_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @
};
let iter_bytes_ident = substr.method_ident;
let call_iterbytes = |thing_expr| {
build::mk_method_call(cx, span,
cx.mk_method_call(span,
thing_expr, iter_bytes_ident,
copy lsb0_f)
};
@ -63,7 +63,7 @@ fn iter_bytes_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @
// iteration function.
let discriminant = match variant.node.disr_expr {
Some(copy d)=> d,
None => build::mk_uint(cx, span, index)
None => cx.mk_uint(span, index)
};
exprs.push(call_iterbytes(discriminant));
@ -82,6 +82,6 @@ fn iter_bytes_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @
}
do vec::foldl(exprs[0], exprs.slice(1, exprs.len())) |prev, me| {
build::mk_binary(cx, span, and, prev, *me)
cx.mk_binary(span, and, prev, *me)
}
}

View File

@ -21,7 +21,7 @@ library.
use ast;
use ast::{Ty, enum_def, expr, ident, item, Generics, meta_item, struct_def};
use ext::base::ExtCtxt;
use ext::build;
use ext::build::AstBuilder;
use codemap::{span, respan};
use parse::token::special_idents::clownshoes_extensions;
use opt_vec;
@ -172,7 +172,7 @@ pub fn create_self_type_with_params(cx: @ExtCtxt,
// Create the type parameters on the `self` path.
let mut self_ty_params = ~[];
for generics.ty_params.each |ty_param| {
let self_ty_param = build::mk_simple_ty_path(cx,
let self_ty_param = cx.mk_simple_ty_path(
span,
ty_param.ident);
self_ty_params.push(self_ty_param);
@ -186,11 +186,11 @@ pub fn create_self_type_with_params(cx: @ExtCtxt,
// Create the type of `self`.
let self_type = build::mk_raw_path_(span,
~[ type_ident ],
let self_type = cx.mk_raw_path_(span,
~[ type_ident ],
lifetime,
self_ty_params);
build::mk_ty_path_path(cx, span, self_type)
cx.mk_ty_path_path(span, self_type)
}
pub fn create_derived_impl(cx: @ExtCtxt,
@ -222,18 +222,18 @@ pub fn create_derived_impl(cx: @ExtCtxt,
for generics.ty_params.each |ty_param| {
// extra restrictions on the generics parameters to the type being derived upon
let mut bounds = do bounds_paths.map |&bound_path| {
build::mk_trait_ty_param_bound_(cx, bound_path)
cx.mk_trait_ty_param_bound_(bound_path)
};
let this_trait_bound =
build::mk_trait_ty_param_bound_(cx, trait_path);
cx.mk_trait_ty_param_bound_(trait_path);
bounds.push(this_trait_bound);
impl_generics.ty_params.push(build::mk_ty_param(cx, ty_param.ident, @bounds));
impl_generics.ty_params.push(cx.mk_ty_param(ty_param.ident, @bounds));
}
// Create the reference to the trait.
let trait_ref = build::mk_trait_ref_(cx, trait_path);
let trait_ref = cx.mk_trait_ref_(trait_path);
// Create the type of `self`.
let self_type = create_self_type_with_params(cx,
@ -255,7 +255,7 @@ pub fn create_subpatterns(cx: @ExtCtxt,
mutbl: ast::mutability)
-> ~[@ast::pat] {
do field_paths.map |&path| {
build::mk_pat(cx, span,
cx.mk_pat(span,
ast::pat_ident(ast::bind_by_ref(mutbl), path, None))
}
}
@ -274,12 +274,12 @@ pub fn create_struct_pattern(cx: @ExtCtxt,
-> (@ast::pat, ~[(Option<ident>, @expr)]) {
if struct_def.fields.is_empty() {
return (
build::mk_pat_ident_with_binding_mode(
cx, span, struct_ident, ast::bind_infer),
cx.mk_pat_ident_with_binding_mode(
span, struct_ident, ast::bind_infer),
~[]);
}
let matching_path = build::mk_raw_path(span, ~[ struct_ident ]);
let matching_path = cx.mk_raw_path(span, ~[ struct_ident ]);
let mut paths = ~[], ident_expr = ~[];
@ -301,10 +301,10 @@ pub fn create_struct_pattern(cx: @ExtCtxt,
cx.span_bug(span, "A struct with named and unnamed fields in `deriving`");
}
};
let path = build::mk_raw_path(span,
let path = cx.mk_raw_path(span,
~[ cx.ident_of(fmt!("%s_%u", prefix, i)) ]);
paths.push(path);
ident_expr.push((opt_id, build::mk_path_raw(cx, span, path)));
ident_expr.push((opt_id, cx.mk_path_raw(span, path)));
}
let subpats = create_subpatterns(cx, span, paths, mutbl);
@ -318,9 +318,9 @@ pub fn create_struct_pattern(cx: @ExtCtxt,
push(ast::field_pat { ident: id.get(), pat: pat })
}
};
build::mk_pat_struct(cx, span, matching_path, field_pats)
cx.mk_pat_struct(span, matching_path, field_pats)
} else {
build::mk_pat_enum(cx, span, matching_path, subpats)
cx.mk_pat_enum(span, matching_path, subpats)
};
(pattern, ident_expr)
@ -337,24 +337,24 @@ pub fn create_enum_variant_pattern(cx: @ExtCtxt,
match variant.node.kind {
ast::tuple_variant_kind(ref variant_args) => {
if variant_args.is_empty() {
return (build::mk_pat_ident_with_binding_mode(
cx, span, variant_ident, ast::bind_infer), ~[]);
return (cx.mk_pat_ident_with_binding_mode(
span, variant_ident, ast::bind_infer), ~[]);
}
let matching_path = build::mk_raw_path(span, ~[ variant_ident ]);
let matching_path = cx.mk_raw_path(span, ~[ variant_ident ]);
let mut paths = ~[], ident_expr = ~[];
for uint::range(0, variant_args.len()) |i| {
let path = build::mk_raw_path(span,
let path = cx.mk_raw_path(span,
~[ cx.ident_of(fmt!("%s_%u", prefix, i)) ]);
paths.push(path);
ident_expr.push((None, build::mk_path_raw(cx, span, path)));
ident_expr.push((None, cx.mk_path_raw(span, path)));
}
let subpats = create_subpatterns(cx, span, paths, mutbl);
(build::mk_pat_enum(cx, span, matching_path, subpats),
(cx.mk_pat_enum(span, matching_path, subpats),
ident_expr)
}
ast::struct_variant_kind(struct_def) => {
@ -377,8 +377,8 @@ pub fn expand_enum_or_struct_match(cx: @ExtCtxt,
span: span,
arms: ~[ ast::arm ])
-> @expr {
let self_expr = build::make_self(cx, span);
let self_expr = build::mk_unary(cx, span, ast::deref, self_expr);
let self_expr = cx.make_self(span);
let self_expr = cx.mk_unary(span, ast::deref, self_expr);
let self_match_expr = ast::expr_match(self_expr, arms);
build::mk_expr(cx, span, self_match_expr)
cx.mk_expr(span, self_match_expr)
}

View File

@ -12,7 +12,7 @@ use ast;
use ast::{meta_item, item, expr, ident};
use codemap::span;
use ext::base::ExtCtxt;
use ext::build;
use ext::build::{AstBuilder, Duplicate, Field};
use ext::deriving::generic::*;
pub fn expand_deriving_rand(cx: @ExtCtxt,
@ -59,10 +59,10 @@ fn rand_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
cx.ident_of("rand")
];
let rand_call = || {
build::mk_call_global(cx,
cx.mk_call_global(
span,
copy rand_ident,
~[ build::duplicate_expr(cx, rng[0]) ])
~[ rng[0].duplicate(cx) ])
};
return match *substr.fields {
@ -74,30 +74,30 @@ fn rand_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
cx.span_fatal(span, "`Rand` cannot be derived for enums with no variants");
}
let variant_count = build::mk_uint(cx, span, variants.len());
let variant_count = cx.mk_uint(span, variants.len());
// need to specify the uint-ness of the random number
let u32_ty = build::mk_ty_path(cx, span, ~[cx.ident_of("uint")]);
let r_ty = build::mk_ty_path(cx, span, ~[cx.ident_of("R")]);
let rand_name = build::mk_raw_path_(span, copy rand_ident, None, ~[ u32_ty, r_ty ]);
let rand_name = build::mk_path_raw(cx, span, rand_name);
let u32_ty = cx.mk_ty_path(span, ~[cx.ident_of("uint")]);
let r_ty = cx.mk_ty_path(span, ~[cx.ident_of("R")]);
let rand_name = cx.mk_raw_path_(span, copy rand_ident, None, ~[ u32_ty, r_ty ]);
let rand_name = cx.mk_path_raw(span, rand_name);
let rv_call = build::mk_call_(cx,
let rv_call = cx.mk_call_(
span,
rand_name,
~[ build::duplicate_expr(cx, rng[0]) ]);
~[ rng[0].duplicate(cx) ]);
// rand() % variants.len()
let rand_variant = build::mk_binary(cx, span, ast::rem,
let rand_variant = cx.mk_binary(span, ast::rem,
rv_call, variant_count);
let mut arms = do variants.mapi |i, id_sum| {
let i_expr = build::mk_uint(cx, span, i);
let pat = build::mk_pat_lit(cx, span, i_expr);
let i_expr = cx.mk_uint(span, i);
let pat = cx.mk_pat_lit(span, i_expr);
match *id_sum {
(ident, ref summary) => {
build::mk_arm(cx, span,
cx.mk_arm(span,
~[ pat ],
rand_thing(cx, span, ident, summary, rand_call))
}
@ -105,9 +105,9 @@ fn rand_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
};
// _ => {} at the end. Should never occur
arms.push(build::mk_unreachable_arm(cx, span));
arms.push(cx.mk_unreachable_arm(span));
build::mk_expr(cx, span,
cx.mk_expr(span,
ast::expr_match(rand_variant, arms))
}
_ => cx.bug("Non-static method in `deriving(Rand)`")
@ -121,20 +121,20 @@ fn rand_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
match *summary {
Left(copy count) => {
if count == 0 {
build::mk_path(cx, span, ctor_ident)
cx.mk_path(span, ctor_ident)
} else {
let exprs = vec::from_fn(count, |_| rand_call());
build::mk_call(cx, span, ctor_ident, exprs)
cx.mk_call(span, ctor_ident, exprs)
}
}
Right(ref fields) => {
let rand_fields = do fields.map |ident| {
build::Field {
Field {
ident: *ident,
ex: rand_call()
}
};
build::mk_struct_e(cx, span, ctor_ident, rand_fields)
cx.mk_struct_e(span, ctor_ident, rand_fields)
}
}
}

View File

@ -11,7 +11,7 @@
use ast::{meta_item, item, expr};
use codemap::span;
use ext::base::ExtCtxt;
use ext::build;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
pub fn expand_deriving_to_str(cx: @ExtCtxt,
@ -42,8 +42,8 @@ pub fn expand_deriving_to_str(cx: @ExtCtxt,
fn to_str_substructure(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
match substr.self_args {
[self_obj] => {
let self_addr = build::mk_addr_of(cx, span, self_obj);
build::mk_call_global(cx, span,
let self_addr = cx.mk_addr_of(span, self_obj);
cx.mk_call_global(span,
~[cx.ident_of("core"),
cx.ident_of("sys"),
cx.ident_of("log_str")],

View File

@ -16,7 +16,7 @@ explicit `Self` type to use when specifying impls to be derived.
use ast;
use ast::{expr,Generics,ident};
use ext::base::ExtCtxt;
use ext::build;
use ext::build::AstBuilder;
use codemap::{span,respan};
use opt_vec;
@ -55,7 +55,7 @@ pub impl<'self> Path<'self> {
fn to_ty(&self, cx: @ExtCtxt, span: span,
self_ty: ident, self_generics: &Generics) -> @ast::Ty {
build::mk_ty_path_path(cx, span,
cx.mk_ty_path_path(span,
self.to_path(cx, span,
self_ty, self_generics))
}
@ -66,9 +66,9 @@ pub impl<'self> Path<'self> {
let tys = self.params.map(|t| t.to_ty(cx, span, self_ty, self_generics));
if self.global {
build::mk_raw_path_global_(span, idents, lt, tys)
cx.mk_raw_path_global_(span, idents, lt, tys)
} else {
build::mk_raw_path_(span, idents, lt, tys)
cx.mk_raw_path_(span, idents, lt, tys)
}
}
}
@ -106,7 +106,7 @@ pub fn nil_ty() -> Ty<'static> {
fn mk_lifetime(cx: @ExtCtxt, span: span, lt: &Option<&str>) -> Option<@ast::Lifetime> {
match *lt {
Some(ref s) => Some(@build::mk_lifetime(cx, span, cx.ident_of(*s))),
Some(ref s) => Some(@cx.mk_lifetime(span, cx.ident_of(*s))),
None => None
}
}
@ -119,20 +119,20 @@ pub impl<'self> Ty<'self> {
let raw_ty = ty.to_ty(cx, span, self_ty, self_generics);
match *ptr {
Owned => {
build::mk_ty_uniq(cx, span, raw_ty)
cx.mk_ty_uniq(span, raw_ty)
}
Managed(mutbl) => {
build::mk_ty_box(cx, span, raw_ty, mutbl)
cx.mk_ty_box(span, raw_ty, mutbl)
}
Borrowed(ref lt, mutbl) => {
let lt = mk_lifetime(cx, span, lt);
build::mk_ty_rptr(cx, span, raw_ty, lt, mutbl)
cx.mk_ty_rptr(span, raw_ty, lt, mutbl)
}
}
}
Literal(ref p) => { p.to_ty(cx, span, self_ty, self_generics) }
Self => {
build::mk_ty_path_path(cx, span, self.to_path(cx, span, self_ty, self_generics))
cx.mk_ty_path_path(span, self.to_path(cx, span, self_ty, self_generics))
}
Tuple(ref fields) => {
let ty = if fields.is_empty() {
@ -141,7 +141,7 @@ pub impl<'self> Ty<'self> {
ast::ty_tup(fields.map(|f| f.to_ty(cx, span, self_ty, self_generics)))
};
build::mk_ty(cx, span, ty)
cx.mk_ty(span, ty)
}
}
}
@ -151,7 +151,7 @@ pub impl<'self> Ty<'self> {
match *self {
Self => {
let self_params = do self_generics.ty_params.map |ty_param| {
build::mk_ty_path(cx, span, ~[ ty_param.ident ])
cx.mk_ty_path(span, ~[ ty_param.ident ])
};
let lifetime = if self_generics.lifetimes.is_empty() {
None
@ -159,7 +159,7 @@ pub impl<'self> Ty<'self> {
Some(@*self_generics.lifetimes.get(0))
};
build::mk_raw_path_(span, ~[self_ty], lifetime,
cx.mk_raw_path_(span, ~[self_ty], lifetime,
opt_vec::take_vec(self_params))
}
Literal(ref p) => {
@ -177,9 +177,9 @@ fn mk_ty_param(cx: @ExtCtxt, span: span, name: &str, bounds: &[Path],
let bounds = opt_vec::from(
do bounds.map |b| {
let path = b.to_path(cx, span, self_ident, self_generics);
build::mk_trait_ty_param_bound_(cx, path)
cx.mk_trait_ty_param_bound_(path)
});
build::mk_ty_param(cx, cx.ident_of(name), @bounds)
cx.mk_ty_param(cx.ident_of(name), @bounds)
}
fn mk_generics(lifetimes: ~[ast::Lifetime], ty_params: ~[ast::TyParam]) -> Generics {
@ -204,7 +204,7 @@ pub impl<'self> LifetimeBounds<'self> {
fn to_generics(&self, cx: @ExtCtxt, span: span,
self_ty: ident, self_generics: &Generics) -> Generics {
let lifetimes = do self.lifetimes.map |lt| {
build::mk_lifetime(cx, span, cx.ident_of(*lt))
cx.mk_lifetime(span, cx.ident_of(*lt))
};
let ty_params = do self.bounds.map |t| {
match t {
@ -220,7 +220,7 @@ pub impl<'self> LifetimeBounds<'self> {
pub fn get_explicit_self(cx: @ExtCtxt, span: span, self_ptr: &Option<PtrTy>)
-> (@expr, ast::explicit_self) {
let self_path = build::make_self(cx, span);
let self_path = cx.make_self(span);
match *self_ptr {
None => {
(self_path, respan(span, ast::sty_value))
@ -232,12 +232,12 @@ pub fn get_explicit_self(cx: @ExtCtxt, span: span, self_ptr: &Option<PtrTy>)
Owned => ast::sty_uniq(ast::m_imm),
Managed(mutbl) => ast::sty_box(mutbl),
Borrowed(ref lt, mutbl) => {
let lt = lt.map(|s| @build::mk_lifetime(cx, span,
let lt = lt.map(|s| @cx.mk_lifetime(span,
cx.ident_of(*s)));
ast::sty_region(lt, mutbl)
}
});
let self_expr = build::mk_deref(cx, span, self_path);
let self_expr = cx.mk_deref(span, self_path);
(self_expr, self_ty)
}
}

View File

@ -18,7 +18,7 @@ use ast;
use codemap::span;
use ext::base::*;
use ext::base;
use ext::build::mk_base_str;
use ext::build::AstBuilder;
pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
@ -29,8 +29,8 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
// Option<str> rather than just an maybe-empty string.
let e = match os::getenv(var) {
None => mk_base_str(cx, sp, ~""),
Some(ref s) => mk_base_str(cx, sp, copy *s)
None => cx.mk_base_str(sp, ~""),
Some(ref s) => cx.mk_base_str(sp, copy *s)
};
MRExpr(e)
}

View File

@ -19,7 +19,7 @@ use codemap::span;
use ext::base::*;
use ext::base;
use ext::build;
use ext::build::*;
use ext::build::AstBuilder;
use core::unstable::extfmt::ct::*;
@ -56,7 +56,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
}
fn make_rt_path_expr(cx: @ExtCtxt, sp: span, nm: &str) -> @ast::expr {
let path = make_path_vec(cx, nm);
return mk_path_global(cx, sp, path);
cx.mk_path_global(sp, path)
}
// Produces an AST expression that represents a RT::conv record,
// which tells the RT::conv* functions how to perform the conversion
@ -72,7 +72,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
FlagSignAlways => "flag_sign_always",
FlagAlternate => "flag_alternate"
};
tmp_expr = mk_binary(cx, sp, ast::bitor, tmp_expr,
tmp_expr = cx.mk_binary(sp, ast::bitor, tmp_expr,
make_rt_path_expr(cx, sp, fstr));
}
return tmp_expr;
@ -83,10 +83,10 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
return make_rt_path_expr(cx, sp, "CountImplied");
}
CountIs(c) => {
let count_lit = mk_uint(cx, sp, c as uint);
let count_lit = cx.mk_uint(sp, c as uint);
let count_is_path = make_path_vec(cx, "CountIs");
let count_is_args = ~[count_lit];
return mk_call_global(cx, sp, count_is_path, count_is_args);
return cx.mk_call_global(sp, count_is_path, count_is_args);
}
_ => cx.span_unimpl(sp, "unimplemented fmt! conversion")
}
@ -107,8 +107,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
width_expr: @ast::expr, precision_expr: @ast::expr,
ty_expr: @ast::expr) -> @ast::expr {
let intr = cx.parse_sess().interner;
mk_global_struct_e(
cx,
cx.mk_global_struct_e(
sp,
make_path_vec(cx, "Conv"),
~[
@ -140,7 +139,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
let path = make_path_vec(cx, fname);
let cnv_expr = make_rt_conv_expr(cx, sp, cnv);
let args = ~[cnv_expr, arg, buf];
return mk_call_global(cx, arg.span, path, args);
cx.mk_call_global(arg.span, path, args)
}
fn make_new_conv(cx: @ExtCtxt, sp: span, cnv: &Conv,
@ -198,10 +197,10 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
TyChar => ("char", arg),
TyBits | TyOctal | TyHex(_) | TyInt(Unsigned) => ("uint", arg),
TyFloat => ("float", arg),
TyPoly => ("poly", mk_addr_of(cx, sp, arg))
TyPoly => ("poly", cx.mk_addr_of(sp, arg))
};
return make_conv_call(cx, arg.span, name, cnv, actual_arg,
mk_mut_addr_of(cx, arg.span, buf));
cx.mk_mut_addr_of(arg.span, buf));
}
fn log_conv(c: &Conv) {
debug!("Building conversion:");
@ -259,7 +258,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
/* 'ident' is the local buffer building up the result of fmt! */
let ident = cx.parse_sess().interner.intern("__fmtbuf");
let buf = || mk_path(cx, fmt_sp, ~[ident]);
let buf = || cx.mk_path(fmt_sp, ~[ident]);
let str_ident = cx.parse_sess().interner.intern("str");
let push_ident = cx.parse_sess().interner.intern("push_str");
let mut stms = ~[];
@ -276,14 +275,14 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
buffer with it directly. If it's actually the only piece,
then there's no need for it to be mutable */
if i == 0 {
stms.push(mk_local(cx, fmt_sp, npieces > 1, ident, mk_uniq_str(cx, fmt_sp, s)));
stms.push(cx.mk_local(fmt_sp, npieces > 1, ident, cx.mk_uniq_str(fmt_sp, s)));
} else {
let args = ~[mk_mut_addr_of(cx, fmt_sp, buf()), mk_base_str(cx, fmt_sp, s)];
let call = mk_call_global(cx,
let args = ~[cx.mk_mut_addr_of(fmt_sp, buf()), cx.mk_base_str(fmt_sp, s)];
let call = cx.mk_call_global(
fmt_sp,
~[str_ident, push_ident],
args);
stms.push(mk_stmt(cx, fmt_sp, call));
stms.push(cx.mk_stmt(fmt_sp, call));
}
}
@ -300,12 +299,12 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
/* If the first portion is a conversion, then the local buffer
must be initialized as an empty string */
if i == 0 {
stms.push(mk_local(cx, fmt_sp, true, ident,
mk_uniq_str(cx, fmt_sp, ~"")));
stms.push(cx.mk_local(fmt_sp, true, ident,
cx.mk_uniq_str(fmt_sp, ~"")));
}
stms.push(mk_stmt(cx, fmt_sp,
make_new_conv(cx, fmt_sp, conv,
args[n], buf())));
stms.push(cx.mk_stmt(fmt_sp,
make_new_conv(cx, fmt_sp, conv,
args[n], buf())));
}
}
}
@ -317,5 +316,5 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
nargs, expected_nargs));
}
return mk_block(cx, fmt_sp, ~[], stms, Some(buf()));
cx.mk_block(fmt_sp, ~[], stms, Some(buf()))
}

View File

@ -12,7 +12,7 @@ use ast;
use codemap::{BytePos, Pos, span};
use ext::base::ExtCtxt;
use ext::base;
use ext::build;
use ext::build::AstBuilder;
use parse::token::*;
use parse::token;
use parse;
@ -382,7 +382,7 @@ pub fn expand_quote_expr(cx: @ExtCtxt,
pub fn expand_quote_item(cx: @ExtCtxt,
sp: span,
tts: &[ast::token_tree]) -> base::MacResult {
let e_attrs = build::mk_uniq_vec_e(cx, sp, ~[]);
let e_attrs = cx.mk_uniq_vec_e(sp, ~[]);
base::MRExpr(expand_parse_call(cx, sp, "parse_item",
~[e_attrs], tts))
}
@ -390,7 +390,7 @@ pub fn expand_quote_item(cx: @ExtCtxt,
pub fn expand_quote_pat(cx: @ExtCtxt,
sp: span,
tts: &[ast::token_tree]) -> base::MacResult {
let e_refutable = build::mk_lit(cx, sp, ast::lit_bool(true));
let e_refutable = cx.mk_lit(sp, ast::lit_bool(true));
base::MRExpr(expand_parse_call(cx, sp, "parse_pat",
~[e_refutable], tts))
}
@ -398,7 +398,7 @@ pub fn expand_quote_pat(cx: @ExtCtxt,
pub fn expand_quote_ty(cx: @ExtCtxt,
sp: span,
tts: &[ast::token_tree]) -> base::MacResult {
let e_param_colons = build::mk_lit(cx, sp, ast::lit_bool(false));
let e_param_colons = cx.mk_lit(sp, ast::lit_bool(false));
base::MRExpr(expand_parse_call(cx, sp, "parse_ty",
~[e_param_colons], tts))
}
@ -406,7 +406,7 @@ pub fn expand_quote_ty(cx: @ExtCtxt,
pub fn expand_quote_stmt(cx: @ExtCtxt,
sp: span,
tts: &[ast::token_tree]) -> base::MacResult {
let e_attrs = build::mk_uniq_vec_e(cx, sp, ~[]);
let e_attrs = cx.mk_uniq_vec_e(sp, ~[]);
base::MRExpr(expand_parse_call(cx, sp, "parse_stmt",
~[e_attrs], tts))
}
@ -421,17 +421,17 @@ fn id_ext(cx: @ExtCtxt, str: &str) -> ast::ident {
// Lift an ident to the expr that evaluates to that ident.
fn mk_ident(cx: @ExtCtxt, sp: span, ident: ast::ident) -> @ast::expr {
let e_str = build::mk_base_str(cx, sp, cx.str_of(ident));
build::mk_method_call(cx, sp,
build::mk_path(cx, sp, ids_ext(cx, ~[~"ext_cx"])),
id_ext(cx, "ident_of"),
~[e_str])
let e_str = cx.mk_base_str(sp, cx.str_of(ident));
cx.mk_method_call(sp,
cx.mk_path(sp, ids_ext(cx, ~[~"ext_cx"])),
id_ext(cx, "ident_of"),
~[e_str])
}
fn mk_bytepos(cx: @ExtCtxt, sp: span, bpos: BytePos) -> @ast::expr {
let path = ids_ext(cx, ~[~"BytePos"]);
let arg = build::mk_uint(cx, sp, bpos.to_uint());
build::mk_call(cx, sp, path, ~[arg])
let arg = cx.mk_uint(sp, bpos.to_uint());
cx.mk_call(sp, path, ~[arg])
}
fn mk_binop(cx: @ExtCtxt, sp: span, bop: token::binop) -> @ast::expr {
@ -447,7 +447,7 @@ fn mk_binop(cx: @ExtCtxt, sp: span, bop: token::binop) -> @ast::expr {
SHL => "SHL",
SHR => "SHR"
};
build::mk_path(cx, sp,
cx.mk_path(sp,
ids_ext(cx, ~[name.to_owned()]))
}
@ -455,12 +455,12 @@ fn mk_token(cx: @ExtCtxt, sp: span, tok: &token::Token) -> @ast::expr {
match *tok {
BINOP(binop) => {
return build::mk_call(cx, sp,
return cx.mk_call(sp,
ids_ext(cx, ~[~"BINOP"]),
~[mk_binop(cx, sp, binop)]);
}
BINOPEQ(binop) => {
return build::mk_call(cx, sp,
return cx.mk_call(sp,
ids_ext(cx, ~[~"BINOPEQ"]),
~[mk_binop(cx, sp, binop)]);
}
@ -475,12 +475,12 @@ fn mk_token(cx: @ExtCtxt, sp: span, tok: &token::Token) -> @ast::expr {
ast::ty_i64 => ~"ty_i64"
};
let e_ity =
build::mk_path(cx, sp,
cx.mk_path(sp,
ids_ext(cx, ~[s_ity]));
let e_i64 = build::mk_lit(cx, sp, ast::lit_int(i, ast::ty_i64));
let e_i64 = cx.mk_lit(sp, ast::lit_int(i, ast::ty_i64));
return build::mk_call(cx, sp,
return cx.mk_call(sp,
ids_ext(cx, ~[~"LIT_INT"]),
~[e_i64, e_ity]);
}
@ -494,21 +494,21 @@ fn mk_token(cx: @ExtCtxt, sp: span, tok: &token::Token) -> @ast::expr {
ast::ty_u64 => ~"ty_u64"
};
let e_uty =
build::mk_path(cx, sp,
cx.mk_path(sp,
ids_ext(cx, ~[s_uty]));
let e_u64 = build::mk_lit(cx, sp, ast::lit_uint(u, ast::ty_u64));
let e_u64 = cx.mk_lit(sp, ast::lit_uint(u, ast::ty_u64));
return build::mk_call(cx, sp,
return cx.mk_call(sp,
ids_ext(cx, ~[~"LIT_UINT"]),
~[e_u64, e_uty]);
}
LIT_INT_UNSUFFIXED(i) => {
let e_i64 = build::mk_lit(cx, sp,
let e_i64 = cx.mk_lit(sp,
ast::lit_int(i, ast::ty_i64));
return build::mk_call(cx, sp,
return cx.mk_call(sp,
ids_ext(cx, ~[~"LIT_INT_UNSUFFIXED"]),
~[e_i64]);
}
@ -520,37 +520,37 @@ fn mk_token(cx: @ExtCtxt, sp: span, tok: &token::Token) -> @ast::expr {
ast::ty_f64 => ~"ty_f64"
};
let e_fty =
build::mk_path(cx, sp,
cx.mk_path(sp,
ids_ext(cx, ~[s_fty]));
let e_fident = mk_ident(cx, sp, fident);
return build::mk_call(cx, sp,
return cx.mk_call(sp,
ids_ext(cx, ~[~"LIT_FLOAT"]),
~[e_fident, e_fty]);
}
LIT_STR(ident) => {
return build::mk_call(cx, sp,
return cx.mk_call(sp,
ids_ext(cx, ~[~"LIT_STR"]),
~[mk_ident(cx, sp, ident)]);
}
IDENT(ident, b) => {
return build::mk_call(cx, sp,
return cx.mk_call(sp,
ids_ext(cx, ~[~"IDENT"]),
~[mk_ident(cx, sp, ident),
build::mk_lit(cx, sp, ast::lit_bool(b))]);
cx.mk_lit(sp, ast::lit_bool(b))]);
}
LIFETIME(ident) => {
return build::mk_call(cx, sp,
return cx.mk_call(sp,
ids_ext(cx, ~[~"LIFETIME"]),
~[mk_ident(cx, sp, ident)]);
}
DOC_COMMENT(ident) => {
return build::mk_call(cx, sp,
return cx.mk_call(sp,
ids_ext(cx, ~[~"DOC_COMMENT"]),
~[mk_ident(cx, sp, ident)]);
}
@ -595,7 +595,7 @@ fn mk_token(cx: @ExtCtxt, sp: span, tok: &token::Token) -> @ast::expr {
EOF => "EOF",
_ => fail!()
};
build::mk_path(cx, sp,
cx.mk_path(sp,
ids_ext(cx, ~[name.to_owned()]))
}
@ -606,18 +606,18 @@ fn mk_tt(cx: @ExtCtxt, sp: span, tt: &ast::token_tree)
match *tt {
ast::tt_tok(sp, ref tok) => {
let e_sp = build::mk_path(cx, sp,
let e_sp = cx.mk_path(sp,
ids_ext(cx, ~[~"sp"]));
let e_tok =
build::mk_call(cx, sp,
cx.mk_call(sp,
ids_ext(cx, ~[~"tt_tok"]),
~[e_sp, mk_token(cx, sp, tok)]);
let e_push =
build::mk_method_call(cx, sp,
build::mk_path(cx, sp, ids_ext(cx, ~[~"tt"])),
cx.mk_method_call(sp,
cx.mk_path(sp, ids_ext(cx, ~[~"tt"])),
id_ext(cx, "push"),
~[e_tok]);
~[build::mk_stmt(cx, sp, e_push)]
~[cx.mk_stmt(sp, e_push)]
}
@ -629,19 +629,19 @@ fn mk_tt(cx: @ExtCtxt, sp: span, tt: &ast::token_tree)
// tt.push_all_move($ident.to_tokens(ext_cx))
let e_to_toks =
build::mk_method_call(cx, sp,
build::mk_path(cx, sp, ~[ident]),
cx.mk_method_call(sp,
cx.mk_path(sp, ~[ident]),
id_ext(cx, "to_tokens"),
~[build::mk_path(cx, sp,
~[cx.mk_path(sp,
ids_ext(cx, ~[~"ext_cx"]))]);
let e_push =
build::mk_method_call(cx, sp,
build::mk_path(cx, sp, ids_ext(cx, ~[~"tt"])),
cx.mk_method_call(sp,
cx.mk_path(sp, ids_ext(cx, ~[~"tt"])),
id_ext(cx, "push_all_move"),
~[e_to_toks]);
~[build::mk_stmt(cx, sp, e_push)]
~[cx.mk_stmt(sp, e_push)]
}
}
}
@ -677,11 +677,11 @@ fn expand_tts(cx: @ExtCtxt,
// We want to emit a block expression that does a sequence of 'use's to
// import the runtime module, followed by a tt-building expression.
let uses = ~[ build::mk_glob_use(cx, sp, ast::public,
ids_ext(cx, ~[~"syntax",
~"ext",
~"quote",
~"rt"])) ];
let uses = ~[ cx.mk_glob_use(sp, ast::public,
ids_ext(cx, ~[~"syntax",
~"ext",
~"quote",
~"rt"])) ];
// We also bind a single value, sp, to ext_cx.call_site()
//
@ -709,23 +709,23 @@ fn expand_tts(cx: @ExtCtxt,
// of quotes, for example) but at this point it seems not likely to be
// worth the hassle.
let e_sp = build::mk_method_call(cx, sp,
build::mk_path(cx, sp, ids_ext(cx, ~[~"ext_cx"])),
let e_sp = cx.mk_method_call(sp,
cx.mk_path(sp, ids_ext(cx, ~[~"ext_cx"])),
id_ext(cx, "call_site"),
~[]);
let stmt_let_sp = build::mk_local(cx, sp, false,
let stmt_let_sp = cx.mk_local(sp, false,
id_ext(cx, "sp"),
e_sp);
let stmt_let_tt = build::mk_local(cx, sp, true,
let stmt_let_tt = cx.mk_local(sp, true,
id_ext(cx, "tt"),
build::mk_uniq_vec_e(cx, sp, ~[]));
cx.mk_uniq_vec_e(sp, ~[]));
build::mk_block(cx, sp, uses,
cx.mk_block(sp, uses,
~[stmt_let_sp,
stmt_let_tt] + mk_tts(cx, sp, tts),
Some(build::mk_path(cx, sp,
Some(cx.mk_path(sp,
ids_ext(cx, ~[~"tt"]))))
}
@ -736,16 +736,16 @@ fn expand_parse_call(cx: @ExtCtxt,
tts: &[ast::token_tree]) -> @ast::expr {
let tts_expr = expand_tts(cx, sp, tts);
let cfg_call = || build::mk_method_call(
cx, sp, build::mk_path(cx, sp, ids_ext(cx, ~[~"ext_cx"])),
let cfg_call = || cx.mk_method_call(
sp, cx.mk_path(sp, ids_ext(cx, ~[~"ext_cx"])),
id_ext(cx, "cfg"), ~[]);
let parse_sess_call = || build::mk_method_call(
cx, sp, build::mk_path(cx, sp, ids_ext(cx, ~[~"ext_cx"])),
let parse_sess_call = || cx.mk_method_call(
sp, cx.mk_path(sp, ids_ext(cx, ~[~"ext_cx"])),
id_ext(cx, "parse_sess"), ~[]);
let new_parser_call =
build::mk_call_global(cx, sp,
cx.mk_call_global(sp,
ids_ext(cx, ~[~"syntax",
~"ext",
~"quote",
@ -755,7 +755,7 @@ fn expand_parse_call(cx: @ExtCtxt,
cfg_call(),
tts_expr]);
build::mk_method_call(cx, sp,
cx.mk_method_call(sp,
new_parser_call,
id_ext(cx, parse_method),
arg_exprs)

View File

@ -14,7 +14,7 @@ use codemap::{FileMap, Loc, Pos, ExpandedFrom, span};
use codemap::{CallInfo, NameAndSpan};
use ext::base::*;
use ext::base;
use ext::build::{mk_base_vec_e, mk_uint, mk_u8, mk_base_str};
use ext::build::AstBuilder;
use parse;
use print::pprust;
@ -30,7 +30,7 @@ pub fn expand_line(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
let topmost = topmost_expn_info(cx.backtrace().get());
let loc = cx.codemap().lookup_char_pos(topmost.call_site.lo);
base::MRExpr(mk_uint(cx, topmost.call_site, loc.line))
base::MRExpr(cx.mk_uint(topmost.call_site, loc.line))
}
/* col!(): expands to the current column number */
@ -40,7 +40,7 @@ pub fn expand_col(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
let topmost = topmost_expn_info(cx.backtrace().get());
let loc = cx.codemap().lookup_char_pos(topmost.call_site.lo);
base::MRExpr(mk_uint(cx, topmost.call_site, loc.col.to_uint()))
base::MRExpr(cx.mk_uint(topmost.call_site, loc.col.to_uint()))
}
/* file!(): expands to the current filename */
@ -53,19 +53,19 @@ pub fn expand_file(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
let topmost = topmost_expn_info(cx.backtrace().get());
let Loc { file: @FileMap { name: filename, _ }, _ } =
cx.codemap().lookup_char_pos(topmost.call_site.lo);
base::MRExpr(mk_base_str(cx, topmost.call_site, filename))
base::MRExpr(cx.mk_base_str(topmost.call_site, filename))
}
pub fn expand_stringify(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
let s = pprust::tts_to_str(tts, cx.parse_sess().interner);
base::MRExpr(mk_base_str(cx, sp, s))
base::MRExpr(cx.mk_base_str(sp, s))
}
pub fn expand_mod(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
base::check_zero_tts(cx, sp, tts, "module_path!");
base::MRExpr(mk_base_str(cx, sp,
base::MRExpr(cx.mk_base_str(sp,
str::connect(cx.mod_path().map(
|x| cx.str_of(*x)), "::")))
}
@ -94,7 +94,7 @@ pub fn expand_include_str(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
}
}
base::MRExpr(mk_base_str(cx, sp, result::unwrap(res)))
base::MRExpr(cx.mk_base_str(sp, result::unwrap(res)))
}
pub fn expand_include_bin(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
@ -103,9 +103,9 @@ pub fn expand_include_bin(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
match io::read_whole_file(&res_rel_file(cx, sp, &Path(file))) {
result::Ok(src) => {
let u8_exprs = vec::map(src, |char| {
mk_u8(cx, sp, *char)
cx.mk_u8(sp, *char)
});
base::MRExpr(mk_base_vec_e(cx, sp, u8_exprs))
base::MRExpr(cx.mk_base_vec_e(sp, u8_exprs))
}
result::Err(ref e) => {
cx.parse_sess().span_diagnostic.handler().fatal((*e))