Merge branch 'master' of git://github.com/graydon/rust
This commit is contained in:
commit
ce79b0e492
@ -489,6 +489,7 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
|
||||
obj-recursion.rs \
|
||||
obj-return-polytypes.rs \
|
||||
obj-with-vec.rs \
|
||||
operator-associativity.rs \
|
||||
output-slot-variants.rs \
|
||||
pred.rs \
|
||||
preempt.rs \
|
||||
@ -576,10 +577,18 @@ RFAIL_RS := $(wildcard test/run-fail/*.rs)
|
||||
CFAIL_RC := $(wildcard test/compile-fail/*.rc)
|
||||
CFAIL_RS := $(wildcard test/compile-fail/*.rs)
|
||||
|
||||
ifdef CHECK_XFAILS
|
||||
TEST_RPASS_CRATES_X86 := $(filter $(TEST_XFAILS_X86), $(RPASS_RC))
|
||||
TEST_RPASS_CRATES_LLVM := $(filter $(TEST_XFAILS_LLVM), $(RPASS_RC))
|
||||
TEST_RPASS_SOURCES_X86 := $(filter $(TEST_XFAILS_X86), $(RPASS_RS))
|
||||
TEST_RPASS_SOURCES_LLVM := $(filter $(TEST_XFAILS_LLVM), $(RPASS_RS))
|
||||
else
|
||||
TEST_RPASS_CRATES_X86 := $(filter-out $(TEST_XFAILS_X86), $(RPASS_RC))
|
||||
TEST_RPASS_CRATES_LLVM := $(filter-out $(TEST_XFAILS_LLVM), $(RPASS_RC))
|
||||
TEST_RPASS_SOURCES_X86 := $(filter-out $(TEST_XFAILS_X86), $(RPASS_RS))
|
||||
TEST_RPASS_SOURCES_LLVM := $(filter-out $(TEST_XFAILS_LLVM), $(RPASS_RS))
|
||||
endif
|
||||
|
||||
TEST_RPASS_EXTRAS := $(wildcard test/run-pass/*/*.rs)
|
||||
TEST_RPASS_EXES_X86 := \
|
||||
$(TEST_RPASS_CRATES_X86:.rc=.x86$(CFG_EXE_SUFFIX)) \
|
||||
|
@ -718,131 +718,175 @@ and parse_negation_pexp (ps:pstate) : pexp =
|
||||
|
||||
(* Binops are all left-associative, *)
|
||||
(* so we factor out some of the parsing code here. *)
|
||||
and binop_rhs
|
||||
and binop_build
|
||||
(ps:pstate)
|
||||
(name:string)
|
||||
(apos:pos)
|
||||
(lhs:pexp)
|
||||
(rhs_parse_fn:pstate -> pexp)
|
||||
(lhs:pexp)
|
||||
(step_fn:pexp -> pexp)
|
||||
(op:Ast.binop)
|
||||
: pexp =
|
||||
bump ps;
|
||||
let rhs = (ctxt (name ^ " rhs") rhs_parse_fn ps) in
|
||||
let bpos = lexpos ps in
|
||||
span ps apos bpos (PEXP_binop (op, lhs, rhs))
|
||||
let node = span ps apos bpos (PEXP_binop (op, lhs, rhs)) in
|
||||
step_fn node
|
||||
|
||||
|
||||
and parse_factor_pexp (ps:pstate) : pexp =
|
||||
let name = "factor pexp" in
|
||||
let apos = lexpos ps in
|
||||
let lhs = ctxt (name ^ " lhs") parse_negation_pexp ps in
|
||||
let build = binop_build ps name apos parse_negation_pexp in
|
||||
let rec step accum =
|
||||
match peek ps with
|
||||
STAR -> binop_rhs ps name apos lhs parse_factor_pexp Ast.BINOP_mul
|
||||
| SLASH -> binop_rhs ps name apos lhs parse_factor_pexp Ast.BINOP_div
|
||||
| PERCENT -> binop_rhs ps name apos lhs parse_factor_pexp Ast.BINOP_mod
|
||||
| _ -> lhs
|
||||
STAR -> build accum step Ast.BINOP_mul
|
||||
| SLASH -> build accum step Ast.BINOP_div
|
||||
| PERCENT -> build accum step Ast.BINOP_mod
|
||||
| _ -> accum
|
||||
in
|
||||
step lhs
|
||||
|
||||
|
||||
and parse_term_pexp (ps:pstate) : pexp =
|
||||
let name = "term pexp" in
|
||||
let apos = lexpos ps in
|
||||
let lhs = ctxt (name ^ " lhs") parse_factor_pexp ps in
|
||||
let build = binop_build ps name apos parse_factor_pexp in
|
||||
let rec step accum =
|
||||
match peek ps with
|
||||
PLUS -> binop_rhs ps name apos lhs parse_term_pexp Ast.BINOP_add
|
||||
| MINUS -> binop_rhs ps name apos lhs parse_term_pexp Ast.BINOP_sub
|
||||
| _ -> lhs
|
||||
PLUS -> build accum step Ast.BINOP_add
|
||||
| MINUS -> build accum step Ast.BINOP_sub
|
||||
| _ -> accum
|
||||
in
|
||||
step lhs
|
||||
|
||||
|
||||
and parse_shift_pexp (ps:pstate) : pexp =
|
||||
let name = "shift pexp" in
|
||||
let apos = lexpos ps in
|
||||
let lhs = ctxt (name ^ " lhs") parse_term_pexp ps in
|
||||
let build = binop_build ps name apos parse_term_pexp in
|
||||
let rec step accum =
|
||||
match peek ps with
|
||||
LSL -> binop_rhs ps name apos lhs parse_shift_pexp Ast.BINOP_lsl
|
||||
| LSR -> binop_rhs ps name apos lhs parse_shift_pexp Ast.BINOP_lsr
|
||||
| ASR -> binop_rhs ps name apos lhs parse_shift_pexp Ast.BINOP_asr
|
||||
| _ -> lhs
|
||||
LSL -> build accum step Ast.BINOP_lsl
|
||||
| LSR -> build accum step Ast.BINOP_lsr
|
||||
| ASR -> build accum step Ast.BINOP_asr
|
||||
| _ -> accum
|
||||
in
|
||||
step lhs
|
||||
|
||||
|
||||
and parse_and_pexp (ps:pstate) : pexp =
|
||||
let name = "and pexp" in
|
||||
let apos = lexpos ps in
|
||||
let lhs = ctxt (name ^ " lhs") parse_shift_pexp ps in
|
||||
let build = binop_build ps name apos parse_shift_pexp in
|
||||
let rec step accum =
|
||||
match peek ps with
|
||||
AND -> binop_rhs ps name apos lhs parse_and_pexp Ast.BINOP_and
|
||||
| _ -> lhs
|
||||
AND -> build accum step Ast.BINOP_and
|
||||
| _ -> accum
|
||||
in
|
||||
step lhs
|
||||
|
||||
|
||||
and parse_xor_pexp (ps:pstate) : pexp =
|
||||
let name = "xor pexp" in
|
||||
let apos = lexpos ps in
|
||||
let lhs = ctxt (name ^ " lhs") parse_and_pexp ps in
|
||||
let build = binop_build ps name apos parse_and_pexp in
|
||||
let rec step accum =
|
||||
match peek ps with
|
||||
CARET -> binop_rhs ps name apos lhs parse_xor_pexp Ast.BINOP_xor
|
||||
| _ -> lhs
|
||||
CARET -> build accum step Ast.BINOP_xor
|
||||
| _ -> accum
|
||||
in
|
||||
step lhs
|
||||
|
||||
|
||||
and parse_or_pexp (ps:pstate) : pexp =
|
||||
let name = "or pexp" in
|
||||
let apos = lexpos ps in
|
||||
let lhs = ctxt (name ^ " lhs") parse_xor_pexp ps in
|
||||
let build = binop_build ps name apos parse_xor_pexp in
|
||||
let rec step accum =
|
||||
match peek ps with
|
||||
OR -> binop_rhs ps name apos lhs parse_or_pexp Ast.BINOP_or
|
||||
| _ -> lhs
|
||||
OR -> build accum step Ast.BINOP_or
|
||||
| _ -> accum
|
||||
in
|
||||
step lhs
|
||||
|
||||
|
||||
and parse_relational_pexp (ps:pstate) : pexp =
|
||||
let name = "relational pexp" in
|
||||
let apos = lexpos ps in
|
||||
let lhs = ctxt (name ^ " lhs") parse_or_pexp ps in
|
||||
let build = binop_build ps name apos parse_or_pexp in
|
||||
let rec step accum =
|
||||
match peek ps with
|
||||
LT -> binop_rhs ps name apos lhs parse_relational_pexp Ast.BINOP_lt
|
||||
| LE -> binop_rhs ps name apos lhs parse_relational_pexp Ast.BINOP_le
|
||||
| GE -> binop_rhs ps name apos lhs parse_relational_pexp Ast.BINOP_ge
|
||||
| GT -> binop_rhs ps name apos lhs parse_relational_pexp Ast.BINOP_gt
|
||||
| _ -> lhs
|
||||
LT -> build accum step Ast.BINOP_lt
|
||||
| LE -> build accum step Ast.BINOP_le
|
||||
| GE -> build accum step Ast.BINOP_ge
|
||||
| GT -> build accum step Ast.BINOP_gt
|
||||
| _ -> accum
|
||||
in
|
||||
step lhs
|
||||
|
||||
|
||||
and parse_equality_pexp (ps:pstate) : pexp =
|
||||
let name = "equality pexp" in
|
||||
let apos = lexpos ps in
|
||||
let lhs = ctxt (name ^ " lhs") parse_relational_pexp ps in
|
||||
let build = binop_build ps name apos parse_relational_pexp in
|
||||
let rec step accum =
|
||||
match peek ps with
|
||||
EQEQ -> binop_rhs ps name apos lhs parse_equality_pexp Ast.BINOP_eq
|
||||
| NE -> binop_rhs ps name apos lhs parse_equality_pexp Ast.BINOP_ne
|
||||
| _ -> lhs
|
||||
EQEQ -> build accum step Ast.BINOP_eq
|
||||
| NE -> build accum step Ast.BINOP_ne
|
||||
| _ -> accum
|
||||
in
|
||||
step lhs
|
||||
|
||||
|
||||
and parse_andand_pexp (ps:pstate) : pexp =
|
||||
let name = "andand pexp" in
|
||||
let apos = lexpos ps in
|
||||
let lhs = ctxt (name ^ " lhs") parse_equality_pexp ps in
|
||||
let rec step accum =
|
||||
match peek ps with
|
||||
ANDAND ->
|
||||
bump ps;
|
||||
let rhs = parse_andand_pexp ps in
|
||||
let rhs = parse_equality_pexp ps in
|
||||
let bpos = lexpos ps in
|
||||
span ps apos bpos (PEXP_lazy_and (lhs, rhs))
|
||||
let node = span ps apos bpos (PEXP_lazy_and (accum, rhs)) in
|
||||
step node
|
||||
|
||||
| _ -> lhs
|
||||
| _ -> accum
|
||||
in
|
||||
step lhs
|
||||
|
||||
|
||||
and parse_oror_pexp (ps:pstate) : pexp =
|
||||
let name = "oror pexp" in
|
||||
let apos = lexpos ps in
|
||||
let lhs = ctxt (name ^ " lhs") parse_andand_pexp ps in
|
||||
let rec step accum =
|
||||
match peek ps with
|
||||
OROR ->
|
||||
bump ps;
|
||||
let rhs = parse_oror_pexp ps in
|
||||
let rhs = parse_andand_pexp ps in
|
||||
let bpos = lexpos ps in
|
||||
span ps apos bpos (PEXP_lazy_or (lhs, rhs))
|
||||
let node = span ps apos bpos (PEXP_lazy_or (accum, rhs)) in
|
||||
step node
|
||||
|
||||
| _ -> accum
|
||||
in
|
||||
step lhs
|
||||
|
||||
| _ -> lhs
|
||||
|
||||
and parse_as_pexp (ps:pstate) : pexp =
|
||||
let apos = lexpos ps in
|
||||
let pexp = ctxt "as pexp" parse_oror_pexp ps in
|
||||
let rec step accum =
|
||||
match peek ps with
|
||||
AS ->
|
||||
bump ps;
|
||||
@ -850,10 +894,16 @@ and parse_as_pexp (ps:pstate) : pexp =
|
||||
let t = parse_ty ps in
|
||||
let bpos = lexpos ps in
|
||||
let t = span ps tapos bpos t in
|
||||
let node =
|
||||
span ps apos bpos
|
||||
(PEXP_unop ((Ast.UNOP_cast t), pexp))
|
||||
(PEXP_unop ((Ast.UNOP_cast t), accum))
|
||||
in
|
||||
step node
|
||||
|
||||
| _ -> accum
|
||||
in
|
||||
step pexp
|
||||
|
||||
| _ -> pexp
|
||||
|
||||
and parse_pexp (ps:pstate) : pexp =
|
||||
parse_as_pexp ps
|
||||
|
@ -472,6 +472,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
|
||||
and internal_check_outer_lval
|
||||
~mut:(mut:Ast.mutability)
|
||||
~deref:(deref:bool)
|
||||
~fn_args:(fn_args:(Ast.ty array) option)
|
||||
(infer:Ast.ty option)
|
||||
(lval:Ast.lval)
|
||||
: (Ast.ty * int) =
|
||||
@ -485,11 +486,15 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
|
||||
demand expected actual;
|
||||
yield_ty actual
|
||||
| None, (LTYPE_poly _ as lty) ->
|
||||
Common.err
|
||||
None
|
||||
"not enough context to automatically instantiate the polymorphic \
|
||||
type '%a'; supply type parameters explicitly"
|
||||
sprintf_ltype lty
|
||||
begin
|
||||
match fn_args with
|
||||
None ->
|
||||
Common.err None
|
||||
"can't auto-instantiate %a" sprintf_ltype lty
|
||||
| Some args ->
|
||||
Common.err None "can't auto-instantiate %a on %d args"
|
||||
sprintf_ltype lty (Array.length args)
|
||||
end
|
||||
| Some _, (LTYPE_poly _) ->
|
||||
(* FIXME: auto-instantiate *)
|
||||
Common.unimpl
|
||||
@ -502,6 +507,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
|
||||
and generic_check_lval
|
||||
~mut:(mut:Ast.mutability)
|
||||
~deref:(deref:bool)
|
||||
~fn_args:(fn_args:(Ast.ty array) option)
|
||||
(infer:Ast.ty option)
|
||||
(lval:Ast.lval)
|
||||
: Ast.ty =
|
||||
@ -521,7 +527,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
|
||||
| Some t -> Fmt.fmt_to_str Ast.fmt_ty t))
|
||||
in
|
||||
let (lval_ty, n_boxes) =
|
||||
internal_check_outer_lval ~mut:mut ~deref:deref infer lval
|
||||
internal_check_outer_lval ~mut ~deref ~fn_args infer lval
|
||||
in
|
||||
let _ =
|
||||
iflog cx
|
||||
@ -563,9 +569,10 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
|
||||
and check_lval
|
||||
?mut:(mut=Ast.MUT_immutable)
|
||||
?deref:(deref=false)
|
||||
?fn_args:(fn_args=None)
|
||||
(lval:Ast.lval)
|
||||
: Ast.ty =
|
||||
generic_check_lval ~mut:mut ~deref:deref None lval
|
||||
generic_check_lval ~fn_args ~mut ~deref None lval
|
||||
|
||||
and check_atom ?deref:(deref=false) (atom:Ast.atom) : Ast.ty =
|
||||
match atom with
|
||||
@ -582,7 +589,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
|
||||
(ty:Ast.ty)
|
||||
(lval:Ast.lval)
|
||||
: unit =
|
||||
ignore (generic_check_lval ?mut:mut ~deref:false
|
||||
ignore (generic_check_lval ~mut ~deref:false ~fn_args:None
|
||||
(Some (Ast.TY_mutable ty)) lval)
|
||||
in
|
||||
|
||||
@ -636,7 +643,7 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
|
||||
* returns the return type. *)
|
||||
let check_fn (callee:Ast.lval) (args:Ast.atom array) : Ast.ty =
|
||||
let arg_tys = Array.map check_atom args in
|
||||
let callee_ty = check_lval callee in
|
||||
let callee_ty = check_lval callee ~fn_args:(Some arg_tys) in
|
||||
demand_fn (Array.map (fun ty -> Some ty) arg_tys) callee_ty
|
||||
in
|
||||
|
||||
|
@ -2,23 +2,19 @@ type buf_reader = unsafe obj {
|
||||
fn read() -> vec[u8];
|
||||
};
|
||||
|
||||
type buf_writer = unsafe obj {
|
||||
fn write(vec[u8] v);
|
||||
};
|
||||
|
||||
fn default_bufsz() -> uint {
|
||||
ret 4096u;
|
||||
}
|
||||
|
||||
fn new_buf() -> vec[u8] {
|
||||
let vec[u8] v = vec();
|
||||
let uint i = default_bufsz();
|
||||
while (i > 0u) {
|
||||
i -= 1u;
|
||||
v += vec(0u8);
|
||||
}
|
||||
// FIXME (issue #93): should be:
|
||||
// ret _vec.alloc[u8](default_bufsz());
|
||||
ret v;
|
||||
ret _vec.alloc[u8](default_bufsz());
|
||||
}
|
||||
|
||||
fn new_buf_reader(str s) -> buf_reader {
|
||||
fn new_buf_reader(str path) -> buf_reader {
|
||||
|
||||
unsafe obj fd_buf_reader(int fd, mutable vec[u8] buf) {
|
||||
|
||||
@ -47,11 +43,67 @@ fn new_buf_reader(str s) -> buf_reader {
|
||||
}
|
||||
}
|
||||
|
||||
auto fd = os.libc.open(_str.buf(s), 0);
|
||||
auto fd = os.libc.open(_str.buf(path),
|
||||
os.libc_constants.O_RDONLY() |
|
||||
os.libc_constants.O_BINARY(),
|
||||
0u);
|
||||
|
||||
if (fd < 0) {
|
||||
log "error opening file";
|
||||
log "error opening file for reading";
|
||||
log sys.rustrt.last_os_error();
|
||||
fail;
|
||||
}
|
||||
ret fd_buf_reader(fd, new_buf());
|
||||
}
|
||||
|
||||
type fileflag = tag(append(), create(), truncate());
|
||||
|
||||
fn new_buf_writer(str path, vec[fileflag] flags) -> buf_writer {
|
||||
|
||||
unsafe obj fd_buf_writer(int fd) {
|
||||
|
||||
fn write(vec[u8] v) {
|
||||
auto len = _vec.len[u8](v);
|
||||
auto count = 0u;
|
||||
auto vbuf;
|
||||
while (count < len) {
|
||||
vbuf = _vec.buf_off[u8](v, count);
|
||||
auto nout = os.libc.write(fd, vbuf, len);
|
||||
if (nout < 0) {
|
||||
log "error dumping buffer";
|
||||
log sys.rustrt.last_os_error();
|
||||
fail;
|
||||
}
|
||||
count += nout as uint;
|
||||
}
|
||||
}
|
||||
|
||||
drop {
|
||||
os.libc.close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
let int fflags =
|
||||
os.libc_constants.O_WRONLY() |
|
||||
os.libc_constants.O_BINARY();
|
||||
|
||||
for (fileflag f in flags) {
|
||||
alt (f) {
|
||||
case (append()) { fflags |= os.libc_constants.O_APPEND(); }
|
||||
case (create()) { fflags |= os.libc_constants.O_CREAT(); }
|
||||
case (truncate()) { fflags |= os.libc_constants.O_TRUNC(); }
|
||||
}
|
||||
}
|
||||
|
||||
auto fd = os.libc.open(_str.buf(path),
|
||||
fflags,
|
||||
os.libc_constants.S_IRUSR() |
|
||||
os.libc_constants.S_IWUSR());
|
||||
|
||||
if (fd < 0) {
|
||||
log "error opening file for writing";
|
||||
log sys.rustrt.last_os_error();
|
||||
fail;
|
||||
}
|
||||
ret fd_buf_writer(fd);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import op = util.operator;
|
||||
|
||||
native "rust" mod rustrt {
|
||||
type vbuf;
|
||||
fn vec_buf[T](vec[T] v) -> vbuf;
|
||||
fn vec_buf[T](vec[T] v, uint offset) -> vbuf;
|
||||
fn vec_len[T](vec[T] v) -> uint;
|
||||
/* The T in vec_alloc[T, U] is the type of the vec to allocate. The
|
||||
* U is the type of an element in the vec. So to allocate a vec[U] we
|
||||
@ -50,7 +50,12 @@ fn len[T](vec[T] v) -> uint {
|
||||
}
|
||||
|
||||
fn buf[T](vec[T] v) -> vbuf {
|
||||
ret rustrt.vec_buf[T](v);
|
||||
ret rustrt.vec_buf[T](v, 0u);
|
||||
}
|
||||
|
||||
fn buf_off[T](vec[T] v, uint offset) -> vbuf {
|
||||
check (offset < len[T](v));
|
||||
ret rustrt.vec_buf[T](v, offset);
|
||||
}
|
||||
|
||||
// Returns elements from [start..end) from v.
|
||||
|
@ -3,7 +3,7 @@ import _vec.vbuf;
|
||||
|
||||
native mod libc = "libc.so.6" {
|
||||
|
||||
fn open(sbuf s, int flags) -> int;
|
||||
fn open(sbuf s, int flags, uint mode) -> int;
|
||||
fn read(int fd, vbuf buf, uint count) -> int;
|
||||
fn write(int fd, vbuf buf, uint count) -> int;
|
||||
fn close(int fd) -> int;
|
||||
@ -17,3 +17,18 @@ native mod libc = "libc.so.6" {
|
||||
fn setenv(sbuf n, sbuf v, int overwrite) -> int;
|
||||
fn unsetenv(sbuf n) -> int;
|
||||
}
|
||||
|
||||
mod libc_constants {
|
||||
fn O_RDONLY() -> int { ret 0x0000; }
|
||||
fn O_WRONLY() -> int { ret 0x0001; }
|
||||
fn O_RDWR() -> int { ret 0x0002; }
|
||||
fn O_APPEND() -> int { ret 0x0400; }
|
||||
fn O_CREAT() -> int { ret 0x0040; }
|
||||
fn O_EXCL() -> int { ret 0x0080; }
|
||||
fn O_TRUNC() -> int { ret 0x0200; }
|
||||
fn O_TEXT() -> int { ret 0x0000; } // nonexistent in linux libc
|
||||
fn O_BINARY() -> int { ret 0x0000; } // nonexistent in linux libc
|
||||
|
||||
fn S_IRUSR() -> uint { ret 0x0100u; }
|
||||
fn S_IWUSR() -> uint { ret 0x0080u; }
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import _vec.vbuf;
|
||||
|
||||
native mod libc = "libc.dylib" {
|
||||
|
||||
fn open(sbuf s, int flags) -> int;
|
||||
fn open(sbuf s, int flags, uint mode) -> int;
|
||||
fn read(int fd, vbuf buf, uint count) -> int;
|
||||
fn write(int fd, vbuf buf, uint count) -> int;
|
||||
fn close(int fd) -> int;
|
||||
@ -17,3 +17,18 @@ native mod libc = "libc.dylib" {
|
||||
fn setenv(sbuf n, sbuf v, int overwrite) -> int;
|
||||
fn unsetenv(sbuf n) -> int;
|
||||
}
|
||||
|
||||
mod libc_constants {
|
||||
fn O_RDONLY() -> int { ret 0x0000; }
|
||||
fn O_WRONLY() -> int { ret 0x0001; }
|
||||
fn O_RDWR() -> int { ret 0x0002; }
|
||||
fn O_APPEND() -> int { ret 0x0008; }
|
||||
fn O_CREAT() -> int { ret 0x0200; }
|
||||
fn O_EXCL() -> int { ret 0x0800; }
|
||||
fn O_TRUNC() -> int { ret 0x0400; }
|
||||
fn O_TEXT() -> int { ret 0x0000; } // nonexistent in darwin libc
|
||||
fn O_BINARY() -> int { ret 0x0000; } // nonexistent in darwin libc
|
||||
|
||||
fn S_IRUSR() -> uint { ret 0x0400u; }
|
||||
fn S_IWUSR() -> uint { ret 0x0200u; }
|
||||
}
|
||||
|
@ -2,8 +2,23 @@ import _str.sbuf;
|
||||
import _vec.vbuf;
|
||||
|
||||
native mod libc = "msvcrt.dll" {
|
||||
fn open(sbuf s, int flags) -> int = "_open";
|
||||
fn open(sbuf s, int flags, uint mode) -> int = "_open";
|
||||
fn read(int fd, vbuf buf, uint count) -> int = "_read";
|
||||
fn write(int fd, vbuf buf, uint count) -> int = "_write";
|
||||
fn close(int fd) -> int = "_close";
|
||||
}
|
||||
|
||||
mod libc_constants {
|
||||
fn O_RDONLY() -> int { ret 0x0000; }
|
||||
fn O_WRONLY() -> int { ret 0x0001; }
|
||||
fn O_RDWR() -> int { ret 0x0002; }
|
||||
fn O_APPEND() -> int { ret 0x0400; }
|
||||
fn O_CREAT() -> int { ret 0x0040; }
|
||||
fn O_EXCL() -> int { ret 0x0080; }
|
||||
fn O_TRUNC() -> int { ret 0x0200; }
|
||||
fn O_TEXT() -> int { ret 0x4000; }
|
||||
fn O_BINARY() -> int { ret 0x8000; }
|
||||
|
||||
fn S_IRUSR() -> uint { ret 0x0100u; } // really _S_IREAD in win32
|
||||
fn S_IWUSR() -> uint { ret 0x0080u; } // really _S_IWRITE in win32
|
||||
}
|
||||
|
@ -116,9 +116,9 @@ str_buf(rust_task *task, rust_str *s)
|
||||
}
|
||||
|
||||
extern "C" CDECL void *
|
||||
vec_buf(rust_task *task, type_desc *ty, rust_vec *v)
|
||||
vec_buf(rust_task *task, type_desc *ty, rust_vec *v, size_t offset)
|
||||
{
|
||||
return (void *)&v->data[0];
|
||||
return (void *)&v->data[ty->size * offset];
|
||||
}
|
||||
|
||||
extern "C" CDECL size_t
|
||||
|
4
src/test/run-pass/operator-associativity.rs
Normal file
4
src/test/run-pass/operator-associativity.rs
Normal file
@ -0,0 +1,4 @@
|
||||
// Testcase for issue #130, operator associativity.
|
||||
fn main() -> () {
|
||||
check ((3 * 5 / 2) == 7);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user