wip
This commit is contained in:
parent
e16dbb7888
commit
ca49fd402a
23 changed files with 93 additions and 97 deletions
|
@ -40,15 +40,15 @@ pub extern mod c_double {
|
||||||
#[link_name="fmax"] pure fn fmax(a: c_double, b: c_double) -> c_double;
|
#[link_name="fmax"] pure fn fmax(a: c_double, b: c_double) -> c_double;
|
||||||
#[link_name="fmin"] pure fn fmin(a: c_double, b: c_double) -> c_double;
|
#[link_name="fmin"] pure fn fmin(a: c_double, b: c_double) -> c_double;
|
||||||
pure fn nextafter(x: c_double, y: c_double) -> c_double;
|
pure fn nextafter(x: c_double, y: c_double) -> c_double;
|
||||||
pure fn frexp(n: c_double, &value: c_int) -> c_double;
|
pure fn frexp(n: c_double, value: &mut c_int) -> c_double;
|
||||||
pure fn hypot(x: c_double, y: c_double) -> c_double;
|
pure fn hypot(x: c_double, y: c_double) -> c_double;
|
||||||
pure fn ldexp(x: c_double, n: c_int) -> c_double;
|
pure fn ldexp(x: c_double, n: c_int) -> c_double;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[link_name="lgamma_r"] pure fn lgamma(n: c_double,
|
#[link_name="lgamma_r"] pure fn lgamma(n: c_double,
|
||||||
&sign: c_int) -> c_double;
|
sign: &mut c_int) -> c_double;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[link_name="__lgamma_r"] pure fn lgamma(n: c_double,
|
#[link_name="__lgamma_r"] pure fn lgamma(n: c_double,
|
||||||
&sign: c_int) -> c_double;
|
sign: &mut c_int) -> c_double;
|
||||||
// renamed: log is a reserved keyword; ln seems more natural, too
|
// renamed: log is a reserved keyword; ln seems more natural, too
|
||||||
#[link_name="log"] pure fn ln(n: c_double) -> c_double;
|
#[link_name="log"] pure fn ln(n: c_double) -> c_double;
|
||||||
// renamed: "logb" /often/ is confused for log2 by beginners
|
// renamed: "logb" /often/ is confused for log2 by beginners
|
||||||
|
@ -58,7 +58,7 @@ pub extern mod c_double {
|
||||||
pure fn log10(n: c_double) -> c_double;
|
pure fn log10(n: c_double) -> c_double;
|
||||||
pure fn log2(n: c_double) -> c_double;
|
pure fn log2(n: c_double) -> c_double;
|
||||||
#[link_name="ilogb"] pure fn ilog_radix(n: c_double) -> c_int;
|
#[link_name="ilogb"] pure fn ilog_radix(n: c_double) -> c_int;
|
||||||
pure fn modf(n: c_double, &iptr: c_double) -> c_double;
|
pure fn modf(n: c_double, iptr: &mut c_double) -> c_double;
|
||||||
pure fn pow(n: c_double, e: c_double) -> c_double;
|
pure fn pow(n: c_double, e: c_double) -> c_double;
|
||||||
// FIXME (#1379): enable when rounding modes become available
|
// FIXME (#1379): enable when rounding modes become available
|
||||||
// pure fn rint(n: c_double) -> c_double;
|
// pure fn rint(n: c_double) -> c_double;
|
||||||
|
@ -110,7 +110,7 @@ pub extern mod c_float {
|
||||||
#[link_name="fdimf"] pure fn abs_sub(a: c_float, b: c_float) -> c_float;
|
#[link_name="fdimf"] pure fn abs_sub(a: c_float, b: c_float) -> c_float;
|
||||||
#[link_name="floorf"] pure fn floor(n: c_float) -> c_float;
|
#[link_name="floorf"] pure fn floor(n: c_float) -> c_float;
|
||||||
#[link_name="frexpf"] pure fn frexp(n: c_float,
|
#[link_name="frexpf"] pure fn frexp(n: c_float,
|
||||||
&value: c_int) -> c_float;
|
value: &mut c_int) -> c_float;
|
||||||
#[link_name="fmaf"] pure fn mul_add(a: c_float,
|
#[link_name="fmaf"] pure fn mul_add(a: c_float,
|
||||||
b: c_float, c: c_float) -> c_float;
|
b: c_float, c: c_float) -> c_float;
|
||||||
#[link_name="fmaxf"] pure fn fmax(a: c_float, b: c_float) -> c_float;
|
#[link_name="fmaxf"] pure fn fmax(a: c_float, b: c_float) -> c_float;
|
||||||
|
@ -122,11 +122,11 @@ pub extern mod c_float {
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[link_name="lgammaf_r"] pure fn lgamma(n: c_float,
|
#[link_name="lgammaf_r"] pure fn lgamma(n: c_float,
|
||||||
&sign: c_int) -> c_float;
|
sign: &mut c_int) -> c_float;
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[link_name="__lgammaf_r"] pure fn lgamma(n: c_float,
|
#[link_name="__lgammaf_r"] pure fn lgamma(n: c_float,
|
||||||
&sign: c_int) -> c_float;
|
sign: &mut c_int) -> c_float;
|
||||||
|
|
||||||
#[link_name="logf"] pure fn ln(n: c_float) -> c_float;
|
#[link_name="logf"] pure fn ln(n: c_float) -> c_float;
|
||||||
#[link_name="logbf"] pure fn log_radix(n: c_float) -> c_float;
|
#[link_name="logbf"] pure fn log_radix(n: c_float) -> c_float;
|
||||||
|
@ -135,7 +135,7 @@ pub extern mod c_float {
|
||||||
#[link_name="log10f"] pure fn log10(n: c_float) -> c_float;
|
#[link_name="log10f"] pure fn log10(n: c_float) -> c_float;
|
||||||
#[link_name="ilogbf"] pure fn ilog_radix(n: c_float) -> c_int;
|
#[link_name="ilogbf"] pure fn ilog_radix(n: c_float) -> c_int;
|
||||||
#[link_name="modff"] pure fn modf(n: c_float,
|
#[link_name="modff"] pure fn modf(n: c_float,
|
||||||
&iptr: c_float) -> c_float;
|
iptr: &mut c_float) -> c_float;
|
||||||
#[link_name="powf"] pure fn pow(n: c_float, e: c_float) -> c_float;
|
#[link_name="powf"] pure fn pow(n: c_float, e: c_float) -> c_float;
|
||||||
// FIXME (#1379): enable when rounding modes become available
|
// FIXME (#1379): enable when rounding modes become available
|
||||||
// #[link_name="rintf"] pure fn rint(n: c_float) -> c_float;
|
// #[link_name="rintf"] pure fn rint(n: c_float) -> c_float;
|
||||||
|
|
|
@ -7,9 +7,18 @@ use result::{Result, Ok, Err};
|
||||||
|
|
||||||
#[abi = "cdecl"]
|
#[abi = "cdecl"]
|
||||||
extern mod rustrt {
|
extern mod rustrt {
|
||||||
#[legacy_exports];
|
#[legacy_exports]
|
||||||
|
#[cfg(stage0)]
|
||||||
fn get_time(&sec: i64, &nsec: i32);
|
fn get_time(&sec: i64, &nsec: i32);
|
||||||
|
#[cfg(stage1)]
|
||||||
|
#[cfg(stage2)]
|
||||||
|
fn get_time(sec: &mut i64, nsec: &mut i32);
|
||||||
|
|
||||||
|
#[cfg(stage0)]
|
||||||
fn precise_time_ns(&ns: u64);
|
fn precise_time_ns(&ns: u64);
|
||||||
|
#[cfg(stage1)]
|
||||||
|
#[cfg(stage2)]
|
||||||
|
fn precise_time_ns(ns: &mut u64);
|
||||||
|
|
||||||
fn rust_tzset();
|
fn rust_tzset();
|
||||||
// FIXME: The i64 values can be passed by-val when #2064 is fixed.
|
// FIXME: The i64 values can be passed by-val when #2064 is fixed.
|
||||||
|
@ -33,22 +42,41 @@ impl Timespec : Eq {
|
||||||
* Returns the current time as a `timespec` containing the seconds and
|
* Returns the current time as a `timespec` containing the seconds and
|
||||||
* nanoseconds since 1970-01-01T00:00:00Z.
|
* nanoseconds since 1970-01-01T00:00:00Z.
|
||||||
*/
|
*/
|
||||||
|
#[cfg(stage0)]
|
||||||
pub fn get_time() -> Timespec {
|
pub fn get_time() -> Timespec {
|
||||||
let mut sec = 0i64;
|
let mut sec = 0i64;
|
||||||
let mut nsec = 0i32;
|
let mut nsec = 0i32;
|
||||||
rustrt::get_time(sec, nsec);
|
rustrt::get_time(sec, nsec);
|
||||||
return {sec: sec, nsec: nsec};
|
return {sec: sec, nsec: nsec};
|
||||||
}
|
}
|
||||||
|
#[cfg(stage1)]
|
||||||
|
#[cfg(stage2)]
|
||||||
|
pub fn get_time() -> Timespec {
|
||||||
|
let mut sec = 0i64;
|
||||||
|
let mut nsec = 0i32;
|
||||||
|
rustrt::get_time(&mut sec, &mut nsec);
|
||||||
|
return {sec: sec, nsec: nsec};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current value of a high-resolution performance counter
|
* Returns the current value of a high-resolution performance counter
|
||||||
* in nanoseconds since an unspecified epoch.
|
* in nanoseconds since an unspecified epoch.
|
||||||
*/
|
*/
|
||||||
|
#[cfg(stage0)]
|
||||||
pub fn precise_time_ns() -> u64 {
|
pub fn precise_time_ns() -> u64 {
|
||||||
let mut ns = 0u64;
|
let mut ns = 0u64;
|
||||||
rustrt::precise_time_ns(ns);
|
rustrt::precise_time_ns(ns);
|
||||||
ns
|
ns
|
||||||
}
|
}
|
||||||
|
#[cfg(stage1)]
|
||||||
|
#[cfg(stage2)]
|
||||||
|
pub fn precise_time_ns() -> u64 {
|
||||||
|
let mut ns = 0u64;
|
||||||
|
rustrt::precise_time_ns(&mut ns);
|
||||||
|
ns
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current value of a high-resolution performance counter
|
* Returns the current value of a high-resolution performance counter
|
||||||
|
|
|
@ -574,7 +574,7 @@ impl<T:cmp::Eq> inferable<T> : cmp::Eq {
|
||||||
|
|
||||||
// "resolved" mode: the real modes.
|
// "resolved" mode: the real modes.
|
||||||
#[auto_serialize]
|
#[auto_serialize]
|
||||||
enum rmode { by_ref, by_val, by_mutbl_ref, by_move, by_copy }
|
enum rmode { by_ref, by_val, by_move, by_copy }
|
||||||
|
|
||||||
impl rmode : to_bytes::IterBytes {
|
impl rmode : to_bytes::IterBytes {
|
||||||
pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
|
pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {
|
||||||
|
|
|
@ -127,14 +127,14 @@ fn consume_non_eol_whitespace(rdr: string_reader) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn push_blank_line_comment(rdr: string_reader, &comments: ~[cmnt]) {
|
fn push_blank_line_comment(rdr: string_reader, comments: &mut ~[cmnt]) {
|
||||||
debug!(">>> blank-line comment");
|
debug!(">>> blank-line comment");
|
||||||
let v: ~[~str] = ~[];
|
let v: ~[~str] = ~[];
|
||||||
comments.push({style: blank_line, lines: v, pos: rdr.chpos});
|
comments.push({style: blank_line, lines: v, pos: rdr.chpos});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn consume_whitespace_counting_blank_lines(rdr: string_reader,
|
fn consume_whitespace_counting_blank_lines(rdr: string_reader,
|
||||||
&comments: ~[cmnt]) {
|
comments: &mut ~[cmnt]) {
|
||||||
while is_whitespace(rdr.curr) && !is_eof(rdr) {
|
while is_whitespace(rdr.curr) && !is_eof(rdr) {
|
||||||
if rdr.col == 0u && rdr.curr == '\n' {
|
if rdr.col == 0u && rdr.curr == '\n' {
|
||||||
push_blank_line_comment(rdr, comments);
|
push_blank_line_comment(rdr, comments);
|
||||||
|
@ -145,7 +145,7 @@ fn consume_whitespace_counting_blank_lines(rdr: string_reader,
|
||||||
|
|
||||||
|
|
||||||
fn read_shebang_comment(rdr: string_reader, code_to_the_left: bool,
|
fn read_shebang_comment(rdr: string_reader, code_to_the_left: bool,
|
||||||
&comments: ~[cmnt]) {
|
comments: &mut ~[cmnt]) {
|
||||||
debug!(">>> shebang comment");
|
debug!(">>> shebang comment");
|
||||||
let p = rdr.chpos;
|
let p = rdr.chpos;
|
||||||
debug!("<<< shebang comment");
|
debug!("<<< shebang comment");
|
||||||
|
@ -157,7 +157,7 @@ fn read_shebang_comment(rdr: string_reader, code_to_the_left: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_line_comments(rdr: string_reader, code_to_the_left: bool,
|
fn read_line_comments(rdr: string_reader, code_to_the_left: bool,
|
||||||
&comments: ~[cmnt]) {
|
comments: &mut ~[cmnt]) {
|
||||||
debug!(">>> line comments");
|
debug!(">>> line comments");
|
||||||
let p = rdr.chpos;
|
let p = rdr.chpos;
|
||||||
let mut lines: ~[~str] = ~[];
|
let mut lines: ~[~str] = ~[];
|
||||||
|
@ -188,8 +188,8 @@ fn all_whitespace(s: ~str, begin: uint, end: uint) -> bool {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trim_whitespace_prefix_and_push_line(&lines: ~[~str],
|
fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str],
|
||||||
s: ~str, col: uint) unsafe {
|
s: ~str, col: uint) {
|
||||||
let mut s1;
|
let mut s1;
|
||||||
let len = str::len(s);
|
let len = str::len(s);
|
||||||
if all_whitespace(s, 0u, uint::min(len, col)) {
|
if all_whitespace(s, 0u, uint::min(len, col)) {
|
||||||
|
@ -202,7 +202,7 @@ fn trim_whitespace_prefix_and_push_line(&lines: ~[~str],
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
|
fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
|
||||||
&comments: ~[cmnt]) {
|
comments: &mut ~[cmnt]) {
|
||||||
debug!(">>> block comment");
|
debug!(">>> block comment");
|
||||||
let p = rdr.chpos;
|
let p = rdr.chpos;
|
||||||
let mut lines: ~[~str] = ~[];
|
let mut lines: ~[~str] = ~[];
|
||||||
|
@ -228,7 +228,7 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
|
||||||
debug!("=== block comment level %d", level);
|
debug!("=== block comment level %d", level);
|
||||||
if is_eof(rdr) {(rdr as reader).fatal(~"unterminated block comment");}
|
if is_eof(rdr) {(rdr as reader).fatal(~"unterminated block comment");}
|
||||||
if rdr.curr == '\n' {
|
if rdr.curr == '\n' {
|
||||||
trim_whitespace_prefix_and_push_line(lines, curr_line, col);
|
trim_whitespace_prefix_and_push_line(&mut lines, curr_line, col);
|
||||||
curr_line = ~"";
|
curr_line = ~"";
|
||||||
bump(rdr);
|
bump(rdr);
|
||||||
} else {
|
} else {
|
||||||
|
@ -248,8 +248,8 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if str::len(curr_line) != 0u {
|
if str::len(curr_line) != 0 {
|
||||||
trim_whitespace_prefix_and_push_line(lines, curr_line, col);
|
trim_whitespace_prefix_and_push_line(&mut lines, curr_line, col);
|
||||||
}
|
}
|
||||||
let mut style = if code_to_the_left { trailing } else { isolated };
|
let mut style = if code_to_the_left { trailing } else { isolated };
|
||||||
consume_non_eol_whitespace(rdr);
|
consume_non_eol_whitespace(rdr);
|
||||||
|
@ -267,7 +267,7 @@ fn peeking_at_comment(rdr: string_reader) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn consume_comment(rdr: string_reader, code_to_the_left: bool,
|
fn consume_comment(rdr: string_reader, code_to_the_left: bool,
|
||||||
&comments: ~[cmnt]) {
|
comments: &mut ~[cmnt]) {
|
||||||
debug!(">>> consume comment");
|
debug!(">>> consume comment");
|
||||||
if rdr.curr == '/' && nextch(rdr) == '/' {
|
if rdr.curr == '/' && nextch(rdr) == '/' {
|
||||||
read_line_comments(rdr, code_to_the_left, comments);
|
read_line_comments(rdr, code_to_the_left, comments);
|
||||||
|
@ -299,11 +299,11 @@ fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler,
|
||||||
consume_non_eol_whitespace(rdr);
|
consume_non_eol_whitespace(rdr);
|
||||||
if rdr.curr == '\n' {
|
if rdr.curr == '\n' {
|
||||||
code_to_the_left = false;
|
code_to_the_left = false;
|
||||||
consume_whitespace_counting_blank_lines(rdr, comments);
|
consume_whitespace_counting_blank_lines(rdr, &mut comments);
|
||||||
}
|
}
|
||||||
while peeking_at_comment(rdr) {
|
while peeking_at_comment(rdr) {
|
||||||
consume_comment(rdr, code_to_the_left, comments);
|
consume_comment(rdr, code_to_the_left, &mut comments);
|
||||||
consume_whitespace_counting_blank_lines(rdr, comments);
|
consume_whitespace_counting_blank_lines(rdr, &mut comments);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@ type ctx =
|
||||||
fn eval_crate_directives(cx: ctx,
|
fn eval_crate_directives(cx: ctx,
|
||||||
cdirs: ~[@ast::crate_directive],
|
cdirs: ~[@ast::crate_directive],
|
||||||
prefix: &Path,
|
prefix: &Path,
|
||||||
&view_items: ~[@ast::view_item],
|
view_items: &mut~[@ast::view_item],
|
||||||
&items: ~[@ast::item]) {
|
items: &mut~[@ast::item]) {
|
||||||
for cdirs.each |sub_cdir| {
|
for cdirs.each |sub_cdir| {
|
||||||
eval_crate_directive(cx, *sub_cdir, prefix, view_items, items);
|
eval_crate_directive(cx, *sub_cdir, prefix, view_items, items);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ fn eval_crate_directives_to_mod(cx: ctx, cdirs: ~[@ast::crate_directive],
|
||||||
= parse_companion_mod(cx, prefix, suffix);
|
= parse_companion_mod(cx, prefix, suffix);
|
||||||
let mut view_items: ~[@ast::view_item] = ~[];
|
let mut view_items: ~[@ast::view_item] = ~[];
|
||||||
let mut items: ~[@ast::item] = ~[];
|
let mut items: ~[@ast::item] = ~[];
|
||||||
eval_crate_directives(cx, cdirs, prefix, view_items, items);
|
eval_crate_directives(cx, cdirs, prefix, &mut view_items, &mut items);
|
||||||
return ({view_items: vec::append(view_items, cview_items),
|
return ({view_items: vec::append(view_items, cview_items),
|
||||||
items: vec::append(items, citems)},
|
items: vec::append(items, citems)},
|
||||||
cattrs);
|
cattrs);
|
||||||
|
@ -82,8 +82,8 @@ fn cdir_path_opt(default: ~str, attrs: ~[ast::attribute]) -> ~str {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: &Path,
|
fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: &Path,
|
||||||
&view_items: ~[@ast::view_item],
|
view_items: &mut ~[@ast::view_item],
|
||||||
&items: ~[@ast::item]) {
|
items: &mut ~[@ast::item]) {
|
||||||
match cdir.node {
|
match cdir.node {
|
||||||
ast::cdir_src_mod(vis, id, attrs) => {
|
ast::cdir_src_mod(vis, id, attrs) => {
|
||||||
let file_path = Path(cdir_path_opt(
|
let file_path = Path(cdir_path_opt(
|
||||||
|
|
|
@ -26,7 +26,7 @@ use ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute,
|
||||||
bind_by_ref, bind_by_implicit_ref, bind_by_value, bind_by_move,
|
bind_by_ref, bind_by_implicit_ref, bind_by_value, bind_by_move,
|
||||||
bitand, bitor, bitxor, blk, blk_check_mode, bound_const,
|
bitand, bitor, bitxor, blk, blk_check_mode, bound_const,
|
||||||
bound_copy, bound_send, bound_trait, bound_owned, box, by_copy,
|
bound_copy, bound_send, bound_trait, bound_owned, box, by_copy,
|
||||||
by_move, by_mutbl_ref, by_ref, by_val, capture_clause,
|
by_move, by_ref, by_val, capture_clause,
|
||||||
capture_item, cdir_dir_mod, cdir_src_mod, cdir_view_item,
|
capture_item, cdir_dir_mod, cdir_src_mod, cdir_view_item,
|
||||||
class_immutable, class_mutable,
|
class_immutable, class_mutable,
|
||||||
crate, crate_cfg, crate_directive, decl, decl_item, decl_local,
|
crate, crate_cfg, crate_directive, decl, decl_item, decl_local,
|
||||||
|
@ -571,7 +571,7 @@ impl parser {
|
||||||
fn parse_arg_mode() -> mode {
|
fn parse_arg_mode() -> mode {
|
||||||
if self.eat(token::BINOP(token::AND)) {
|
if self.eat(token::BINOP(token::AND)) {
|
||||||
self.warn(~"Obsolete syntax has no effect");
|
self.warn(~"Obsolete syntax has no effect");
|
||||||
expl(by_mutbl_ref)
|
expl(by_val)
|
||||||
} else if self.eat(token::BINOP(token::MINUS)) {
|
} else if self.eat(token::BINOP(token::MINUS)) {
|
||||||
expl(by_move)
|
expl(by_move)
|
||||||
} else if self.eat(token::ANDAND) {
|
} else if self.eat(token::ANDAND) {
|
||||||
|
@ -1276,7 +1276,8 @@ impl parser {
|
||||||
|
|
||||||
return match self.token {
|
return match self.token {
|
||||||
token::LPAREN | token::LBRACE | token::LBRACKET => {
|
token::LPAREN | token::LBRACE | token::LBRACKET => {
|
||||||
let ket = token::flip_delimiter(self.token);
|
// tjc: ??????
|
||||||
|
let ket = token::flip_delimiter(copy self.token);
|
||||||
tt_delim(vec::append(
|
tt_delim(vec::append(
|
||||||
~[parse_tt_tok(self, true)],
|
~[parse_tt_tok(self, true)],
|
||||||
vec::append(
|
vec::append(
|
||||||
|
@ -1297,7 +1298,8 @@ impl parser {
|
||||||
return match self.token {
|
return match self.token {
|
||||||
token::LBRACE | token::LPAREN | token::LBRACKET => {
|
token::LBRACE | token::LPAREN | token::LBRACKET => {
|
||||||
self.parse_matcher_subseq(name_idx, copy self.token,
|
self.parse_matcher_subseq(name_idx, copy self.token,
|
||||||
token::flip_delimiter(self.token))
|
// tjc: not sure why we need a copy
|
||||||
|
token::flip_delimiter(copy self.token))
|
||||||
}
|
}
|
||||||
_ => self.fatal(~"expected open delimiter")
|
_ => self.fatal(~"expected open delimiter")
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,7 +230,7 @@ pure fn can_begin_expr(t: token) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// what's the opposite delimiter?
|
/// what's the opposite delimiter?
|
||||||
fn flip_delimiter(&t: token::token) -> token::token {
|
fn flip_delimiter(t: token::token) -> token::token {
|
||||||
match t {
|
match t {
|
||||||
token::LPAREN => token::RPAREN,
|
token::LPAREN => token::RPAREN,
|
||||||
token::LBRACE => token::RBRACE,
|
token::LBRACE => token::RBRACE,
|
||||||
|
|
|
@ -1688,7 +1688,6 @@ fn print_fn_block_args(s: ps, decl: ast::fn_decl,
|
||||||
|
|
||||||
fn mode_to_str(m: ast::mode) -> ~str {
|
fn mode_to_str(m: ast::mode) -> ~str {
|
||||||
match m {
|
match m {
|
||||||
ast::expl(ast::by_mutbl_ref) => ~"&",
|
|
||||||
ast::expl(ast::by_move) => ~"-",
|
ast::expl(ast::by_move) => ~"-",
|
||||||
ast::expl(ast::by_ref) => ~"&&",
|
ast::expl(ast::by_ref) => ~"&&",
|
||||||
ast::expl(ast::by_val) => ~"++",
|
ast::expl(ast::by_val) => ~"++",
|
||||||
|
|
|
@ -116,7 +116,7 @@ fn encode_mutability(ebml_w: ebml::Writer, mt: class_mutability) {
|
||||||
type entry<T> = {val: T, pos: uint};
|
type entry<T> = {val: T, pos: uint};
|
||||||
|
|
||||||
fn add_to_index(ecx: @encode_ctxt, ebml_w: ebml::Writer, path: &[ident],
|
fn add_to_index(ecx: @encode_ctxt, ebml_w: ebml::Writer, path: &[ident],
|
||||||
&index: ~[entry<~str>], name: ident) {
|
index: &mut ~[entry<~str>], name: ident) {
|
||||||
let mut full_path = ~[];
|
let mut full_path = ~[];
|
||||||
full_path.push_all(path);
|
full_path.push_all(path);
|
||||||
full_path.push(name);
|
full_path.push(name);
|
||||||
|
|
|
@ -394,7 +394,6 @@ fn parse_arg(st: @pstate, conv: conv_did) -> ty::arg {
|
||||||
|
|
||||||
fn parse_mode(st: @pstate) -> ast::mode {
|
fn parse_mode(st: @pstate) -> ast::mode {
|
||||||
let m = ast::expl(match next(st) {
|
let m = ast::expl(match next(st) {
|
||||||
'&' => ast::by_mutbl_ref,
|
|
||||||
'-' => ast::by_move,
|
'-' => ast::by_move,
|
||||||
'+' => ast::by_copy,
|
'+' => ast::by_copy,
|
||||||
'=' => ast::by_ref,
|
'=' => ast::by_ref,
|
||||||
|
|
|
@ -332,7 +332,6 @@ fn enc_arg(w: io::Writer, cx: @ctxt, arg: ty::arg) {
|
||||||
|
|
||||||
fn enc_mode(w: io::Writer, cx: @ctxt, m: mode) {
|
fn enc_mode(w: io::Writer, cx: @ctxt, m: mode) {
|
||||||
match ty::resolved_mode(cx.tcx, m) {
|
match ty::resolved_mode(cx.tcx, m) {
|
||||||
by_mutbl_ref => w.write_char('&'),
|
|
||||||
by_move => w.write_char('-'),
|
by_move => w.write_char('-'),
|
||||||
by_copy => w.write_char('+'),
|
by_copy => w.write_char('+'),
|
||||||
by_ref => w.write_char('='),
|
by_ref => w.write_char('='),
|
||||||
|
|
|
@ -396,10 +396,10 @@ type req_maps = {
|
||||||
pure_map: HashMap<ast::node_id, bckerr>
|
pure_map: HashMap<ast::node_id, bckerr>
|
||||||
};
|
};
|
||||||
|
|
||||||
fn save_and_restore<T:Copy,U>(&save_and_restore_t: T, f: fn() -> U) -> U {
|
fn save_and_restore<T:Copy,U>(save_and_restore_t: &mut T, f: fn() -> U) -> U {
|
||||||
let old_save_and_restore_t = save_and_restore_t;
|
let old_save_and_restore_t = *save_and_restore_t;
|
||||||
let u <- f();
|
let u <- f();
|
||||||
save_and_restore_t = old_save_and_restore_t;
|
*save_and_restore_t = old_save_and_restore_t;
|
||||||
move u
|
move u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -529,8 +529,7 @@ impl check_loan_ctxt {
|
||||||
ast::by_move => {
|
ast::by_move => {
|
||||||
self.check_move_out(*arg);
|
self.check_move_out(*arg);
|
||||||
}
|
}
|
||||||
ast::by_mutbl_ref | ast::by_ref |
|
ast::by_ref | ast::by_copy | ast::by_val => {
|
||||||
ast::by_copy | ast::by_val => {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -542,9 +541,9 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
|
||||||
visitor: visit::vt<check_loan_ctxt>) {
|
visitor: visit::vt<check_loan_ctxt>) {
|
||||||
|
|
||||||
debug!("purity on entry=%?", copy self.declared_purity);
|
debug!("purity on entry=%?", copy self.declared_purity);
|
||||||
do save_and_restore(self.in_ctor) {
|
do save_and_restore(&mut(self.in_ctor)) {
|
||||||
do save_and_restore(self.declared_purity) {
|
do save_and_restore(&mut(self.declared_purity)) {
|
||||||
do save_and_restore(self.fn_args) {
|
do save_and_restore(&mut(self.fn_args)) {
|
||||||
let is_stack_closure = self.is_stack_closure(id);
|
let is_stack_closure = self.is_stack_closure(id);
|
||||||
let fty = ty::node_id_to_type(self.tcx(), id);
|
let fty = ty::node_id_to_type(self.tcx(), id);
|
||||||
self.declared_purity = ty::determine_inherited_purity(
|
self.declared_purity = ty::determine_inherited_purity(
|
||||||
|
@ -667,7 +666,7 @@ fn check_loans_in_expr(expr: @ast::expr,
|
||||||
fn check_loans_in_block(blk: ast::blk,
|
fn check_loans_in_block(blk: ast::blk,
|
||||||
&&self: check_loan_ctxt,
|
&&self: check_loan_ctxt,
|
||||||
vt: visit::vt<check_loan_ctxt>) {
|
vt: visit::vt<check_loan_ctxt>) {
|
||||||
do save_and_restore(self.declared_purity) {
|
do save_and_restore(&mut(self.declared_purity)) {
|
||||||
self.check_for_conflicting_loans(blk.node.id);
|
self.check_for_conflicting_loans(blk.node.id);
|
||||||
|
|
||||||
match blk.node.rules {
|
match blk.node.rules {
|
||||||
|
|
|
@ -115,10 +115,6 @@ fn req_loans_in_expr(ex: @ast::expr,
|
||||||
let scope_r = ty::re_scope(ex.id);
|
let scope_r = ty::re_scope(ex.id);
|
||||||
for vec::each2(args, arg_tys) |arg, arg_ty| {
|
for vec::each2(args, arg_tys) |arg, arg_ty| {
|
||||||
match ty::resolved_mode(self.tcx(), arg_ty.mode) {
|
match ty::resolved_mode(self.tcx(), arg_ty.mode) {
|
||||||
ast::by_mutbl_ref => {
|
|
||||||
let arg_cmt = self.bccx.cat_expr(*arg);
|
|
||||||
self.guarantee_valid(arg_cmt, m_mutbl, scope_r);
|
|
||||||
}
|
|
||||||
ast::by_ref => {
|
ast::by_ref => {
|
||||||
let arg_cmt = self.bccx.cat_expr(*arg);
|
let arg_cmt = self.bccx.cat_expr(*arg);
|
||||||
self.guarantee_valid(arg_cmt, m_imm, scope_r);
|
self.guarantee_valid(arg_cmt, m_imm, scope_r);
|
||||||
|
|
|
@ -319,13 +319,13 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
||||||
for exprs.each |expr| { maybe_copy(cx, *expr, None); }
|
for exprs.each |expr| { maybe_copy(cx, *expr, None); }
|
||||||
}
|
}
|
||||||
expr_call(f, args, _) => {
|
expr_call(f, args, _) => {
|
||||||
let mut i = 0u;
|
let mut i = 0;
|
||||||
for ty::ty_fn_args(ty::expr_ty(cx.tcx, f)).each |arg_t| {
|
for ty::ty_fn_args(ty::expr_ty(cx.tcx, f)).each |arg_t| {
|
||||||
match ty::arg_mode(cx.tcx, *arg_t) {
|
match ty::arg_mode(cx.tcx, *arg_t) {
|
||||||
by_copy => maybe_copy(cx, args[i], None),
|
by_copy => maybe_copy(cx, args[i], None),
|
||||||
by_ref | by_val | by_mutbl_ref | by_move => ()
|
by_ref | by_val | by_move => ()
|
||||||
}
|
}
|
||||||
i += 1u;
|
i += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
expr_field(lhs, _, _) => {
|
expr_field(lhs, _, _) => {
|
||||||
|
@ -335,7 +335,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
||||||
Some(ref mme) => {
|
Some(ref mme) => {
|
||||||
match ty::arg_mode(cx.tcx, mme.self_arg) {
|
match ty::arg_mode(cx.tcx, mme.self_arg) {
|
||||||
by_copy => maybe_copy(cx, lhs, None),
|
by_copy => maybe_copy(cx, lhs, None),
|
||||||
by_ref | by_val | by_mutbl_ref | by_move => ()
|
by_ref | by_val | by_move => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => ()
|
_ => ()
|
||||||
|
@ -465,18 +465,10 @@ fn check_imm_free_var(cx: ctx, def: def, sp: span) {
|
||||||
cx.tcx.sess.span_err(sp, msg);
|
cx.tcx.sess.span_err(sp, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
def_arg(_, mode) => {
|
|
||||||
match ty::resolved_mode(cx.tcx, mode) {
|
|
||||||
by_ref | by_val | by_move | by_copy => { /* ok */ }
|
|
||||||
by_mutbl_ref => {
|
|
||||||
cx.tcx.sess.span_err(sp, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
def_upvar(_, def1, _, _) => {
|
def_upvar(_, def1, _, _) => {
|
||||||
check_imm_free_var(cx, *def1, sp);
|
check_imm_free_var(cx, *def1, sp);
|
||||||
}
|
}
|
||||||
def_binding(*) | def_self(*) => { /*ok*/ }
|
def_arg(*) | def_binding(*) | def_self(*) => { /*ok*/ }
|
||||||
_ => {
|
_ => {
|
||||||
cx.tcx.sess.span_bug(
|
cx.tcx.sess.span_bug(
|
||||||
sp,
|
sp,
|
||||||
|
|
|
@ -398,8 +398,8 @@ impl IrMaps {
|
||||||
|
|
||||||
(*v).push(id);
|
(*v).push(id);
|
||||||
}
|
}
|
||||||
Arg(_, _, by_ref) | Arg(_, _, by_mutbl_ref) |
|
Arg(_, _, by_ref) | Arg(_, _, by_val) | Self | Field(_) |
|
||||||
Arg(_, _, by_val) | Self | Field(_) | ImplicitRet |
|
ImplicitRet |
|
||||||
Local(LocalInfo {kind: FromMatch(bind_by_implicit_ref), _}) => {
|
Local(LocalInfo {kind: FromMatch(bind_by_implicit_ref), _}) => {
|
||||||
debug!("--but it is not owned");
|
debug!("--but it is not owned");
|
||||||
}
|
}
|
||||||
|
@ -831,9 +831,9 @@ impl Liveness {
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
do self.indices2(ln, succ_ln) |idx, succ_idx| {
|
do self.indices2(ln, succ_ln) |idx, succ_idx| {
|
||||||
changed |= copy_if_invalid(copy self.users[succ_idx].reader,
|
changed |= copy_if_invalid(copy self.users[succ_idx].reader,
|
||||||
self.users[idx].reader);
|
&mut self.users[idx].reader);
|
||||||
changed |= copy_if_invalid(copy self.users[succ_idx].writer,
|
changed |= copy_if_invalid(copy self.users[succ_idx].writer,
|
||||||
self.users[idx].writer);
|
&mut self.users[idx].writer);
|
||||||
if self.users[succ_idx].used && !self.users[idx].used {
|
if self.users[succ_idx].used && !self.users[idx].used {
|
||||||
self.users[idx].used = true;
|
self.users[idx].used = true;
|
||||||
changed = true;
|
changed = true;
|
||||||
|
@ -844,10 +844,10 @@ impl Liveness {
|
||||||
ln.to_str(), self.ln_str(succ_ln), first_merge, changed);
|
ln.to_str(), self.ln_str(succ_ln), first_merge, changed);
|
||||||
return changed;
|
return changed;
|
||||||
|
|
||||||
fn copy_if_invalid(src: LiveNode, &dst: LiveNode) -> bool {
|
fn copy_if_invalid(src: LiveNode, dst: &mut LiveNode) -> bool {
|
||||||
if src.is_valid() {
|
if src.is_valid() {
|
||||||
if !dst.is_valid() {
|
if !dst.is_valid() {
|
||||||
dst = src;
|
*dst = src;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -919,7 +919,7 @@ impl Liveness {
|
||||||
// inputs passed by & mode should be considered live on exit:
|
// inputs passed by & mode should be considered live on exit:
|
||||||
for decl.inputs.each |arg| {
|
for decl.inputs.each |arg| {
|
||||||
match ty::resolved_mode(self.tcx, arg.mode) {
|
match ty::resolved_mode(self.tcx, arg.mode) {
|
||||||
by_mutbl_ref | by_ref | by_val => {
|
by_ref | by_val => {
|
||||||
// These are "non-owned" modes, so register a read at
|
// These are "non-owned" modes, so register a read at
|
||||||
// the end. This will prevent us from moving out of
|
// the end. This will prevent us from moving out of
|
||||||
// such variables but also prevent us from registering
|
// such variables but also prevent us from registering
|
||||||
|
@ -1573,7 +1573,7 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
|
||||||
let targs = ty::ty_fn_args(ty::expr_ty(self.tcx, f));
|
let targs = ty::ty_fn_args(ty::expr_ty(self.tcx, f));
|
||||||
for vec::each2(args, targs) |arg_expr, arg_ty| {
|
for vec::each2(args, targs) |arg_expr, arg_ty| {
|
||||||
match ty::resolved_mode(self.tcx, arg_ty.mode) {
|
match ty::resolved_mode(self.tcx, arg_ty.mode) {
|
||||||
by_val | by_copy | by_ref | by_mutbl_ref => {}
|
by_val | by_copy | by_ref => {}
|
||||||
by_move => {
|
by_move => {
|
||||||
self.check_move_from_expr(*arg_expr, vt);
|
self.check_move_from_expr(*arg_expr, vt);
|
||||||
}
|
}
|
||||||
|
@ -1866,19 +1866,6 @@ impl @Liveness {
|
||||||
for decl.inputs.each |arg| {
|
for decl.inputs.each |arg| {
|
||||||
let var = self.variable(arg.id, arg.ty.span);
|
let var = self.variable(arg.id, arg.ty.span);
|
||||||
match ty::resolved_mode(self.tcx, arg.mode) {
|
match ty::resolved_mode(self.tcx, arg.mode) {
|
||||||
by_mutbl_ref => {
|
|
||||||
// for mutable reference arguments, something like
|
|
||||||
// x = 1;
|
|
||||||
// is not worth warning about, as it has visible
|
|
||||||
// side effects outside the fn.
|
|
||||||
match self.assigned_on_entry(entry_ln, var) {
|
|
||||||
Some(_) => { /*ok*/ }
|
|
||||||
None => {
|
|
||||||
// but if it is not written, it ought to be used
|
|
||||||
self.warn_about_unused(sp, entry_ln, var);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
by_val | by_ref | by_move | by_copy => {
|
by_val | by_ref | by_move | by_copy => {
|
||||||
self.warn_about_unused(sp, entry_ln, var);
|
self.warn_about_unused(sp, entry_ln, var);
|
||||||
}
|
}
|
||||||
|
|
|
@ -523,9 +523,6 @@ impl &mem_categorization_ctxt {
|
||||||
// m: mutability of the argument
|
// m: mutability of the argument
|
||||||
// lp: loan path, must be none for aliasable things
|
// lp: loan path, must be none for aliasable things
|
||||||
let {m,lp} = match ty::resolved_mode(self.tcx, mode) {
|
let {m,lp} = match ty::resolved_mode(self.tcx, mode) {
|
||||||
ast::by_mutbl_ref => {
|
|
||||||
{m: m_mutbl, lp: None}
|
|
||||||
}
|
|
||||||
ast::by_move | ast::by_copy => {
|
ast::by_move | ast::by_copy => {
|
||||||
{m: m_imm, lp: Some(@lp_arg(vid))}
|
{m: m_imm, lp: Some(@lp_arg(vid))}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1503,7 +1503,7 @@ fn copy_args_to_allocas(fcx: fn_ctxt,
|
||||||
// the event it's not truly needed.
|
// the event it's not truly needed.
|
||||||
let llarg;
|
let llarg;
|
||||||
match ty::resolved_mode(tcx, arg_ty.mode) {
|
match ty::resolved_mode(tcx, arg_ty.mode) {
|
||||||
ast::by_ref | ast::by_mutbl_ref => {
|
ast::by_ref => {
|
||||||
llarg = raw_llarg;
|
llarg = raw_llarg;
|
||||||
}
|
}
|
||||||
ast::by_move | ast::by_copy => {
|
ast::by_move | ast::by_copy => {
|
||||||
|
|
|
@ -592,7 +592,7 @@ fn trans_arg_expr(bcx: block,
|
||||||
DoAutorefArg => { val = arg_datum.to_ref_llval(bcx); }
|
DoAutorefArg => { val = arg_datum.to_ref_llval(bcx); }
|
||||||
DontAutorefArg => {
|
DontAutorefArg => {
|
||||||
match arg_mode {
|
match arg_mode {
|
||||||
ast::by_ref | ast::by_mutbl_ref => {
|
ast::by_ref => {
|
||||||
val = arg_datum.to_ref_llval(bcx);
|
val = arg_datum.to_ref_llval(bcx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,6 @@ impl reflector {
|
||||||
ast::expl(e) => match e {
|
ast::expl(e) => match e {
|
||||||
ast::by_ref => 1u,
|
ast::by_ref => 1u,
|
||||||
ast::by_val => 2u,
|
ast::by_val => 2u,
|
||||||
ast::by_mutbl_ref => 3u,
|
|
||||||
ast::by_move => 4u,
|
ast::by_move => 4u,
|
||||||
ast::by_copy => 5u
|
ast::by_copy => 5u
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,12 +49,12 @@ fn mk_ctxt(llmod: ModuleRef) -> ctxt {
|
||||||
return {mut next_tag_id: 0u16, pad: 0u16, pad2: 0u32};
|
return {mut next_tag_id: 0u16, pad: 0u16, pad2: 0u32};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_u16(&dest: ~[u8], val: u16) {
|
fn add_u16(dest: &mut ~[u8], val: u16) {
|
||||||
dest += ~[(val & 0xffu16) as u8, (val >> 8u16) as u8];
|
*dest += ~[(val & 0xffu16) as u8, (val >> 8u16) as u8];
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_substr(&dest: ~[u8], src: ~[u8]) {
|
fn add_substr(dest: &mut ~[u8], src: ~[u8]) {
|
||||||
add_u16(dest, vec::len(src) as u16);
|
add_u16(dest, vec::len(src) as u16);
|
||||||
dest += src;
|
*dest += src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
|
||||||
by_val | by_move | by_copy => {
|
by_val | by_move | by_copy => {
|
||||||
type_needs(cx, use_repr, arg.ty);
|
type_needs(cx, use_repr, arg.ty);
|
||||||
}
|
}
|
||||||
by_ref | by_mutbl_ref => {}
|
by_ref => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ use lib::llvm::ValueRef;
|
||||||
use common::*;
|
use common::*;
|
||||||
use build::*;
|
use build::*;
|
||||||
use base::*;
|
use base::*;
|
||||||
use shape::llsize_of;
|
|
||||||
use datum::immediate_rvalue;
|
use datum::immediate_rvalue;
|
||||||
|
|
||||||
export make_free_glue, autoderef, duplicate;
|
export make_free_glue, autoderef, duplicate;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue