Allow istrs as patterns. Issue #855
This commit is contained in:
parent
4c25d81041
commit
7924368268
3 changed files with 50 additions and 14 deletions
|
|
@ -296,9 +296,9 @@ fn compile_submatch(bcx: @block_ctxt, m: &match, vals: [ValueRef],
|
|||
let data = m[0].data;
|
||||
alt data.guard {
|
||||
some(e) {
|
||||
let guard_cx = new_scope_block_ctxt(bcx, ~"guard");
|
||||
let next_cx = new_sub_block_ctxt(bcx, ~"next");
|
||||
let else_cx = new_sub_block_ctxt(bcx, ~"else");
|
||||
let guard_cx = new_scope_block_ctxt(bcx, ~"submatch_guard");
|
||||
let next_cx = new_sub_block_ctxt(bcx, ~"submatch_next");
|
||||
let else_cx = new_sub_block_ctxt(bcx, ~"submatch_else");
|
||||
Br(bcx, guard_cx.llbb);
|
||||
// Temporarily set bindings. They'll be rewritten to PHI nodes for
|
||||
// the actual arm block.
|
||||
|
|
@ -431,13 +431,17 @@ fn compile_submatch(bcx: @block_ctxt, m: &match, vals: [ValueRef],
|
|||
llvm::LLVMAddCase(sw, r.val, opt_cx.llbb);
|
||||
}
|
||||
compare. {
|
||||
let compare_cx = new_scope_block_ctxt(bcx, ~"compare_scope");
|
||||
Br(bcx, compare_cx.llbb);
|
||||
bcx = compare_cx;
|
||||
let r = trans_opt(bcx, opt);
|
||||
bcx = r.bcx;
|
||||
let t = ty::node_id_to_type(ccx.tcx, pat_id);
|
||||
let eq =
|
||||
trans::trans_compare(bcx, ast::eq, test_val, t, r.val, t);
|
||||
bcx = new_sub_block_ctxt(bcx, ~"next");
|
||||
CondBr(eq.bcx, eq.val, opt_cx.llbb, bcx.llbb);
|
||||
let cleanup_cx = trans::trans_block_cleanups(bcx, compare_cx);
|
||||
bcx = new_sub_block_ctxt(bcx, ~"compare_next");
|
||||
CondBr(cleanup_cx, eq.val, opt_cx.llbb, bcx.llbb);
|
||||
}
|
||||
_ { }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1497,6 +1497,22 @@ fn parse_pat(p: &parser) -> @ast::pat {
|
|||
pat = ast::pat_tup(fields);
|
||||
}
|
||||
}
|
||||
token::TILDE. {
|
||||
p.bump();
|
||||
alt p.peek() {
|
||||
token::LIT_STR(s) {
|
||||
let sp = p.get_span();
|
||||
p.bump();
|
||||
let lit =
|
||||
@{node: ast::lit_str(p.get_str(s),
|
||||
ast::sk_unique),
|
||||
span: sp};
|
||||
hi = lit.span.hi;
|
||||
pat = ast::pat_lit(lit);
|
||||
}
|
||||
_ { p.fatal(~"expected string literal"); }
|
||||
}
|
||||
}
|
||||
tok {
|
||||
if !is_ident(tok) || is_word(p, ~"true") || is_word(p, ~"false") {
|
||||
let lit = parse_lit(p);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue