Implement check-exprs, un-xfail 5 rustc tests.
This commit is contained in:
parent
fc8b5155a8
commit
6d47d2abde
6 changed files with 64 additions and 3 deletions
|
@ -498,8 +498,14 @@ TEST_XFAILS_LLVM := $(TASK_XFAILS) \
|
||||||
|
|
||||||
TEST_XFAILS_SELF := $(filter-out \
|
TEST_XFAILS_SELF := $(filter-out \
|
||||||
$(addprefix test/run-pass/, \
|
$(addprefix test/run-pass/, \
|
||||||
|
bool-not.rs \
|
||||||
|
char.rs \
|
||||||
|
div-mod.rs \
|
||||||
hello.rs \
|
hello.rs \
|
||||||
int.rs), \
|
int.rs \
|
||||||
|
item-name-overload.rs \
|
||||||
|
multiline-comment.rs \
|
||||||
|
), \
|
||||||
$(wildcard test/*/*.rs test/*/*.rc))
|
$(wildcard test/*/*.rs test/*/*.rc))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ tag stmt_ {
|
||||||
stmt_decl(@decl);
|
stmt_decl(@decl);
|
||||||
stmt_ret(option[@expr]);
|
stmt_ret(option[@expr]);
|
||||||
stmt_log(@expr);
|
stmt_log(@expr);
|
||||||
|
stmt_check_expr(@expr);
|
||||||
stmt_expr(@expr);
|
stmt_expr(@expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -690,6 +690,22 @@ io fn parse_stmt(parser p) -> @ast.stmt {
|
||||||
ret @spanned(lo, hi, ast.stmt_log(e));
|
ret @spanned(lo, hi, ast.stmt_log(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case (token.CHECK) {
|
||||||
|
p.bump();
|
||||||
|
alt (p.peek()) {
|
||||||
|
case (token.LPAREN) {
|
||||||
|
auto e = parse_expr(p);
|
||||||
|
auto hi = p.get_span();
|
||||||
|
expect(p, token.SEMI);
|
||||||
|
ret @spanned(lo, hi, ast.stmt_check_expr(e));
|
||||||
|
}
|
||||||
|
case (_) {
|
||||||
|
p.get_session().unimpl("constraint-check stmt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
case (token.LET) {
|
case (token.LET) {
|
||||||
auto decl = parse_let(p);
|
auto decl = parse_let(p);
|
||||||
auto hi = p.get_span();
|
auto hi = p.get_span();
|
||||||
|
|
|
@ -119,6 +119,9 @@ type ast_fold[ENV] =
|
||||||
(fn(&ENV e, &span sp,
|
(fn(&ENV e, &span sp,
|
||||||
@expr e) -> @stmt) fold_stmt_log,
|
@expr e) -> @stmt) fold_stmt_log,
|
||||||
|
|
||||||
|
(fn(&ENV e, &span sp,
|
||||||
|
@expr e) -> @stmt) fold_stmt_check_expr,
|
||||||
|
|
||||||
(fn(&ENV e, &span sp,
|
(fn(&ENV e, &span sp,
|
||||||
@expr e) -> @stmt) fold_stmt_expr,
|
@expr e) -> @stmt) fold_stmt_expr,
|
||||||
|
|
||||||
|
@ -393,6 +396,11 @@ fn fold_stmt[ENV](&ENV env, ast_fold[ENV] fld, &@stmt s) -> @stmt {
|
||||||
ret fld.fold_stmt_log(env_, s.span, ee);
|
ret fld.fold_stmt_log(env_, s.span, ee);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case (ast.stmt_check_expr(?e)) {
|
||||||
|
auto ee = fold_expr(env_, fld, e);
|
||||||
|
ret fld.fold_stmt_check_expr(env_, s.span, ee);
|
||||||
|
}
|
||||||
|
|
||||||
case (ast.stmt_expr(?e)) {
|
case (ast.stmt_expr(?e)) {
|
||||||
auto ee = fold_expr(env_, fld, e);
|
auto ee = fold_expr(env_, fld, e);
|
||||||
ret fld.fold_stmt_expr(env_, s.span, ee);
|
ret fld.fold_stmt_expr(env_, s.span, ee);
|
||||||
|
@ -645,6 +653,10 @@ fn identity_fold_stmt_log[ENV](&ENV e, &span sp, @expr x) -> @stmt {
|
||||||
ret @respan(sp, ast.stmt_log(x));
|
ret @respan(sp, ast.stmt_log(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn identity_fold_stmt_check_expr[ENV](&ENV e, &span sp, @expr x) -> @stmt {
|
||||||
|
ret @respan(sp, ast.stmt_check_expr(x));
|
||||||
|
}
|
||||||
|
|
||||||
fn identity_fold_stmt_expr[ENV](&ENV e, &span sp, @expr x) -> @stmt {
|
fn identity_fold_stmt_expr[ENV](&ENV e, &span sp, @expr x) -> @stmt {
|
||||||
ret @respan(sp, ast.stmt_expr(x));
|
ret @respan(sp, ast.stmt_expr(x));
|
||||||
}
|
}
|
||||||
|
@ -765,6 +777,8 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
|
||||||
fold_stmt_decl = bind identity_fold_stmt_decl[ENV](_,_,_),
|
fold_stmt_decl = bind identity_fold_stmt_decl[ENV](_,_,_),
|
||||||
fold_stmt_ret = bind identity_fold_stmt_ret[ENV](_,_,_),
|
fold_stmt_ret = bind identity_fold_stmt_ret[ENV](_,_,_),
|
||||||
fold_stmt_log = bind identity_fold_stmt_log[ENV](_,_,_),
|
fold_stmt_log = bind identity_fold_stmt_log[ENV](_,_,_),
|
||||||
|
fold_stmt_check_expr
|
||||||
|
= bind identity_fold_stmt_check_expr[ENV](_,_,_),
|
||||||
fold_stmt_expr = bind identity_fold_stmt_expr[ENV](_,_,_),
|
fold_stmt_expr = bind identity_fold_stmt_expr[ENV](_,_,_),
|
||||||
|
|
||||||
fold_item_fn = bind identity_fold_item_fn[ENV](_,_,_,_,_),
|
fold_item_fn = bind identity_fold_item_fn[ENV](_,_,_,_,_),
|
||||||
|
|
|
@ -23,7 +23,7 @@ type env = rec(list[scope] scopes,
|
||||||
|
|
||||||
fn lookup_name(&env e, ast.ident i) -> option[def] {
|
fn lookup_name(&env e, ast.ident i) -> option[def] {
|
||||||
|
|
||||||
log "resolving name " + i;
|
// log "resolving name " + i;
|
||||||
|
|
||||||
fn found_def_item(@ast.item i) -> option[def] {
|
fn found_def_item(@ast.item i) -> option[def] {
|
||||||
alt (i.node) {
|
alt (i.node) {
|
||||||
|
@ -108,7 +108,7 @@ fn fold_expr_name(&env e, &span sp, &ast.name n,
|
||||||
|
|
||||||
alt (d_) {
|
alt (d_) {
|
||||||
case (some[def](_)) {
|
case (some[def](_)) {
|
||||||
log "resolved name " + n.node.ident;
|
// log "resolved name " + n.node.ident;
|
||||||
}
|
}
|
||||||
case (none[def]) {
|
case (none[def]) {
|
||||||
e.sess.err("unresolved name: " + n.node.ident);
|
e.sess.err("unresolved name: " + n.node.ident);
|
||||||
|
|
|
@ -791,6 +791,26 @@ fn trans_log(@block_ctxt cx, &ast.expr e) -> result {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn trans_check_expr(@block_ctxt cx, &ast.expr e) -> result {
|
||||||
|
auto cond_res = trans_expr(cx, e);
|
||||||
|
|
||||||
|
// FIXME: need pretty-printer.
|
||||||
|
auto V_expr_str = p2i(C_str(cx.fcx.tcx, "<expr>"));
|
||||||
|
auto V_filename = p2i(C_str(cx.fcx.tcx, e.span.filename));
|
||||||
|
auto V_line = e.span.lo.line as int;
|
||||||
|
auto args = vec(V_expr_str, V_filename, C_int(V_line));
|
||||||
|
|
||||||
|
auto fail_cx = new_empty_block_ctxt(cx.fcx);
|
||||||
|
auto fail_res = trans_upcall(fail_cx, "upcall_fail", args);
|
||||||
|
|
||||||
|
auto next_cx = new_extension_block_ctxt(cx);
|
||||||
|
fail_res.bcx.build.Br(next_cx.llbb);
|
||||||
|
cond_res.bcx.build.CondBr(cond_res.val,
|
||||||
|
next_cx.llbb,
|
||||||
|
fail_cx.llbb);
|
||||||
|
ret res(next_cx, C_nil());
|
||||||
|
}
|
||||||
|
|
||||||
fn trans_stmt(@block_ctxt cx, &ast.stmt s) -> result {
|
fn trans_stmt(@block_ctxt cx, &ast.stmt s) -> result {
|
||||||
auto sub = res(cx, C_nil());
|
auto sub = res(cx, C_nil());
|
||||||
alt (s.node) {
|
alt (s.node) {
|
||||||
|
@ -798,6 +818,10 @@ fn trans_stmt(@block_ctxt cx, &ast.stmt s) -> result {
|
||||||
sub.bcx = trans_log(cx, *a).bcx;
|
sub.bcx = trans_log(cx, *a).bcx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case (ast.stmt_check_expr(?a)) {
|
||||||
|
sub.bcx = trans_check_expr(cx, *a).bcx;
|
||||||
|
}
|
||||||
|
|
||||||
case (ast.stmt_expr(?e)) {
|
case (ast.stmt_expr(?e)) {
|
||||||
sub.bcx = trans_expr(cx, *e).bcx;
|
sub.bcx = trans_expr(cx, *e).bcx;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue