提交 d08b443f 编写于 作者: G Graydon Hoare

Revert "Use different syntax for checks that matter to typestate"

This reverts commit aa25f22f. It broke stage2, not sure why yet.
上级 764de078
......@@ -199,14 +199,6 @@ and parse_stmts_including_none (ps:pstate) : Ast.stmt array =
bump ps;
expect ps SEMI;
[| span ps apos (lexpos ps) Ast.STMT_cont |]
| ASSERT ->
bump ps;
let (stmts, expr) =
ctxt "stmts: check value" parse_expr ps
in
expect ps SEMI;
spans ps stmts apos (Ast.STMT_check_expr expr)
(* leaving check as it is; adding assert as a synonym for the "old" check *)
| CHECK ->
bump ps;
begin
......
......@@ -92,7 +92,6 @@
("type", TYPE);
("check", CHECK);
("assert", ASSERT);
("claim", CLAIM);
("prove", PROVE);
......
......@@ -77,7 +77,6 @@ type token =
(* Type and type-state keywords *)
| TYPE
| CHECK
| ASSERT
| CLAIM
| PROVE
......@@ -238,7 +237,6 @@ let rec string_of_tok t =
(* Type and type-state keywords *)
| TYPE -> "type"
| CHECK -> "check"
| ASSERT -> "assert"
| CLAIM -> "claim"
| PROVE -> "prove"
......
......@@ -283,10 +283,7 @@ fn unop_to_str(unop op) -> str {
expr_put(option.t[@expr], ann);
expr_be(@expr, ann);
expr_log(int, @expr, ann);
/* just an assert, no significance to typestate */
expr_assert(@expr, ann);
/* preds that typestate is aware of */
expr_check(@expr, ann);
expr_check_expr(@expr, ann);
expr_port(ann);
expr_chan(@expr, ann);
}
......
......@@ -93,7 +93,7 @@ fn parse_ty(@pstate st, str_def sd) -> ty.t {
case ('c') { ret ty.mk_char(st.tcx); }
case ('s') { ret ty.mk_str(st.tcx); }
case ('t') {
assert (next(st) as char == '[');
check(next(st) as char == '[');
auto def = parse_def(st, sd);
let vec[ty.t] params = vec();
while (peek(st) as char != ']') {
......@@ -108,7 +108,7 @@ fn parse_ty(@pstate st, str_def sd) -> ty.t {
case ('P') { ret ty.mk_port(st.tcx, parse_ty(st, sd)); }
case ('C') { ret ty.mk_chan(st.tcx, parse_ty(st, sd)); }
case ('T') {
assert (next(st) as char == '[');
check(next(st) as char == '[');
let vec[ty.mt] params = vec();
while (peek(st) as char != ']') {
params += vec(parse_mt(st, sd));
......@@ -117,7 +117,7 @@ fn parse_ty(@pstate st, str_def sd) -> ty.t {
ret ty.mk_tup(st.tcx, params);
}
case ('R') {
assert (next(st) as char == '[');
check(next(st) as char == '[');
let vec[ty.field] fields = vec();
while (peek(st) as char != ']') {
auto name = "";
......@@ -149,7 +149,7 @@ fn parse_ty(@pstate st, str_def sd) -> ty.t {
ret ty.mk_native_fn(st.tcx,abi,func._0,func._1);
}
case ('O') {
assert (next(st) as char == '[');
check(next(st) as char == '[');
let vec[ty.method] methods = vec();
while (peek(st) as char != ']') {
auto proto;
......@@ -175,9 +175,9 @@ fn parse_ty(@pstate st, str_def sd) -> ty.t {
case ('Y') { ret ty.mk_type(st.tcx); }
case ('#') {
auto pos = parse_hex(st);
assert (next(st) as char == ':');
check (next(st) as char == ':');
auto len = parse_hex(st);
assert (next(st) as char == '#');
check (next(st) as char == '#');
alt (st.tcx.rcache.find(tup(st.crate,pos,len))) {
case (some[ty.t](?tt)) { ret tt; }
case (none[ty.t]) {
......@@ -245,7 +245,7 @@ fn parse_hex(@pstate st) -> uint {
}
fn parse_ty_fn(@pstate st, str_def sd) -> tup(vec[ty.arg], ty.t) {
assert (next(st) as char == '[');
check(next(st) as char == '[');
let vec[ty.arg] inputs = vec();
while (peek(st) as char != ']') {
auto mode = ast.val;
......
......@@ -127,7 +127,6 @@ fn keyword_table() -> std.map.hashmap[str, token.token] {
keywords.insert("type", token.TYPE);
keywords.insert("check", token.CHECK);
keywords.insert("assert", token.ASSERT);
keywords.insert("claim", token.CLAIM);
keywords.insert("prove", token.PROVE);
......@@ -529,7 +528,7 @@ fn scan_numeric_escape(reader rdr) -> char {
auto n_hex_digits = 0;
assert (rdr.curr() == '\\');
check (rdr.curr() == '\\');
alt (rdr.next()) {
case ('x') { n_hex_digits = 2; }
......
......@@ -621,7 +621,7 @@ fn parse_path(parser p, greed g) -> ast.path {
if (p.peek() == token.DOT) {
if (g == GREEDY) {
p.bump();
assert (is_ident(p.peek()));
check (is_ident(p.peek()));
} else {
more = false;
}
......@@ -816,22 +816,19 @@ fn parse_expr_opt(parser p) -> option.t[@ast.expr] {
ex = ast.expr_log(0, e, ast.ann_none);
}
case (token.ASSERT) {
p.bump();
auto e = parse_expr(p);
auto hi = e.span.hi;
ex = ast.expr_assert(e, ast.ann_none);
}
case (token.CHECK) {
p.bump();
/* Should be a predicate (pure boolean function) applied to
arguments that are all either slot variables or literals.
but the typechecker enforces that. */
auto e = parse_expr(p);
auto hi = e.span.hi;
ex = ast.expr_check(e, ast.ann_none);
}
alt (p.peek()) {
case (token.LPAREN) {
auto e = parse_expr(p);
auto hi = e.span.hi;
ex = ast.expr_check_expr(e, ast.ann_none);
}
case (_) {
p.get_session().unimpl("constraint-check stmt");
}
}
}
case (token.RET) {
p.bump();
......@@ -940,7 +937,7 @@ fn expand_syntax_ext(parser p, ast.span sp,
&ast.path path, vec[@ast.expr] args,
option.t[str] body) -> ast.expr_ {
assert (_vec.len[ast.ident](path.node.idents) > 0u);
check (_vec.len[ast.ident](path.node.idents) > 0u);
auto extname = path.node.idents.(0);
if (_str.eq(extname, "fmt")) {
auto expanded = extfmt.expand_syntax_ext(args, body);
......@@ -1676,8 +1673,7 @@ fn stmt_ends_with_semi(@ast.stmt stmt) -> bool {
case (ast.expr_put(_,_)) { ret true; }
case (ast.expr_be(_,_)) { ret true; }
case (ast.expr_log(_,_,_)) { ret true; }
case (ast.expr_check(_,_)) { ret true; }
case (ast.expr_assert(_,_)) { ret true; }
case (ast.expr_check_expr(_,_)) { ret true; }
}
}
// We should not be calling this on a cdir.
......@@ -2161,24 +2157,24 @@ fn parse_item(parser p) -> @ast.item {
alt (p.peek()) {
case (token.CONST) {
assert (lyr == ast.layer_value);
check (lyr == ast.layer_value);
ret parse_item_const(p);
}
case (token.FN) {
assert (lyr == ast.layer_value);
check (lyr == ast.layer_value);
ret parse_item_fn_or_iter(p);
}
case (token.ITER) {
assert (lyr == ast.layer_value);
check (lyr == ast.layer_value);
ret parse_item_fn_or_iter(p);
}
case (token.MOD) {
assert (lyr == ast.layer_value);
check (lyr == ast.layer_value);
ret parse_item_mod(p);
}
case (token.NATIVE) {
assert (lyr == ast.layer_value);
check (lyr == ast.layer_value);
ret parse_item_native_mod(p);
}
case (token.TYPE) {
......
......@@ -89,7 +89,6 @@
/* Type and type-state keywords */
TYPE;
ASSERT;
CHECK;
CLAIM;
PROVE;
......@@ -259,7 +258,6 @@ fn to_str(token t) -> str {
/* Type and type-state keywords */
case (TYPE) { ret "type"; }
case (ASSERT) { ret "assert"; }
case (CHECK) { ret "check"; }
case (CLAIM) { ret "claim"; }
case (PROVE) { ret "prove"; }
......
......@@ -861,19 +861,19 @@ fn LLVMRustWriteOutputFile(PassManagerRef PM, ModuleRef M,
/* Terminators */
fn RetVoid() -> ValueRef {
assert (!*terminated);
check (!*terminated);
*terminated = true;
ret llvm.LLVMBuildRetVoid(B);
}
fn Ret(ValueRef V) -> ValueRef {
assert (!*terminated);
check (!*terminated);
*terminated = true;
ret llvm.LLVMBuildRet(B, V);
}
fn AggregateRet(vec[ValueRef] RetVals) -> ValueRef {
assert (!*terminated);
check (!*terminated);
*terminated = true;
ret llvm.LLVMBuildAggregateRet(B,
_vec.buf[ValueRef](RetVals),
......@@ -881,26 +881,26 @@ fn AggregateRet(vec[ValueRef] RetVals) -> ValueRef {
}
fn Br(BasicBlockRef Dest) -> ValueRef {
assert (!*terminated);
check (!*terminated);
*terminated = true;
ret llvm.LLVMBuildBr(B, Dest);
}
fn CondBr(ValueRef If, BasicBlockRef Then,
BasicBlockRef Else) -> ValueRef {
assert (!*terminated);
check (!*terminated);
*terminated = true;
ret llvm.LLVMBuildCondBr(B, If, Then, Else);
}
fn Switch(ValueRef V, BasicBlockRef Else, uint NumCases) -> ValueRef {
assert (!*terminated);
check (!*terminated);
*terminated = true;
ret llvm.LLVMBuildSwitch(B, V, Else, NumCases);
}
fn IndirectBr(ValueRef Addr, uint NumDests) -> ValueRef {
assert (!*terminated);
check (!*terminated);
*terminated = true;
ret llvm.LLVMBuildIndirectBr(B, Addr, NumDests);
}
......@@ -909,7 +909,7 @@ fn Invoke(ValueRef Fn,
vec[ValueRef] Args,
BasicBlockRef Then,
BasicBlockRef Catch) -> ValueRef {
assert (!*terminated);
check (!*terminated);
*terminated = true;
ret llvm.LLVMBuildInvoke(B, Fn,
_vec.buf[ValueRef](Args),
......@@ -919,209 +919,209 @@ fn Invoke(ValueRef Fn,
}
fn Unwind() -> ValueRef {
assert (!*terminated);
check (!*terminated);
*terminated = true;
ret llvm.LLVMBuildUnwind(B);
}
fn Unreachable() -> ValueRef {
assert (!*terminated);
check (!*terminated);
*terminated = true;
ret llvm.LLVMBuildUnreachable(B);
}
/* Arithmetic */
fn Add(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildAdd(B, LHS, RHS, _str.buf(""));
}
fn NSWAdd(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildNSWAdd(B, LHS, RHS, _str.buf(""));
}
fn NUWAdd(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildNUWAdd(B, LHS, RHS, _str.buf(""));
}
fn FAdd(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildFAdd(B, LHS, RHS, _str.buf(""));
}
fn Sub(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildSub(B, LHS, RHS, _str.buf(""));
}
fn NSWSub(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildNSWSub(B, LHS, RHS, _str.buf(""));
}
fn NUWSub(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildNUWSub(B, LHS, RHS, _str.buf(""));
}
fn FSub(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildFSub(B, LHS, RHS, _str.buf(""));
}
fn Mul(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildMul(B, LHS, RHS, _str.buf(""));
}
fn NSWMul(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildNSWMul(B, LHS, RHS, _str.buf(""));
}
fn NUWMul(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildNUWMul(B, LHS, RHS, _str.buf(""));
}
fn FMul(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildFMul(B, LHS, RHS, _str.buf(""));
}
fn UDiv(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildUDiv(B, LHS, RHS, _str.buf(""));
}
fn SDiv(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildSDiv(B, LHS, RHS, _str.buf(""));
}
fn ExactSDiv(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildExactSDiv(B, LHS, RHS, _str.buf(""));
}
fn FDiv(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildFDiv(B, LHS, RHS, _str.buf(""));
}
fn URem(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildURem(B, LHS, RHS, _str.buf(""));
}
fn SRem(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildSRem(B, LHS, RHS, _str.buf(""));
}
fn FRem(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildFRem(B, LHS, RHS, _str.buf(""));
}
fn Shl(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildShl(B, LHS, RHS, _str.buf(""));
}
fn LShr(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildLShr(B, LHS, RHS, _str.buf(""));
}
fn AShr(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildAShr(B, LHS, RHS, _str.buf(""));
}
fn And(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildAnd(B, LHS, RHS, _str.buf(""));
}
fn Or(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildOr(B, LHS, RHS, _str.buf(""));
}
fn Xor(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildXor(B, LHS, RHS, _str.buf(""));
}
fn BinOp(Opcode Op, ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildBinOp(B, Op, LHS, RHS, _str.buf(""));
}
fn Neg(ValueRef V) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildNeg(B, V, _str.buf(""));
}
fn NSWNeg(ValueRef V) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildNSWNeg(B, V, _str.buf(""));
}
fn NUWNeg(ValueRef V) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildNUWNeg(B, V, _str.buf(""));
}
fn FNeg(ValueRef V) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildFNeg(B, V, _str.buf(""));
}
fn Not(ValueRef V) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildNot(B, V, _str.buf(""));
}
/* Memory */
fn Malloc(TypeRef Ty) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildMalloc(B, Ty, _str.buf(""));
}
fn ArrayMalloc(TypeRef Ty, ValueRef Val) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildArrayMalloc(B, Ty, Val, _str.buf(""));
}
fn Alloca(TypeRef Ty) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildAlloca(B, Ty, _str.buf(""));
}
fn ArrayAlloca(TypeRef Ty, ValueRef Val) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildArrayAlloca(B, Ty, Val, _str.buf(""));
}
fn Free(ValueRef PointerVal) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildFree(B, PointerVal);
}
fn Load(ValueRef PointerVal) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildLoad(B, PointerVal, _str.buf(""));
}
fn Store(ValueRef Val, ValueRef Ptr) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildStore(B, Val, Ptr);
}
fn GEP(ValueRef Pointer, vec[ValueRef] Indices) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildGEP(B, Pointer,
_vec.buf[ValueRef](Indices),
_vec.len[ValueRef](Indices),
......@@ -1129,7 +1129,7 @@ fn GEP(ValueRef Pointer, vec[ValueRef] Indices) -> ValueRef {
}
fn InBoundsGEP(ValueRef Pointer, vec[ValueRef] Indices) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildInBoundsGEP(B, Pointer,
_vec.buf[ValueRef](Indices),
_vec.len[ValueRef](Indices),
......@@ -1137,125 +1137,125 @@ fn InBoundsGEP(ValueRef Pointer, vec[ValueRef] Indices) -> ValueRef {
}
fn StructGEP(ValueRef Pointer, uint Idx) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildStructGEP(B, Pointer, Idx, _str.buf(""));
}
fn GlobalString(sbuf Str) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildGlobalString(B, Str, _str.buf(""));
}
fn GlobalStringPtr(sbuf Str) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildGlobalStringPtr(B, Str, _str.buf(""));
}
/* Casts */
fn Trunc(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildTrunc(B, Val, DestTy, _str.buf(""));
}
fn ZExt(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildZExt(B, Val, DestTy, _str.buf(""));
}
fn SExt(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildSExt(B, Val, DestTy, _str.buf(""));
}
fn FPToUI(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildFPToUI(B, Val, DestTy, _str.buf(""));
}
fn FPToSI(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildFPToSI(B, Val, DestTy, _str.buf(""));
}
fn UIToFP(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildUIToFP(B, Val, DestTy, _str.buf(""));
}
fn SIToFP(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildSIToFP(B, Val, DestTy, _str.buf(""));
}
fn FPTrunc(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildFPTrunc(B, Val, DestTy, _str.buf(""));
}
fn FPExt(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildFPExt(B, Val, DestTy, _str.buf(""));
}
fn PtrToInt(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildPtrToInt(B, Val, DestTy, _str.buf(""));
}
fn IntToPtr(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildIntToPtr(B, Val, DestTy, _str.buf(""));
}
fn BitCast(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildBitCast(B, Val, DestTy, _str.buf(""));
}
fn ZExtOrBitCast(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildZExtOrBitCast(B, Val, DestTy, _str.buf(""));
}
fn SExtOrBitCast(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildSExtOrBitCast(B, Val, DestTy, _str.buf(""));
}
fn TruncOrBitCast(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildTruncOrBitCast(B, Val, DestTy, _str.buf(""));
}
fn Cast(Opcode Op, ValueRef Val, TypeRef DestTy, sbuf Name) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildCast(B, Op, Val, DestTy, _str.buf(""));
}
fn PointerCast(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildPointerCast(B, Val, DestTy, _str.buf(""));
}
fn IntCast(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildIntCast(B, Val, DestTy, _str.buf(""));
}
fn FPCast(ValueRef Val, TypeRef DestTy) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildFPCast(B, Val, DestTy, _str.buf(""));
}
/* Comparisons */
fn ICmp(uint Op, ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildICmp(B, Op, LHS, RHS, _str.buf(""));
}
fn FCmp(uint Op, ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildFCmp(B, Op, LHS, RHS, _str.buf(""));
}
......@@ -1263,9 +1263,9 @@ fn FCmp(uint Op, ValueRef LHS, ValueRef RHS) -> ValueRef {
/* Miscellaneous instructions */
fn Phi(TypeRef Ty, vec[ValueRef] vals,
vec[BasicBlockRef] bbs) -> ValueRef {
assert (!*terminated);
check (!*terminated);
auto phi = llvm.LLVMBuildPhi(B, Ty, _str.buf(""));
assert (_vec.len[ValueRef](vals) == _vec.len[BasicBlockRef](bbs));
check (_vec.len[ValueRef](vals) == _vec.len[BasicBlockRef](bbs));
llvm.LLVMAddIncoming(phi,
_vec.buf[ValueRef](vals),
_vec.buf[BasicBlockRef](bbs),
......@@ -1276,7 +1276,7 @@ fn Phi(TypeRef Ty, vec[ValueRef] vals,
fn AddIncomingToPhi(ValueRef phi,
vec[ValueRef] vals,
vec[BasicBlockRef] bbs) {
assert (_vec.len[ValueRef](vals) == _vec.len[BasicBlockRef](bbs));
check (_vec.len[ValueRef](vals) == _vec.len[BasicBlockRef](bbs));
llvm.LLVMAddIncoming(phi,
_vec.buf[ValueRef](vals),
_vec.buf[BasicBlockRef](bbs),
......@@ -1284,7 +1284,7 @@ fn AddIncomingToPhi(ValueRef phi,
}
fn Call(ValueRef Fn, vec[ValueRef] Args) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildCall(B, Fn,
_vec.buf[ValueRef](Args),
_vec.len[ValueRef](Args),
......@@ -1292,7 +1292,7 @@ fn Call(ValueRef Fn, vec[ValueRef] Args) -> ValueRef {
}
fn FastCall(ValueRef Fn, vec[ValueRef] Args) -> ValueRef {
assert (!*terminated);
check (!*terminated);
auto v = llvm.LLVMBuildCall(B, Fn,
_vec.buf[ValueRef](Args),
_vec.len[ValueRef](Args),
......@@ -1302,65 +1302,65 @@ fn FastCall(ValueRef Fn, vec[ValueRef] Args) -> ValueRef {
}
fn Select(ValueRef If, ValueRef Then, ValueRef Else) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildSelect(B, If, Then, Else, _str.buf(""));
}
fn VAArg(ValueRef List, TypeRef Ty) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildVAArg(B, List, Ty, _str.buf(""));
}
fn ExtractElement(ValueRef VecVal, ValueRef Index) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildExtractElement(B, VecVal, Index, _str.buf(""));
}
fn InsertElement(ValueRef VecVal, ValueRef EltVal,
ValueRef Index) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildInsertElement(B, VecVal, EltVal, Index,
_str.buf(""));
}
fn ShuffleVector(ValueRef V1, ValueRef V2, ValueRef Mask) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildShuffleVector(B, V1, V2, Mask, _str.buf(""));
}
fn ExtractValue(ValueRef AggVal, uint Index) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildExtractValue(B, AggVal, Index, _str.buf(""));
}
fn InsertValue(ValueRef AggVal, ValueRef EltVal,
uint Index) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildInsertValue(B, AggVal, EltVal, Index, _str.buf(""));
}
fn IsNull(ValueRef Val) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildIsNull(B, Val, _str.buf(""));
}
fn IsNotNull(ValueRef Val) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildIsNotNull(B, Val, _str.buf(""));
}
fn PtrDiff(ValueRef LHS, ValueRef RHS) -> ValueRef {
assert (!*terminated);
check (!*terminated);
ret llvm.LLVMBuildPtrDiff(B, LHS, RHS, _str.buf(""));
}
fn Trap() -> ValueRef {
assert (!*terminated);
check (!*terminated);
let BasicBlockRef BB = llvm.LLVMGetInsertBlock(B);
let ValueRef FN = llvm.LLVMGetBasicBlockParent(BB);
let ModuleRef M = llvm.LLVMGetGlobalParent(FN);
let ValueRef T = llvm.LLVMGetNamedFunction(M, _str.buf("llvm.trap"));
assert (T as int != 0);
check (T as int != 0);
let vec[ValueRef] Args = vec();
ret llvm.LLVMBuildCall(B, T,
_vec.buf[ValueRef](Args),
......@@ -1391,8 +1391,8 @@ fn mk_type_handle() -> type_handle {
std.map.hashmap[str, TypeRef] named_types) {
fn associate(str s, TypeRef t) {
assert (!named_types.contains_key(s));
assert (!type_names.contains_key(t));
check (!named_types.contains_key(s));
check (!type_names.contains_key(t));
type_names.insert(t, s);
named_types.insert(s, t);
}
......
......@@ -196,10 +196,7 @@
@expr e, ann a) -> @expr) fold_expr_log,
(fn(&ENV e, &span sp,
@expr e, ann a) -> @expr) fold_expr_check,
(fn(&ENV e, &span sp,
@expr e, ann a) -> @expr) fold_expr_assert,
@expr e, ann a) -> @expr) fold_expr_check_expr,
(fn(&ENV e, &span sp,
ann a) -> @expr) fold_expr_port,
......@@ -799,16 +796,10 @@ fn fold_expr[ENV](&ENV env, ast_fold[ENV] fld, &@expr e) -> @expr {
ret fld.fold_expr_log(env_, e.span, l, ee, t2);
}
case (ast.expr_check(?x, ?t)) {
case (ast.expr_check_expr(?x, ?t)) {
auto ee = fold_expr(env_, fld, x);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_check(env_, e.span, ee, t2);
}
case (ast.expr_assert(?x, ?t)) {
auto ee = fold_expr(env_, fld, x);
auto t2 = fld.fold_ann(env_, t);
ret fld.fold_expr_assert(env_, e.span, ee, t2);
ret fld.fold_expr_check_expr(env_, e.span, ee, t2);
}
case (ast.expr_port(?t)) {
......@@ -1389,14 +1380,9 @@ fn identity_fold_expr_log[ENV](&ENV e, &span sp, int lvl, @expr x,
ret @respan(sp, ast.expr_log(lvl, x, a));
}
fn identity_fold_expr_check[ENV](&ENV e, &span sp, @expr x, ann a)
-> @expr {
ret @respan(sp, ast.expr_check(x, a));
}
fn identity_fold_expr_assert[ENV](&ENV e, &span sp, @expr x, ann a)
fn identity_fold_expr_check_expr[ENV](&ENV e, &span sp, @expr x, ann a)
-> @expr {
ret @respan(sp, ast.expr_check(x, a));
ret @respan(sp, ast.expr_check_expr(x, a));
}
fn identity_fold_expr_port[ENV](&ENV e, &span sp, ann a) -> @expr {
......@@ -1690,11 +1676,8 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
fold_expr_put = bind identity_fold_expr_put[ENV](_,_,_,_),
fold_expr_be = bind identity_fold_expr_be[ENV](_,_,_,_),
fold_expr_log = bind identity_fold_expr_log[ENV](_,_,_,_,_),
fold_expr_check
= bind identity_fold_expr_check[ENV](_,_,_,_),
fold_expr_assert
= bind identity_fold_expr_assert[ENV](_,_,_,_),
fold_expr_check_expr
= bind identity_fold_expr_check_expr[ENV](_,_,_,_),
fold_expr_port = bind identity_fold_expr_port[ENV](_,_,_),
fold_expr_chan = bind identity_fold_expr_chan[ENV](_,_,_,_),
......
......@@ -63,7 +63,7 @@ mod Encode {
);
fn ty_str(@ctxt cx, ty.t t) -> str {
assert (! cx.use_abbrevs);
check (! cx.use_abbrevs);
auto sw = io.string_writer();
enc_ty(sw.get_writer(), cx, t);
ret sw.get_str();
......
......@@ -662,7 +662,7 @@ fn fold_pat_tag(&env e, &span sp, ast.path p, vec[@ast.pat] args,
fn fold_expr_path(&env e, &span sp, &ast.path p, &option.t[def] d,
ann a) -> @ast.expr {
auto n_idents = _vec.len[ast.ident](p.node.idents);
assert (n_idents != 0u);
check (n_idents != 0u);
auto index = new_def_hash[def_wrap]();
auto d = find_final_def(e, index, sp, p.node.idents, ns_value,
......
......@@ -586,7 +586,7 @@ fn type_of_explicit_args(@crate_ctxt cx, vec[ty.arg] inputs) -> vec[TypeRef] {
let vec[TypeRef] atys = vec();
for (ty.arg arg in inputs) {
if (ty.type_has_dynamic_size(cx.tcx, arg.ty)) {
assert (arg.mode == ast.alias);
check (arg.mode == ast.alias);
atys += vec(T_typaram_ptr(cx.tn));
} else {
let TypeRef t;
......@@ -632,7 +632,7 @@ fn type_of_fn_full(@crate_ctxt cx,
// Arg 2: Env (closure-bindings / self-obj)
alt (obj_self) {
case (some[TypeRef](?t)) {
assert (t as int != 0);
check (t as int != 0);
atys += vec(t);
}
case (_) {
......@@ -800,7 +800,7 @@ fn type_of_inner(@crate_ctxt cx, ty.t t) -> TypeRef {
case (ty.ty_type) { llty = T_ptr(T_tydesc(cx.tn)); }
}
assert (llty as int != 0);
check (llty as int != 0);
llvm.LLVMAddTypeName(cx.llmod,
_str.buf(ty.ty_to_short_str(cx.tcx,
cx.type_abbrevs, t)),
......@@ -1355,7 +1355,7 @@ fn dynamic_align_of(@block_ctxt cx, ty.t t) -> result {
fn GEP_tup_like(@block_ctxt cx, ty.t t,
ValueRef base, vec[int] ixs) -> result {
assert (ty.type_is_tup_like(cx.fcx.lcx.ccx.tcx, t));
check (ty.type_is_tup_like(cx.fcx.lcx.ccx.tcx, t));
// It might be a static-known type. Handle this.
......@@ -1393,17 +1393,17 @@ fn split_type(@crate_ctxt ccx, ty.t t, vec[int] ixs, uint n)
// and the latter would only be meaningful if we supported non-0
// values for the 0th index (we don't).
assert (len > 1u);
check (len > 1u);
if (n == 0u) {
// Since we're starting from a value that's a pointer to a
// *single* structure, the first index (in GEP-ese) should just be
// 0, to yield the pointee.
assert (ixs.(n) == 0);
check (ixs.(n) == 0);
ret split_type(ccx, t, ixs, n+1u);
}
assert (n < len);
check (n < len);
let int ix = ixs.(n);
let vec[ty.t] prefix = vec();
......@@ -1618,8 +1618,8 @@ fn get_tydesc(&@block_ctxt cx, ty.t t, bool escapes) -> result {
let uint n_params = ty.count_ty_params(cx.fcx.lcx.ccx.tcx, t);
auto tys = linearize_ty_params(cx, t);
assert (n_params == _vec.len[uint](tys._0));
assert (n_params == _vec.len[ValueRef](tys._1));
check (n_params == _vec.len[uint](tys._0));
check (n_params == _vec.len[ValueRef](tys._1));
auto root = get_static_tydesc(cx, t, tys._0).tydesc;
......@@ -2348,7 +2348,7 @@ fn tag_variants(@crate_ctxt cx, ast.def_id id) -> vec[variant_info] {
ret creader.get_tag_variants(cx.sess, cx.tcx, id);
}
assert (cx.items.contains_key(id));
check (cx.items.contains_key(id));
alt (cx.items.get(id).node) {
case (ast.item_tag(_, ?variants, _, _, _)) {
let vec[variant_info] result = vec();
......@@ -3367,7 +3367,7 @@ fn join_results(@block_ctxt parent_cx,
// No incoming edges are live, so we're in dead-code-land.
// Arbitrarily pick the first dead edge, since the caller
// is just going to propagate it outward.
assert (_vec.len[result](ins) >= 1u);
check (_vec.len[result](ins) >= 1u);
ret ins.(0);
}
......@@ -3995,7 +3995,7 @@ fn lval_generic_fn(@block_ctxt cx,
auto lv;
if (cx.fcx.lcx.ccx.sess.get_targ_crate_num() == fn_id._0) {
// Internal reference.
assert (cx.fcx.lcx.ccx.fn_pairs.contains_key(fn_id));
check (cx.fcx.lcx.ccx.fn_pairs.contains_key(fn_id));
lv = lval_val(cx, cx.fcx.lcx.ccx.fn_pairs.get(fn_id));
} else {
// External reference.
......@@ -4038,7 +4038,7 @@ fn lookup_discriminant(@local_ctxt lcx, ast.def_id tid, ast.def_id vid)
alt (lcx.ccx.discrims.find(vid)) {
case (none[ValueRef]) {
// It's an external discriminant that we haven't seen yet.
assert (lcx.ccx.sess.get_targ_crate_num() != vid._0);
check (lcx.ccx.sess.get_targ_crate_num() != vid._0);
auto sym = creader.get_symbol(lcx.ccx.sess, vid);
auto gvar = llvm.LLVMAddGlobal(lcx.ccx.llmod, T_int(),
_str.buf(sym));
......@@ -4060,7 +4060,7 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
case (ast.def_arg(?did)) {
alt (cx.fcx.llargs.find(did)) {
case (none[ValueRef]) {
assert (cx.fcx.llupvars.contains_key(did));
check (cx.fcx.llupvars.contains_key(did));
ret lval_mem(cx, cx.fcx.llupvars.get(did));
}
case (some[ValueRef](?llval)) {
......@@ -4071,7 +4071,7 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
case (ast.def_local(?did)) {
alt (cx.fcx.lllocals.find(did)) {
case (none[ValueRef]) {
assert (cx.fcx.llupvars.contains_key(did));
check (cx.fcx.llupvars.contains_key(did));
ret lval_mem(cx, cx.fcx.llupvars.get(did));
}
case (some[ValueRef](?llval)) {
......@@ -4080,11 +4080,11 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
}
}
case (ast.def_binding(?did)) {
assert (cx.fcx.lllocals.contains_key(did));
check (cx.fcx.lllocals.contains_key(did));
ret lval_mem(cx, cx.fcx.lllocals.get(did));
}
case (ast.def_obj_field(?did)) {
assert (cx.fcx.llobjfields.contains_key(did));
check (cx.fcx.llobjfields.contains_key(did));
ret lval_mem(cx, cx.fcx.llobjfields.get(did));
}
case (ast.def_fn(?did)) {
......@@ -4136,7 +4136,7 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
}
case (ast.def_const(?did)) {
// TODO: externals
assert (cx.fcx.lcx.ccx.consts.contains_key(did));
check (cx.fcx.lcx.ccx.consts.contains_key(did));
ret lval_mem(cx, cx.fcx.lcx.ccx.consts.get(did));
}
case (ast.def_native_fn(?did)) {
......@@ -4275,7 +4275,7 @@ fn trans_lval(@block_ctxt cx, @ast.expr e) -> lval_result {
ret trans_index(cx, e.span, base, idx, ann);
}
case (ast.expr_unary(?unop, ?base, ?ann)) {
assert (unop == ast.deref);
check (unop == ast.deref);
auto sub = trans_expr(cx, base);
auto val = sub.bcx.build.GEP(sub.val,
......@@ -4439,7 +4439,7 @@ fn trans_bind_thunk(@local_ctxt cx,
}
} else if (ty.type_contains_params(cx.ccx.tcx,
out_arg.ty)) {
assert (out_arg.mode == ast.alias);
check (out_arg.mode == ast.alias);
val = bcx.build.PointerCast(val, llout_arg_ty);
}
......@@ -4452,7 +4452,7 @@ fn trans_bind_thunk(@local_ctxt cx,
let ValueRef passed_arg = llvm.LLVMGetParam(llthunk, a);
if (ty.type_contains_params(cx.ccx.tcx, out_arg.ty)) {
assert (out_arg.mode == ast.alias);
check (out_arg.mode == ast.alias);
passed_arg = bcx.build.PointerCast(passed_arg,
llout_arg_ty);
}
......@@ -5142,7 +5142,7 @@ fn trans_expr(@block_ctxt cx, @ast.expr e) -> result {
case (ast.expr_assign(?dst, ?src, ?ann)) {
auto lhs_res = trans_lval(cx, dst);
assert (lhs_res.is_mem);
check (lhs_res.is_mem);
auto rhs_res = trans_expr(lhs_res.res.bcx, src);
auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
// FIXME: calculate copy init-ness in typestate.
......@@ -5153,7 +5153,7 @@ fn trans_expr(@block_ctxt cx, @ast.expr e) -> result {
case (ast.expr_assign_op(?op, ?dst, ?src, ?ann)) {
auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
auto lhs_res = trans_lval(cx, dst);
assert (lhs_res.is_mem);
check (lhs_res.is_mem);
auto rhs_res = trans_expr(lhs_res.res.bcx, src);
if (ty.type_is_sequence(cx.fcx.lcx.ccx.tcx, t)) {
alt (op) {
......@@ -5210,11 +5210,7 @@ fn trans_expr(@block_ctxt cx, @ast.expr e) -> result {
ret trans_log(lvl, cx, a);
}
case (ast.expr_assert(?a, _)) {
ret trans_check_expr(cx, a);
}
case (ast.expr_check(?a, _)) {
case (ast.expr_check_expr(?a, _)) {
ret trans_check_expr(cx, a);
}
......@@ -5535,7 +5531,7 @@ fn trans_ret(@block_ctxt cx, &option.t[@ast.expr] e) -> result {
fn trans_be(@block_ctxt cx, @ast.expr e) -> result {
// FIXME: This should be a typestate precondition
assert (ast.is_call_expr(e));
check (ast.is_call_expr(e));
// FIXME: Turn this into a real tail call once
// calling convention issues are settled
ret trans_ret(cx, some(e));
......@@ -5631,7 +5627,7 @@ fn trans_recv(@block_ctxt cx, @ast.expr lhs, @ast.expr rhs,
auto bcx = cx;
auto data = trans_lval(bcx, lhs);
assert (data.is_mem);
check (data.is_mem);
bcx = data.res.bcx;
auto unit_ty = node_ann_type(bcx.fcx.lcx.ccx, ann);
......@@ -5663,7 +5659,7 @@ fn recv_val(@block_ctxt cx, ValueRef lhs, @ast.expr rhs,
fn init_local(@block_ctxt cx, @ast.local local) -> result {
// Make a note to drop this slot on the way out.
assert (cx.fcx.lllocals.contains_key(local.id));
check (cx.fcx.lllocals.contains_key(local.id));
auto llptr = cx.fcx.lllocals.get(local.id);
auto ty = node_ann_type(cx.fcx.lcx.ccx, local.ann);
auto bcx = cx;
......@@ -5779,7 +5775,7 @@ fn trans_block_cleanups(@block_ctxt cx,
auto bcx = cx;
if (cleanup_cx.kind == NON_SCOPE_BLOCK) {
assert (_vec.len[cleanup](cleanup_cx.cleanups) == 0u);
check (_vec.len[cleanup](cleanup_cx.cleanups) == 0u);
}
auto i = _vec.len[cleanup](cleanup_cx.cleanups);
......@@ -6000,7 +5996,7 @@ fn create_llargs_for_fn_args(&@fn_ctxt cx,
auto i = 0u;
for (ast.ty_param tp in ty_params) {
auto llarg = llvm.LLVMGetParam(cx.llfn, arg_n);
assert (llarg as int != 0);
check (llarg as int != 0);
cx.lltydescs += vec(llarg);
arg_n += 1u;
i += 1u;
......@@ -6010,14 +6006,14 @@ fn create_llargs_for_fn_args(&@fn_ctxt cx,
if (proto == ast.proto_iter) {
auto llarg = llvm.LLVMGetParam(cx.llfn, arg_n);
assert (llarg as int != 0);
check (llarg as int != 0);
cx.lliterbody = some[ValueRef](llarg);
arg_n += 1u;
}
for (ast.arg arg in args) {
auto llarg = llvm.LLVMGetParam(cx.llfn, arg_n);
assert (llarg as int != 0);
check (llarg as int != 0);
cx.llargs.insert(arg.id, llarg);
arg_n += 1u;
}
......@@ -6455,7 +6451,7 @@ fn trans_tag_variant(@local_ctxt cx, ast.def_id tag_id,
id=varg.id));
}
assert (cx.ccx.item_ids.contains_key(variant.node.id));
check (cx.ccx.item_ids.contains_key(variant.node.id));
let ValueRef llfndecl = cx.ccx.item_ids.get(variant.node.id);
auto fcx = new_fn_ctxt(cx, llfndecl);
......@@ -6722,7 +6718,7 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx,
for each (uint i in _uint.range(0u, num_ty_param)) {
auto llarg = llvm.LLVMGetParam(fcx.llfn, arg_n);
fcx.lltydescs += vec(llarg);
assert (llarg as int != 0);
check (llarg as int != 0);
call_args += vec(vp2i(bcx, llarg));
arg_n += 1u;
}
......@@ -6788,7 +6784,7 @@ fn push_arg(@block_ctxt cx,
for (ty.arg arg in args) {
auto llarg = llvm.LLVMGetParam(fcx.llfn, arg_n);
assert (llarg as int != 0);
check (llarg as int != 0);
push_arg(bcx, call_args, llarg, arg.ty, arg.mode);
if (arg.mode == ast.val) {
drop_args += vec(tup(llarg, arg.ty));
......
......@@ -895,7 +895,7 @@ fn type_is_tup_like(ctxt cx, t ty) -> bool {
}
fn get_element_type(ctxt cx, t ty, uint i) -> t {
assert (type_is_tup_like(cx, ty));
check (type_is_tup_like(cx, ty));
alt (struct(cx, ty)) {
case (ty_tup(?mts)) {
ret mts.(i).ty;
......@@ -1785,117 +1785,50 @@ fn pat_ty(ctxt cx, @ast.pat pat) -> t {
fail; // not reached
}
fn expr_ann(&@ast.expr e) -> ast.ann {
alt(e.node) {
case (ast.expr_vec(_,_,?a)) {
ret a;
}
case (ast.expr_tup(_,?a)) {
ret a;
}
case (ast.expr_rec(_,_,?a)) {
ret a;
}
case (ast.expr_call(_,_,?a)) {
ret a;
}
case (ast.expr_bind(_,_,?a)) {
ret a;
}
case (ast.expr_binary(_,_,_,?a)) {
ret a;
}
case (ast.expr_unary(_,_,?a)) {
ret a;
}
case (ast.expr_lit(_,?a)) {
ret a;
}
case (ast.expr_cast(_,_,?a)) {
ret a;
}
case (ast.expr_if(_,_,_,?a)) {
ret a;
}
case (ast.expr_while(_,_,?a)) {
ret a;
}
case (ast.expr_for(_,_,_,?a)) {
ret a;
}
case (ast.expr_for_each(_,_,_,?a)) {
ret a;
}
case (ast.expr_do_while(_,_,?a)) {
ret a;
}
case (ast.expr_alt(_,_,?a)) {
ret a;
}
case (ast.expr_block(_,?a)) {
ret a;
}
case (ast.expr_assign(_,_,?a)) {
ret a;
}
case (ast.expr_assign_op(_,_,_,?a)) {
ret a;
}
case (ast.expr_send(_,_,?a)) {
ret a;
}
case (ast.expr_recv(_,_,?a)) {
ret a;
}
case (ast.expr_field(_,_,?a)) {
ret a;
}
case (ast.expr_index(_,_,?a)) {
ret a;
}
case (ast.expr_path(_,_,?a)) {
ret a;
}
case (ast.expr_ext(_,_,_,_,?a)) {
ret a;
}
case (ast.expr_fail(?a)) {
ret a;
}
case (ast.expr_ret(_,?a)) {
ret a;
}
case (ast.expr_put(_,?a)) {
ret a;
}
case (ast.expr_be(_,?a)) {
ret a;
}
case (ast.expr_log(_,_,?a)) {
ret a;
}
case (ast.expr_assert(_,?a)) {
ret a;
}
case (ast.expr_check(_,?a)) {
ret a;
}
case (ast.expr_port(?a)) {
ret a;
}
case (ast.expr_chan(_,?a)) {
ret a;
}
case (ast.expr_break(?a)) {
ret a;
}
case (ast.expr_cont(?a)) {
ret a;
}
case (ast.expr_self_method(_, ?a)) {
ret a;
}
fn expr_ann(@ast.expr expr) -> option.t[ast.ann] {
alt (expr.node) {
case (ast.expr_vec(_, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_tup(_, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_rec(_, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_bind(_, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_call(_, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_self_method(_, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_spawn(_, _, _, _, ?ann))
{ ret some[ast.ann](ann); }
case (ast.expr_binary(_, _, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_unary(_, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_lit(_, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_cast(_, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_if(_, _, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_for(_, _, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_for_each(_, _, _, ?ann))
{ ret some[ast.ann](ann); }
case (ast.expr_while(_, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_do_while(_, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_alt(_, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_block(_, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_assign(_, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_assign_op(_, _, _, ?ann))
{ ret some[ast.ann](ann); }
case (ast.expr_field(_, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_index(_, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_path(_, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_ext(_, _, _, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_port(?ann)) { ret some[ast.ann](ann); }
case (ast.expr_chan(_, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_send(_, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_recv(_, _, ?ann)) { ret some[ast.ann](ann); }
case (ast.expr_fail(_)) { ret none[ast.ann]; }
case (ast.expr_break(_)) { ret none[ast.ann]; }
case (ast.expr_cont(_)) { ret none[ast.ann]; }
case (ast.expr_log(_,_,_)) { ret none[ast.ann]; }
case (ast.expr_check_expr(_,_)) { ret none[ast.ann]; }
case (ast.expr_ret(_,_)) { ret none[ast.ann]; }
case (ast.expr_put(_,_)) { ret none[ast.ann]; }
case (ast.expr_be(_,_)) { ret none[ast.ann]; }
}
fail;
}
// Returns the type of an expression as a monotype.
......@@ -1905,21 +1838,35 @@ fn expr_ann(&@ast.expr e) -> ast.ann {
// instead of "fn(&T) -> T with T = int". If this isn't what you want, see
// expr_ty_params_and_ty() below.
fn expr_ty(ctxt cx, @ast.expr expr) -> t {
{ ret ann_to_monotype(cx, expr_ann(expr)); }
alt (expr_ann(expr)) {
case (none[ast.ann]) { ret mk_nil(cx); }
case (some[ast.ann](?a)) { ret ann_to_monotype(cx, a); }
}
}
fn expr_ty_params_and_ty(ctxt cx, @ast.expr expr) -> tup(vec[t], t) {
auto a = expr_ann(expr);
ret tup(ann_to_type_params(a), ann_to_type(a));
alt (expr_ann(expr)) {
case (none[ast.ann]) {
let vec[t] tps = vec();
ret tup(tps, mk_nil(cx));
}
case (some[ast.ann](?a)) {
ret tup(ann_to_type_params(a), ann_to_type(a));
}
}
}
fn expr_has_ty_params(@ast.expr expr) -> bool {
// FIXME: Rewrite using complex patterns when they're trustworthy.
alt (expr_ann(expr)) {
case (ast.ann_none) { fail; }
case (ast.ann_type(_, ?tps_opt, _)) {
ret !option.is_none[vec[t]](tps_opt);
case (none[ast.ann]) { fail; }
case (some[ast.ann](?a)) {
alt (a) {
case (ast.ann_none) { fail; }
case (ast.ann_type(_, ?tps_opt, _)) {
ret !option.is_none[vec[t]](tps_opt);
}
}
}
}
}
......@@ -2286,7 +2233,7 @@ fn unify_step(@ctxt cx, t expected, t actual) -> result {
if (actual_n < vlen) {
cx.types.(actual_n) += vec(expected);
} else {
assert (actual_n == vlen);
check (actual_n == vlen);
cx.types += vec(mutable vec(expected));
}
}
......@@ -2654,7 +2601,7 @@ fn unify_step(@ctxt cx, t expected, t actual) -> result {
if (expected_n < vlen) {
cx.types.(expected_n) += vec(actual);
} else {
assert (expected_n == vlen);
check (expected_n == vlen);
cx.types += vec(mutable vec(actual));
}
ret ures_ok(expected);
......
......@@ -110,7 +110,7 @@ fn ty_param_count_and_ty_for_def(@fn_ctxt fcx, &ast.span sp, &ast.def defn)
-> ty_param_count_and_ty {
alt (defn) {
case (ast.def_arg(?id)) {
// assert (fcx.locals.contains_key(id));
// check (fcx.locals.contains_key(id));
ret tup(0u, fcx.locals.get(id));
}
case (ast.def_local(?id)) {
......@@ -122,7 +122,7 @@ fn ty_param_count_and_ty_for_def(@fn_ctxt fcx, &ast.span sp, &ast.def defn)
ret tup(0u, t);
}
case (ast.def_obj_field(?id)) {
// assert (fcx.locals.contains_key(id));
// check (fcx.locals.contains_key(id));
ret tup(0u, fcx.locals.get(id));
}
case (ast.def_fn(?id)) {
......@@ -142,7 +142,7 @@ fn ty_param_count_and_ty_for_def(@fn_ctxt fcx, &ast.span sp, &ast.def defn)
fcx.ccx.type_cache, vid);
}
case (ast.def_binding(?id)) {
// assert (fcx.locals.contains_key(id));
// check (fcx.locals.contains_key(id));
ret tup(0u, fcx.locals.get(id));
}
case (ast.def_obj(?id)) {
......@@ -298,7 +298,7 @@ fn instantiate(ty.ctxt tcx,
}
case (ast.ty_path(?path, ?def)) {
assert (def != none[ast.def]);
check (def != none[ast.def]);
alt (option.get[ast.def](def)) {
case (ast.def_ty(?id)) {
typ = instantiate(tcx, getter, id, path.node.types);
......@@ -411,7 +411,7 @@ fn getter(@ctxt cx, ast.def_id id) -> ty.ty_param_count_and_ty {
ret creader.get_type(cx.sess, cx.tcx, id);
}
// assert (cx.id_to_ty_item.contains_key(id));
// check (cx.id_to_ty_item.contains_key(id));
auto it = cx.id_to_ty_item.get(id);
auto tpt;
......@@ -672,7 +672,7 @@ fn convert_native(&@env e, @ast.native_item i) -> @env {
fn fold_item_const(&@env e, &span sp, ast.ident i,
@ast.ty t, @ast.expr ex,
ast.def_id id, ast.ann a) -> @ast.item {
// assert (e.cx.type_cache.contains_key(id));
// check (e.cx.type_cache.contains_key(id));
auto typ = e.cx.type_cache.get(id)._1;
auto item = ast.item_const(i, t, ex, id, triv_ann(typ));
ret @fold.respan[ast.item_](sp, item);
......@@ -681,7 +681,7 @@ fn fold_item_const(&@env e, &span sp, ast.ident i,
fn fold_item_fn(&@env e, &span sp, ast.ident i,
&ast._fn f, vec[ast.ty_param] ty_params,
ast.def_id id, ast.ann a) -> @ast.item {
// assert (e.cx.type_cache.contains_key(id));
// check (e.cx.type_cache.contains_key(id));
auto typ = e.cx.type_cache.get(id)._1;
auto item = ast.item_fn(i, f, ty_params, id, triv_ann(typ));
ret @fold.respan[ast.item_](sp, item);
......@@ -690,7 +690,7 @@ fn fold_item_fn(&@env e, &span sp, ast.ident i,
fn fold_native_item_fn(&@env e, &span sp, ast.ident i, option.t[str] ln,
&ast.fn_decl d, vec[ast.ty_param] ty_params,
ast.def_id id, ast.ann a) -> @ast.native_item {
// assert (e.cx.type_cache.contains_key(id));
// check (e.cx.type_cache.contains_key(id));
auto typ = e.cx.type_cache.get(id)._1;
auto item = ast.native_item_fn(i, ln, d, ty_params, id,
triv_ann(typ));
......@@ -721,7 +721,7 @@ fn get_ctor_obj_methods(&@env e, ty.t t) -> vec[method] {
fn fold_item_obj(&@env e, &span sp, ast.ident i,
&ast._obj ob, vec[ast.ty_param] ty_params,
ast.obj_def_ids odid, ast.ann a) -> @ast.item {
// assert (e.cx.type_cache.contains_key(odid.ctor));
// check (e.cx.type_cache.contains_key(odid.ctor));
auto t = e.cx.type_cache.get(odid.ctor)._1;
let vec[method] meth_tys = get_ctor_obj_methods(e, t);
let vec[@ast.method] methods = vec();
......@@ -777,7 +777,7 @@ fn fold_item_obj(&@env e, &span sp, ast.ident i,
fn fold_item_ty(&@env e, &span sp, ast.ident i,
@ast.ty t, vec[ast.ty_param] ty_params,
ast.def_id id, ast.ann a) -> @ast.item {
// assert (e.cx.type_cache.contains_key(id));
// check (e.cx.type_cache.contains_key(id));
auto typ = e.cx.type_cache.get(id)._1;
auto item = ast.item_ty(i, t, ty_params, id, triv_ann(typ));
ret @fold.respan[ast.item_](sp, item);
......@@ -1214,7 +1214,7 @@ fn pushdown_expr_full(&@fn_ctxt fcx, ty.t expected, @ast.expr e,
case (none[@ast.expr]) {
auto i = 0u;
for (ast.field field_0 in fields_0) {
assert (_str.eq(field_0.ident,
check (_str.eq(field_0.ident,
field_mts.(i).ident));
auto e_1 =
pushdown_expr(fcx,
......@@ -1409,8 +1409,7 @@ fn pushdown_expr_full(&@fn_ctxt fcx, ty.t expected, @ast.expr e,
case (ast.expr_ret(_,_)) { e_1 = e.node; }
case (ast.expr_put(_,_)) { e_1 = e.node; }
case (ast.expr_be(_,_)) { e_1 = e.node; }
case (ast.expr_check(_,_)) { e_1 = e.node; }
case (ast.expr_assert(_,_)) { e_1 = e.node; }
case (ast.expr_check_expr(_,_)) { e_1 = e.node; }
case (ast.expr_port(?ann)) {
auto t = Demand.simple(fcx, e.span, expected,
......@@ -1840,7 +1839,7 @@ fn check_call(&@fn_ctxt fcx, @ast.expr f, vec[@ast.expr] args)
case (ast.expr_path(?pth, ?defopt, _)) {
auto t = ty.mk_nil(fcx.ccx.tcx);
assert (defopt != none[ast.def]);
check (defopt != none[ast.def]);
auto defn = option.get[ast.def](defopt);
auto tpt = ty_param_count_and_ty_for_def(fcx, expr.span, defn);
......@@ -1940,7 +1939,7 @@ fn check_call(&@fn_ctxt fcx, @ast.expr f, vec[@ast.expr] args)
case (ast.expr_be(?e, _)) {
/* FIXME: prove instead of check */
assert (ast.is_call_expr(e));
check (ast.is_call_expr(e));
auto expr_0 = check_expr(fcx, e);
auto expr_1 = Pushdown.pushdown_expr(fcx, fcx.ret_ty, expr_0);
ret @fold.respan[ast.expr_](expr.span,
......@@ -1954,25 +1953,12 @@ fn check_call(&@fn_ctxt fcx, @ast.expr f, vec[@ast.expr] args)
plain_ann(fcx.ccx.tcx)));
}
case (ast.expr_check(?e, _)) {
/* FIXME */
/* presumably, here is where we should check that e is
actually a call to a predicate, where all the arguments
are literals or slot variables? */
case (ast.expr_check_expr(?e, _)) {
auto expr_t = check_expr(fcx, e);
Demand.simple(fcx, expr.span, ty.mk_bool(fcx.ccx.tcx),
expr_ty(fcx.ccx.tcx, expr_t));
ret @fold.respan[ast.expr_]
(expr.span, ast.expr_check(expr_t,
plain_ann(fcx.ccx.tcx)));
}
case (ast.expr_assert(?e, _)) {
auto expr_t = check_expr(fcx, e);
Demand.simple(fcx, expr.span, ty.mk_bool(fcx.ccx.tcx),
expr_ty(fcx.ccx.tcx, expr_t));
ret @fold.respan[ast.expr_]
(expr.span, ast.expr_assert(expr_t,
(expr.span, ast.expr_check_expr(expr_t,
plain_ann(fcx.ccx.tcx)));
}
......
此差异已折叠。
......@@ -392,10 +392,7 @@ fn walk_expr(&ast_visitor v, @ast.expr e) {
case (ast.expr_log(_,?x, _)) {
walk_expr(v, x);
}
case (ast.expr_check(?x, _)) {
walk_expr(v, x);
}
case (ast.expr_assert(?x, _)) {
case (ast.expr_check_expr(?x, _)) {
walk_expr(v, x);
}
case (ast.expr_port(_)) { }
......
......@@ -661,18 +661,12 @@ fn print_opt(ps s, &option.t[@ast.expr] expr) {
}
print_expr(s, expr);
}
case (ast.expr_check(?expr,_)) {
case (ast.expr_check_expr(?expr,_)) {
wrd1(s, "check");
popen_h(s);
print_expr(s, expr);
pclose(s);
}
case (ast.expr_assert(?expr,_)) {
wrd1(s, "assert");
popen_h(s);
print_expr(s, expr);
pclose(s);
}
case (ast.expr_ext(?path, ?args, ?body, _, _)) {
wrd(s.s, "#");
print_path(s, path);
......
......@@ -85,7 +85,7 @@ fn intersect(&precond p1, &precond p2) -> bool {
fn pps_len(&pre_and_post p) -> uint {
// gratuitous check
assert (p.precondition.nbits == p.postcondition.nbits);
check (p.precondition.nbits == p.postcondition.nbits);
ret p.precondition.nbits;
}
......@@ -129,7 +129,7 @@ fn set_prestate(@ts_ann a, &prestate p) -> bool {
// Sets all the bits in a's postcondition to equal the
// corresponding bit in p's postcondition.
fn set_poststate(@ts_ann a, &poststate p) -> bool {
fn set_poststate(&ts_ann a, &poststate p) -> bool {
ret bitv.copy(a.states.poststate, p);
}
......
......@@ -35,7 +35,7 @@ fn color_supported() -> bool {
}
fn set_color(io.buf_writer writer, u8 first_char, u8 color) {
assert (color < 16u8);
check (color < 16u8);
esc(writer);
if (color >= 8u8) {
......
......@@ -27,7 +27,7 @@
fn to_str(int n, uint radix) -> str
{
assert (0u < radix && radix <= 16u);
check (0u < radix && radix <= 16u);
if (n < 0) {
ret "-" + _uint.to_str((-n) as uint, radix);
} else {
......
......@@ -218,14 +218,14 @@ fn utf8_char_width(u8 b) -> uint {
fn char_range_at(str s, uint i) -> tup(char, uint) {
auto b0 = s.(i);
auto w = utf8_char_width(b0);
assert (w != 0u);
check(w != 0u);
if (w == 1u) {ret tup(b0 as char, i + 1u);}
auto val = 0u;
auto end = i + w;
i += 1u;
while (i < end) {
auto byte = s.(i);
assert (byte & 0xc0_u8 == tag_cont_u8);
check(byte & 0xc0_u8 == tag_cont_u8);
val <<= 6u;
val += (byte & 0x3f_u8) as uint;
i += 1u;
......@@ -247,11 +247,11 @@ fn char_len(str s) -> uint {
auto total = byte_len(s);
while (i < total) {
auto chsize = utf8_char_width(s.(i));
assert (chsize > 0u);
check(chsize > 0u);
len += 1u;
i += chsize;
}
assert (i == total);
check(i == total);
ret len;
}
......@@ -274,7 +274,7 @@ fn push_char(&mutable str s, char ch) {
fn pop_char(&mutable str s) -> char {
auto end = byte_len(s);
while (end > 0u && s.(end - 1u) & 0xc0_u8 == tag_cont_u8) {end -= 1u;}
assert (end > 0u);
check(end > 0u);
auto ch = char_at(s, end - 1u);
s = substr(s, 0u, end - 1u);
ret ch;
......@@ -404,7 +404,7 @@ fn slice(str s, uint begin, uint end) -> str {
fn shift_byte(&mutable str s) -> u8 {
auto len = byte_len(s);
assert (len > 0u);
check(len > 0u);
auto b = s.(0);
s = substr(s, 1u, len - 1u);
ret b;
......@@ -412,7 +412,7 @@ fn shift_byte(&mutable str s) -> u8 {
fn pop_byte(&mutable str s) -> u8 {
auto len = byte_len(s);
assert (len > 0u);
check(len > 0u);
auto b = s.(len - 1u);
s = substr(s, 0u, len - 1u);
ret b;
......
......@@ -56,7 +56,7 @@ fn to_str(uint num, uint radix) -> str
{
auto n = num;
assert (0u < radix && radix <= 16u);
check (0u < radix && radix <= 16u);
fn digit(uint n) -> char {
alt (n) {
case (0u) { ret '0'; }
......
......@@ -131,7 +131,7 @@ fn len_set[T](array[T] v, uint n) {
}
fn buf_off[T](array[T] v, uint offset) -> vbuf {
assert (offset < len[T](v));
check (offset < len[T](v));
ret rustrt.vec_buf[T](v, offset);
}
......@@ -149,10 +149,9 @@ fn last[T](array[T] v) -> option.t[T] {
}
// Returns elements from [start..end) from v.
fn slice[T](array[T] v, uint start, uint end) -> vec[T] {
assert (start <= end);
assert (end <= len[T](v));
check (start <= end);
check (end <= len[T](v));
auto result = alloc[T](end - start);
let uint i = start;
while (i < end) {
......@@ -164,7 +163,7 @@ fn slice[T](array[T] v, uint start, uint end) -> vec[T] {
fn shift[T](&mutable array[T] v) -> T {
auto ln = len[T](v);
assert (ln > 0u);
check(ln > 0u);
auto e = v.(0);
v = slice[T](v, 1u, ln);
ret e;
......@@ -172,7 +171,7 @@ fn shift[T](&mutable array[T] v) -> T {
fn pop[T](&mutable array[T] v) -> T {
auto ln = len[T](v);
assert (ln > 0u);
check(ln > 0u);
ln -= 1u;
auto e = v.(ln);
v = slice[T](v, 0u, ln);
......
......@@ -28,8 +28,8 @@ fn create(uint nbits, bool init) -> t {
fn process(&fn(uint, uint) -> uint op, &t v0, &t v1) -> bool {
auto len = _vec.len[mutable uint](v1.storage);
assert (_vec.len[mutable uint](v0.storage) == len);
assert (v0.nbits == v1.nbits);
check (_vec.len[mutable uint](v0.storage) == len);
check (v0.nbits == v1.nbits);
auto changed = false;
......@@ -84,7 +84,7 @@ fn clone(t v) -> t {
}
fn get(&t v, uint i) -> bool {
assert (i < v.nbits);
check (i < v.nbits);
auto bits = uint_bits();
......@@ -129,7 +129,7 @@ fn difference(&t v0, &t v1) -> bool {
}
fn set(&t v, uint i, bool x) {
assert (i < v.nbits);
check (i < v.nbits);
auto bits = uint_bits();
......@@ -196,7 +196,7 @@ fn to_str(&t v) -> str {
// FIXME: can we just use structural equality on to_vec?
fn eq_vec(&t v0, &vec[uint] v1) -> bool {
assert (v0.nbits == _vec.len[uint](v1));
check (v0.nbits == _vec.len[uint](v1));
auto len = v0.nbits;
auto i = 0u;
while (i < len) {
......
......@@ -28,7 +28,7 @@ fn create[T]() -> t[T] {
* elsewhere.
*/
fn grow[T](uint nelts, uint lo, vec[cell[T]] elts) -> vec[cell[T]] {
assert (nelts == _vec.len[cell[T]](elts));
check (nelts == _vec.len[cell[T]](elts));
fn fill[T](uint i, uint nelts, uint lo,
vec[cell[T]] old) -> cell[T] {
......
......@@ -99,7 +99,7 @@ fn doc_data(doc d) -> vec[u8] {
fn be_uint_from_bytes(vec[u8] data, uint start, uint size) -> uint {
auto sz = size;
assert (sz <= 4u);
check (sz <= 4u);
auto val = 0u;
auto pos = start;
while (sz > 0u) {
......
......@@ -10,7 +10,7 @@ fn path_sep() -> str {
fn dirname(path p) -> path {
auto sep = path_sep();
assert (_str.byte_len(sep) == 1u);
check (_str.byte_len(sep) == 1u);
let int i = _str.rindex(p, sep.(0));
if (i == -1) {
ret p;
......
......@@ -72,7 +72,7 @@ fn eof() -> bool {
ret os.libc.feof(f) != 0;
}
fn seek(int offset, seek_style whence) {
assert (os.libc.fseek(f, offset, convert_whence(whence)) == 0);
check (os.libc.fseek(f, offset, convert_whence(whence)) == 0);
}
fn tell() -> uint {
ret os.libc.ftell(f) as uint;
......@@ -101,14 +101,14 @@ fn read_char() -> char {
if (c0 == -1) {ret -1 as char;} // FIXME will this stay valid?
auto b0 = c0 as u8;
auto w = _str.utf8_char_width(b0);
assert (w > 0u);
check(w > 0u);
if (w == 1u) {ret b0 as char;}
auto val = 0u;
while (w > 1u) {
w -= 1u;
auto next = rdr.read_byte();
assert (next > -1);
assert (next & 0xc0 == 0x80);
check(next > -1);
check(next & 0xc0 == 0x80);
val <<= 6u;
val += (next & 0x3f) as uint;
}
......@@ -279,7 +279,7 @@ fn write(vec[u8] v) {
}
fn seek(int offset, seek_style whence) {
assert (os.libc.fseek(f, offset, convert_whence(whence)) == 0);
check(os.libc.fseek(f, offset, convert_whence(whence)) == 0);
}
fn tell() -> uint {
......
......@@ -66,7 +66,7 @@ fn dylib_filename(str base) -> str {
fn pipe() -> tup(int, int) {
let vec[mutable int] fds = vec(mutable 0, 0);
assert (os.libc.pipe(_vec.buf[mutable int](fds)) == 0);
check(os.libc.pipe(_vec.buf[mutable int](fds)) == 0);
ret tup(fds.(0), fds.(1));
}
......@@ -76,7 +76,7 @@ fn fd_FILE(int fd) -> libc.FILE {
fn waitpid(int pid) -> int {
let vec[mutable int] status = vec(mutable 0);
assert (os.libc.waitpid(pid, _vec.buf[mutable int](status), 0) != -1);
check(os.libc.waitpid(pid, _vec.buf[mutable int](status), 0) != -1);
ret status.(0);
}
......
......@@ -63,7 +63,7 @@ fn dylib_filename(str base) -> str {
fn pipe() -> tup(int, int) {
let vec[mutable int] fds = vec(mutable 0, 0);
assert (os.libc.pipe(_vec.buf[mutable int](fds)) == 0);
check(os.libc.pipe(_vec.buf[mutable int](fds)) == 0);
ret tup(fds.(0), fds.(1));
}
......@@ -73,7 +73,7 @@ fn fd_FILE(int fd) -> libc.FILE {
fn waitpid(int pid) -> int {
let vec[mutable int] status = vec(mutable 0);
assert (os.libc.waitpid(pid, _vec.buf[mutable int](status), 0) != -1);
check(os.libc.waitpid(pid, _vec.buf[mutable int](status), 0) != -1);
ret status.(0);
}
......
......@@ -5,7 +5,7 @@
fn list_dir(str path) -> vec[str] {
// TODO ensure this is always closed
auto dir = os.libc.opendir(_str.buf(path));
assert (dir as uint != 0u);
check (dir as uint != 0u);
let vec[str] result = vec();
while (true) {
auto ent = os.libc.readdir(dir);
......
......@@ -43,7 +43,7 @@ fn mk_sha1() -> sha1 {
fn add_input(&sha1state st, &vec[u8] msg) {
// FIXME: Should be typestate precondition
assert (!st.computed);
check (!st.computed);
for (u8 element in msg) {
st.msg_block.(st.msg_block_idx) = element;
......@@ -67,7 +67,7 @@ fn add_input(&sha1state st, &vec[u8] msg) {
fn process_msg_block(&sha1state st) {
// FIXME: Make precondition
assert (_vec.len[mutable u32](st.h) == digest_buf_len);
check (_vec.len[mutable u32](st.h) == digest_buf_len);
// Constants
auto k = vec(0x5A827999u32,
......@@ -192,7 +192,7 @@ fn mk_result(&sha1state st) -> vec[u8] {
*/
fn pad_msg(&sha1state st) {
// FIXME: Should be a precondition
assert (_vec.len[mutable u8](st.msg_block) == msg_block_len);
check (_vec.len[mutable u8](st.msg_block) == msg_block_len);
/*
* Check to see if the current message block is too small to hold
......@@ -236,7 +236,7 @@ fn pad_msg(&sha1state st) {
fn reset() {
// FIXME: Should be typestate precondition
assert (_vec.len[mutable u32](st.h) == digest_buf_len);
check (_vec.len[mutable u32](st.h) == digest_buf_len);
st.len_low = 0u32;
st.len_high = 0u32;
......
......@@ -53,7 +53,7 @@ fn dylib_filename(str base) -> str {
fn pipe() -> tup(int, int) {
let vec[mutable int] fds = vec(mutable 0, 0);
assert (os.libc._pipe(_vec.buf[mutable int](fds), 1024u,
check(os.libc._pipe(_vec.buf[mutable int](fds), 1024u,
libc_constants.O_BINARY()) == 0);
ret tup(fds.(0), fds.(1));
}
......
......@@ -2,5 +2,5 @@
// error-pattern:1 == 2
fn main() {
assert (1 == 2);
check (1 == 2);
}
......@@ -4,7 +4,7 @@
// error-pattern:1 == 2
fn child() {
assert (1 == 2);
check (1 == 2);
}
fn main() {
......
......@@ -6,12 +6,12 @@
fn main() {
let str s = "hello";
let int x = 0;
assert (s.(x) == (0x68 as u8));
check (s.(x) == (0x68 as u8));
// NB: at the moment a string always has a trailing NULL,
// so the largest index value on the string above is 5, not
// 4. Possibly change this.
// Bounds-check failure.
assert (s.(x + 6) == (0x0 as u8));
check (s.(x + 6) == (0x0 as u8));
}
......@@ -6,7 +6,7 @@
fn main() {
let vec[int] v = vec(10);
let int x = 0;
assert (v.(x) == 10);
check (v.(x) == 10);
// Bounds-check failure.
assert (v.(x + 2) == 20);
check (v.(x + 2) == 20);
}
......@@ -6,7 +6,7 @@
fn main() {
let vec[int] v = vec(10, 20);
let int x = 0;
assert (v.(x) == 10);
check (v.(x) == 10);
// Bounds-check failure.
assert (v.(x-1) == 20);
check (v.(x-1) == 20);
}
......@@ -21,12 +21,12 @@ fn foo(str s) {
}
log _str.refcount(s);
assert (_str.refcount(s) == const_refcount);
check (_str.refcount(s) == const_refcount);
}
fn main() {
let str s = "hi"; // ref up
foo(s); // ref up then down
log _str.refcount(s);
assert (_str.refcount(s) == const_refcount);
check (_str.refcount(s) == const_refcount);
}
......@@ -12,6 +12,6 @@ fn altlit(int f) -> int {
}
fn main() {
assert (altlit(10) == 20);
assert (altlit(11) == 22);
check (altlit(10) == 20);
check (altlit(11) == 22);
}
......@@ -32,8 +32,8 @@ fn main() {
let color gray = rgb(127, 127, 127);
let color clear = rgba(50, 150, 250, 0);
let color red = hsl(0, 255, 255);
assert (process(gray) == 127);
assert (process(clear) == 0);
assert (process(red) == 255);
check (process(gray) == 127);
check (process(clear) == 0);
check (process(red) == 255);
}
fn main() -> () {
let int a = 10;
log a;
assert (a * (a - 1) == 90);
check (a * (a - 1) == 90);
}
\ No newline at end of file
fn main() -> () {
let int i32_a = 10;
assert (i32_a == 10);
assert (i32_a - 10 == 0);
assert (i32_a / 10 == 1);
assert (i32_a - 20 == -10);
assert (i32_a << 10 == 10240);
assert (i32_a << 16 == 655360);
assert (i32_a * 16 == 160);
assert (i32_a * i32_a * i32_a == 1000);
assert (i32_a * i32_a * i32_a * i32_a == 10000);
assert (((i32_a * i32_a) / i32_a) * i32_a == 100);
assert (i32_a * (i32_a - 1) << 2 + i32_a == 368640);
check(i32_a == 10);
check(i32_a - 10 == 0);
check(i32_a / 10 == 1);
check(i32_a - 20 == -10);
check(i32_a << 10 == 10240);
check(i32_a << 16 == 655360);
check(i32_a * 16 == 160);
check(i32_a * i32_a * i32_a == 1000);
check(i32_a * i32_a * i32_a * i32_a == 10000);
check(((i32_a * i32_a) / i32_a) * i32_a == 100);
check(i32_a * (i32_a - 1) << 2 + i32_a == 368640);
let int i32_b = 0x10101010;
assert (i32_b + 1 - 1 == i32_b);
assert (i32_b << 1 == i32_b << 1);
assert (i32_b >> 1 == i32_b >> 1);
assert ((i32_b & (i32_b << 1)) == 0);
check(i32_b + 1 - 1 == i32_b);
check(i32_b << 1 == i32_b << 1);
check(i32_b >> 1 == i32_b >> 1);
check((i32_b & (i32_b << 1)) == 0);
log ((i32_b | (i32_b << 1)));
assert ((i32_b | (i32_b << 1)) == 0x30303030);
check((i32_b | (i32_b << 1)) == 0x30303030);
}
\ No newline at end of file
fn main() -> () {
let int i32_c = 0x10101010;
assert (i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3) ==
check (i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3) ==
i32_c + (((i32_c * 2) / 3) * 2) + (i32_c - (7 % 3)));
}
\ No newline at end of file
......@@ -2,24 +2,24 @@
// Unsigned integer operations
fn main() {
assert (0u8 < 255u8);
assert (0u8 <= 255u8);
assert (255u8 > 0u8);
assert (255u8 >= 0u8);
assert (250u8 / 10u8 == 25u8);
assert (255u8 % 10u8 == 5u8);
assert (0u16 < 60000u16);
assert (0u16 <= 60000u16);
assert (60000u16 > 0u16);
assert (60000u16 >= 0u16);
assert (60000u16 / 10u16 == 6000u16);
assert (60005u16 % 10u16 == 5u16);
assert (0u32 < 4000000000u32);
assert (0u32 <= 4000000000u32);
assert (4000000000u32 > 0u32);
assert (4000000000u32 >= 0u32);
assert (4000000000u32 / 10u32 == 400000000u32);
assert (4000000005u32 % 10u32 == 5u32);
check (0u8 < 255u8);
check (0u8 <= 255u8);
check (255u8 > 0u8);
check (255u8 >= 0u8);
check (250u8 / 10u8 == 25u8);
check (255u8 % 10u8 == 5u8);
check (0u16 < 60000u16);
check (0u16 <= 60000u16);
check (60000u16 > 0u16);
check (60000u16 >= 0u16);
check (60000u16 / 10u16 == 6000u16);
check (60005u16 % 10u16 == 5u16);
check (0u32 < 4000000000u32);
check (0u32 <= 4000000000u32);
check (4000000000u32 > 0u32);
check (4000000000u32 >= 0u32);
check (4000000000u32 / 10u32 == 400000000u32);
check (4000000005u32 % 10u32 == 5u32);
// 64-bit numbers have some flakiness yet. Not tested
}
......@@ -8,11 +8,11 @@ fn main() {
let clam b = rec(x=@10, y=@20);
let int z = a.x + b.y;
log z;
assert (z == 21);
check (z == 21);
let fish forty = tup(@40);
let fish two = tup(@2);
let int answer = forty._0 + two._0;
log answer;
assert (answer == 42);
check (answer == 42);
}
......@@ -4,5 +4,5 @@ fn foo(@int a, @int b) -> int {
fn main() {
auto f1 = bind foo(@10, @12);
assert (f1() == 22);
check(f1() == 22);
}
......@@ -7,5 +7,5 @@ fn f(int n) -> int {
fn main() {
let fn() -> int g = bind f(10);
let int i = g();
assert (i == 10);
check(i == 10);
}
......@@ -11,7 +11,7 @@ fn sum() -> int {
auto ctor1 = bind simple(_, 2);
auto obj1 = ctor0(2);
auto obj2 = ctor1(1);
assert (obj0.sum() == 3);
assert (obj1.sum() == 3);
assert (obj2.sum() == 3);
check (obj0.sum() == 3);
check (obj1.sum() == 3);
check (obj2.sum() == 3);
}
......@@ -7,5 +7,5 @@ fn f() -> int {
fn main() {
let fn() -> int g = bind f();
let int i = g();
assert (i == 42);
check(i == 42);
}
......@@ -7,5 +7,5 @@ fn f(int n) -> int {
fn main() {
let fn(int) -> int g = bind f(_);
let int i = g(42);
assert (i == 42);
check(i == 42);
}
......@@ -8,14 +8,14 @@ fn main() {
a = a ^ b;
log a;
log b;
assert (b == 1);
assert (a == 2);
check (b == 1);
check (a == 2);
assert (~(0xf0) & 0xff == 0xf);
assert (0xf0 | 0xf == 0xff);
assert (0xf << 4 == 0xf0);
assert (0xf0 >> 4 == 0xf);
assert (-16 >>> 2 == -4);
assert (0b1010_1010 | 0b0101_0101 == 0xff);
check (~(0xf0) & 0xff == 0xf);
check (0xf0 | 0xf == 0xff);
check (0xf << 4 == 0xf0);
check (0xf0 >> 4 == 0xf);
check (-16 >>> 2 == -4);
check (0b1010_1010 | 0b0101_0101 == 0xff);
}
......@@ -2,14 +2,14 @@
fn main() {
if (!false) {
assert (true);
check (true);
} else {
assert (false);
check (false);
}
if (!true) {
assert (false);
check (false);
} else {
assert (true);
check (true);
}
}
// xfail-boot
fn main() {
assert (@1 < @3);
assert (@@"hello " > @@"hello");
assert (@@@"hello" != @@@"there");
check (@1 < @3);
check (@@"hello " > @@"hello");
check (@@@"hello" != @@@"there");
}
\ No newline at end of file
......@@ -6,5 +6,5 @@ fn main() {
let int foo = 17;
let box[int] bfoo = tup(@foo);
log "see what's in our box";
assert (unbox[int](bfoo) == foo);
check (unbox[int](bfoo) == foo);
}
fn main() {
let @int x = @10;
assert ((*x) == 10);
check ((*x) == 10);
}
......@@ -6,35 +6,35 @@ fn main() {
i += 1;
if (i == 10) { break; }
}
assert (i == 10);
check(i == 10);
do {
i += 1;
if (i == 20) { break; }
} while (i < 30);
assert (i == 20);
check(i == 20);
for (int x in vec(1, 2, 3, 4, 5, 6)) {
if (x == 3) { break; }
assert (x <= 3);
check(x <= 3);
}
i = 0;
while (i < 10) {
i += 1;
if (i % 2 == 0) { cont; }
assert (i % 2 != 0);
check(i % 2 != 0);
}
i = 0;
do {
i += 1;
if (i % 2 == 0) { cont; }
assert (i % 2 != 0);
check(i % 2 != 0);
} while (i < 10);
for (int x in vec(1, 2, 3, 4, 5, 6)) {
if (x % 2 == 0) { cont; }
assert (x % 2 != 0);
check(x % 2 != 0);
}
}
......@@ -3,14 +3,14 @@
fn main() {
let int i = 'Q' as int;
assert (i == 0x51);
check (i == 0x51);
let u32 u = i as u32;
assert (u == (0x51 as u32));
assert (u == ('Q' as u32));
assert ((i as u8) == ('Q' as u8));
assert (((i as u8) as i8) == (('Q' as u8) as i8));
assert ((0x51 as char) == 'Q');
check (u == (0x51 as u32));
check (u == ('Q' as u32));
check ((i as u8) == ('Q' as u8));
check (((i as u8) as i8) == (('Q' as u8) as i8));
check ((0x51 as char) == 'Q');
assert (true == (1 as bool));
assert ((0 as u32) == (false as u32));
check (true == (1 as bool));
check ((0 as u32) == (false as u32));
}
fn main() {
let char c = 'x';
let char d = 'x';
assert (c == 'x');
assert ('x' == c);
assert (c == c);
assert (c == d);
assert (d == c);
assert (d == 'x');
assert ('x' == d);
check(c == 'x');
check('x' == c);
check(c == c);
check(c == d);
check(d == c);
check (d == 'x');
check('x' == d);
}
// xfail-boot
// xfail-stage0
fn f(@rec(int a, int b) x) {
assert (x.a == 10);
assert (x.b == 12);
check (x.a == 10);
check (x.b == 12);
}
fn main() {
......
......@@ -8,7 +8,7 @@ fn main() {
y <- p;
log "received";
log y;
assert (y == 10);
check (y == 10);
}
fn child(chan[int] c) {
......
......@@ -6,9 +6,9 @@ fn main() {
ch <| 10;
let int i <- po;
assert (i == 10);
check (i == 10);
ch <| 11;
auto j <- po;
assert (j == 11);
check (j == 11);
}
......@@ -10,5 +10,5 @@ fn f(int x) -> int {
}
fn main() {
assert (f(5000) == 5000);
check (f(5000) == 5000);
}
......@@ -3,15 +3,15 @@
fn main() {
let int x = 15;
let int y = 5;
assert (x / 5 == 3);
assert (x / 4 == 3);
assert (x / 3 == 5);
assert (x / y == 3);
assert (15 / y == 3);
check(x / 5 == 3);
check(x / 4 == 3);
check(x / 3 == 5);
check(x / y == 3);
check(15 / y == 3);
assert (x % 5 == 0);
assert (x % 4 == 3);
assert (x % 3 == 0);
assert (x % y == 0);
assert (15 % y == 0);
check(x % 5 == 0);
check(x % 4 == 3);
check(x % 3 == 0);
check(x % y == 0);
check(15 % y == 0);
}
fn main() {
if (1 == 2) {
assert (false);
check(false);
} else if (2 == 3) {
assert (false);
check(false);
} else if (3 == 4) {
assert (false);
check(false);
} else {
assert (true);
check(true);
}
if (1 == 2) {
assert (false);
check(false);
} else if (2 == 2) {
assert (true);
check(true);
}
if (1 == 2) {
assert (false);
check(false);
} else if (2 == 2) {
if (1 == 1) {
assert (true);
check(true);
} else {
if (2 == 1) {
assert (false);
check(false);
} else {
assert (false);
check(false);
}
}
}
if (1 == 2) {
assert (false);
check(false);
} else {
if (1 == 2) {
assert (false);
check(false);
} else {
assert (true);
check(true);
}
}
}
......@@ -9,7 +9,7 @@ fn test_box() {
@100
}
};
assert (*res == 100);
check (*res == 100);
}
fn test_str() {
......@@ -18,7 +18,7 @@ fn test_str() {
"happy"
}
};
assert (res == "happy");
check (res == "happy");
}
fn main() {
......
......@@ -9,7 +9,7 @@ fn test_generic[T](@T expected, &compare[T] eq) {
expected
}
};
assert (eq(expected, actual));
check (eq(expected, actual));
}
fn test_box() {
......
......@@ -9,7 +9,7 @@ fn test_generic[T](&T expected, &compare[T] eq) {
expected
}
};
assert (eq(expected, actual));
check (eq(expected, actual));
}
fn test_vec() {
......
......@@ -9,7 +9,7 @@ fn test_generic[T](&T expected, &compare[T] eq) {
expected
}
};
assert (eq(expected, actual));
check (eq(expected, actual));
}
fn test_bool() {
......
......@@ -9,7 +9,7 @@ fn test_rec() {
rec(i = 100)
}
};
assert (res == rec(i = 100));
check (res == rec(i = 100));
}
fn test_tag() {
......@@ -26,7 +26,7 @@ fn test_tag() {
sad
}
};
assert (res == happy);
check (res == happy);
}
fn main() {
......
......@@ -12,7 +12,7 @@ fn test_basic() {
false
}
};
assert (res);
check (res);
res = alt(false) {
case (true) {
......@@ -22,7 +22,7 @@ fn test_basic() {
true
}
};
assert (res);
check (res);
}
fn test_inferrence() {
......@@ -34,7 +34,7 @@ fn test_inferrence() {
false
}
};
assert (res);
check (res);
}
fn test_alt_as_alt_head() {
......@@ -47,7 +47,7 @@ fn test_alt_as_alt_head() {
true
}
};
assert (res);
check (res);
}
fn test_alt_as_block_result() {
......@@ -66,7 +66,7 @@ fn test_alt_as_block_result() {
}
}
};
assert (res);
check (res);
}
fn main() {
......
......@@ -6,5 +6,5 @@ fn main() {
@100
};
assert (*x == 100);
check (*x == 100);
}
......@@ -6,7 +6,7 @@ fn ten() -> int {
ret 10;
}
let t res = { ten };
assert (res() == 10);
check (res() == 10);
}
fn main() {
......
......@@ -5,7 +5,7 @@
fn test_generic[T](@T expected, &compare[T] eq) {
let @T actual = { expected };
assert (eq(expected, actual));
check (eq(expected, actual));
}
fn test_box() {
......
......@@ -5,7 +5,7 @@
fn test_generic[T](&T expected, &compare[T] eq) {
let T actual = { expected };
assert (eq(expected, actual));
check (eq(expected, actual));
}
fn test_vec() {
......
......@@ -7,7 +7,7 @@
fn test_generic[T](&T expected, &compare[T] eq) {
let T actual = { expected };
assert (eq(expected, actual));
check (eq(expected, actual));
}
fn test_bool() {
......
......@@ -5,12 +5,12 @@
fn test_basic() {
let bool res = { true };
assert (res);
check (res);
}
fn test_rec() {
auto res = { rec(v1 = 10, v2 = 20) };
assert (res.v2 == 20);
check (res.v2 == 20);
}
fn test_filled_with_stuff() {
......@@ -21,7 +21,7 @@ fn test_filled_with_stuff() {
}
a
};
assert (res == 10);
check (res == 10);
}
fn main() {
......
......@@ -5,12 +5,12 @@
fn test_box() {
auto res = if (true) { @100 } else { @101 };
assert (*res == 100);
check (*res == 100);
}
fn test_str() {
auto res = if (true) { "happy" } else { "sad" };
assert (res == "happy");
check (res == "happy");
}
fn main() {
......
......@@ -5,7 +5,7 @@
fn test_generic[T](@T expected, @T not_expected, &compare[T] eq) {
let @T actual = if (true) { expected } else { not_expected };
assert (eq(expected, actual));
check (eq(expected, actual));
}
fn test_box() {
......
......@@ -5,7 +5,7 @@
fn test_generic[T](&T expected, &T not_expected, &compare[T] eq) {
let T actual = if (true) { expected } else { not_expected };
assert (eq(expected, actual));
check (eq(expected, actual));
}
fn test_vec() {
......
......@@ -7,7 +7,7 @@
fn test_generic[T](&T expected, &T not_expected, &compare[T] eq) {
let T actual = if (true) { expected } else { not_expected };
assert (eq(expected, actual));
check (eq(expected, actual));
}
fn test_bool() {
......
......@@ -5,7 +5,7 @@
fn test_rec() {
auto res = if (true) { rec(i = 100) } else { rec(i = 101) };
assert (res == rec(i = 100));
check (res == rec(i = 100));
}
fn test_tag() {
......@@ -15,7 +15,7 @@ fn test_tag() {
}
auto res = if (true) { happy } else { sad };
assert (res == happy);
check (res == happy);
}
fn main() {
......
......@@ -5,12 +5,12 @@
fn test_if() {
let bool res = if (true) { true } else { false };
assert (res);
check (res);
}
fn test_else() {
let bool res = if (false) { false } else { true };
assert (res);
check (res);
}
fn test_elseif1() {
......@@ -21,7 +21,7 @@ fn test_elseif1() {
} else {
false
};
assert (res);
check (res);
}
fn test_elseif2() {
......@@ -32,7 +32,7 @@ fn test_elseif2() {
} else {
false
};
assert (res);
check (res);
}
fn test_elseif3() {
......@@ -43,12 +43,12 @@ fn test_elseif3() {
} else {
true
};
assert (res);
check (res);
}
fn test_inferrence() {
auto res = if (true) { true } else { false };
assert (res);
check (res);
}
fn test_if_as_if_condition() {
......@@ -57,14 +57,14 @@ fn test_if_as_if_condition() {
} else {
false
};
assert (res1);
check (res1);
auto res2 = if (if (true) { false } else { true }) {
false
} else {
true
};
assert (res2);
check (res2);
}
fn test_if_as_block_result() {
......@@ -77,7 +77,7 @@ fn test_if_as_block_result() {
} else {
false
};
assert (res);
check (res);
}
fn main() {
......
......@@ -3,16 +3,16 @@
type point = rec(int x, int y, mutable int z);
fn f(@point p) {
assert (p.z == 12);
check (p.z == 12);
p.z = 13;
assert (p.z == 13);
check (p.z == 13);
}
fn main() {
let point a = rec(x=10, y=11, mutable z=12);
let @point b = @a;
assert (b.z == 12);
check (b.z == 12);
f(b);
assert (a.z == 12);
assert (b.z == 13);
check (a.z == 12);
check (b.z == 13);
}
......@@ -15,7 +15,7 @@ fn f(int x) -> int {
}
}
fn main () {
assert (f(5) == 120);
check (f(5) == 120);
// log "all done";
}
......@@ -12,13 +12,13 @@ fn main() {
auto j = 3.1e+9;
auto k = 3.2e-10;
assert (a == b);
assert (c < b);
assert (c == d);
assert (e < g);
assert (f < h);
assert (g == 1000000.0f32);
assert (h == i);
assert (j > k);
assert (k < a);
check(a == b);
check(c < b);
check(c == d);
check(e < g);
check(f < h);
check(g == 1000000.0f32);
check(h == i);
check(j > k);
check(k < a);
}
\ No newline at end of file
// xfail-boot
fn main() {
auto f = 4.999999999999;
assert (f > 4.90);
assert (f < 5.0);
check (f > 4.90);
check (f < 5.0);
auto g = 4.90000000001e-10;
assert (g > 5e-11);
assert (g < 5e-9);
check(g > 5e-11);
check(g < 5e-9);
}
\ No newline at end of file
......@@ -28,12 +28,12 @@ fn main() {
}
}
assert (a.(0) == 0);
assert (a.(1) == 1);
assert (a.(2) == 10);
assert (a.(3) == 11);
assert (a.(4) == 100);
assert (a.(5) == 101);
assert (a.(6) == 110);
assert (a.(7) == 111);
check (a.(0) == 0);
check (a.(1) == 1);
check (a.(2) == 10);
check (a.(3) == 11);
check (a.(4) == 100);
check (a.(5) == 101);
check (a.(6) == 110);
check (a.(7) == 111);
}
......@@ -16,8 +16,8 @@ fn main() {
}
}
assert (a.(0) == 0);
assert (a.(1) == 1);
assert (a.(2) == 10);
assert (a.(3) == 11);
check (a.(0) == 0);
check (a.(1) == 1);
check (a.(2) == 10);
check (a.(3) == 11);
}
......@@ -14,9 +14,9 @@ fn main() {
for each (tup(int,int) p in pairs()) {
log p._0;
log p._1;
assert (p._0 + 10 == i);
check (p._0 + 10 == i);
i += 1;
j = p._1;
}
assert (j == 45);
check(j == 45);
}
\ No newline at end of file
......@@ -9,7 +9,7 @@ fn main() {
}
log "sum";
log sum;
assert (sum == 45);
check (sum == 45);
}
iter first_ten() -> int {
......
......@@ -13,7 +13,7 @@ fn main() {
let int a = direct(3); // direct
//let int b = ho(direct); // indirect unbound
let int c = ho(bind direct(_)); // indirect bound
//assert (a == b);
//assert (b == c);
//check(a == b);
//check(b == c);
}
......@@ -7,5 +7,5 @@ fn f() -> int {
fn main() {
let fn() -> int g = f;
let int i = g();
assert (i == 42);
check(i == 42);
}
......@@ -8,5 +8,5 @@ fn main() {
auto expected = @100;
auto actual = id[@int](expected);
log *actual;
assert (*expected == *actual);
check (*expected == *actual);
}
\ No newline at end of file
......@@ -5,7 +5,7 @@ fn id[T](&T t) -> T {
fn main() {
auto t = tup(1,2,3,4,5,6,7);
assert (t._5 == 6);
check (t._5 == 6);
auto f0 = bind id[tup(int,int,int,int,int,int,int)](t);
assert (f0()._5 == 6);
check (f0()._5 == 6);
}
......@@ -4,7 +4,7 @@ fn id[T](&T t) -> T {
fn main() {
auto t = tup(1,2,3,4,5,6,7);
assert (t._5 == 6);
check (t._5 == 6);
auto f1 = bind id[tup(int,int,int,int,int,int,int)](_);
assert (f1(t)._5 == 6);
check (f1(t)._5 == 6);
}
......@@ -4,5 +4,5 @@ fn box[T](&tup(T,T,T) x) -> @tup(T,T,T) {
fn main() {
let @tup(int,int,int) x = box[int](tup(1,2,3));
assert (x._1 == 2);
check (x._1 == 2);
}
\ No newline at end of file
......@@ -12,6 +12,6 @@ fn main() {
auto b = f[int](10);
log b._0;
log b._1;
assert (b._0 == 10);
assert (b._1 == 10);
check (b._0 == 10);
check (b._1 == 10);
}
......@@ -8,6 +8,6 @@ fn main() {
let int foo = 17;
let tupbox[int] tbfoo = tuplift[int](foo);
let recbox[int] rbfoo = reclift[int](foo);
assert (tbfoo._0 == foo);
assert (rbfoo.x == foo);
check (tbfoo._0 == foo);
check (rbfoo.x == foo);
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册