Skip to content

Commit d1433fe

Browse files
committed
---
yaml --- r: 2148 b: refs/heads/master c: 6d3a423 h: refs/heads/master v: v3
1 parent 97cf83c commit d1433fe

File tree

11 files changed

+41
-27
lines changed

11 files changed

+41
-27
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 9bfc8bf11e15b7b9a782f1757f9a0ebe324b16e4
2+
refs/heads/master: 6d3a423094c77b25b20afe3a812a67f03080cc3d

trunk/src/comp/front/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ tag expr_ {
289289
expr_ret(option.t[@expr], ann);
290290
expr_put(option.t[@expr], ann);
291291
expr_be(@expr, ann);
292-
expr_log(@expr, ann);
292+
expr_log(int, @expr, ann);
293293
expr_check_expr(@expr, ann);
294294
expr_port(ann);
295295
expr_chan(@expr, ann);

trunk/src/comp/front/lexer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ fn keyword_table() -> std.map.hashmap[str, token.token] {
152152
keywords.insert("const", token.CONST);
153153

154154
keywords.insert("log", token.LOG);
155+
keywords.insert("log_err", token.LOG_ERR);
155156
keywords.insert("spawn", token.SPAWN);
156157
keywords.insert("thread", token.THREAD);
157158
keywords.insert("yield", token.YIELD);

trunk/src/comp/front/parser.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,14 @@ impure fn parse_bottom_expr(parser p) -> @ast.expr {
810810
p.bump();
811811
auto e = parse_expr(p);
812812
auto hi = e.span.hi;
813-
ex = ast.expr_log(e, ast.ann_none);
813+
ex = ast.expr_log(1, e, ast.ann_none);
814+
}
815+
816+
case (token.LOG_ERR) {
817+
p.bump();
818+
auto e = parse_expr(p);
819+
auto hi = e.span.hi;
820+
ex = ast.expr_log(0, e, ast.ann_none);
814821
}
815822

816823
case (token.CHECK) {
@@ -1669,7 +1676,7 @@ fn stmt_ends_with_semi(@ast.stmt stmt) -> bool {
16691676
case (ast.expr_ret(_,_)) { ret true; }
16701677
case (ast.expr_put(_,_)) { ret true; }
16711678
case (ast.expr_be(_,_)) { ret true; }
1672-
case (ast.expr_log(_,_)) { ret true; }
1679+
case (ast.expr_log(_,_,_)) { ret true; }
16731680
case (ast.expr_check_expr(_,_)) { ret true; }
16741681
}
16751682
}

trunk/src/comp/front/token.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ tag token {
119119

120120
/* Magic runtime services */
121121
LOG;
122+
LOG_ERR;
122123
SPAWN;
123124
BIND;
124125
THREAD;
@@ -291,6 +292,7 @@ fn to_str(token t) -> str {
291292

292293
/* Magic runtime services */
293294
case (LOG) { ret "log"; }
295+
case (LOG_ERR) { ret "log_err"; }
294296
case (SPAWN) { ret "spawn"; }
295297
case (BIND) { ret "bind"; }
296298
case (THREAD) { ret "thread"; }

trunk/src/comp/middle/fold.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ type ast_fold[ENV] =
193193
(fn(&ENV e, &span sp,
194194
@expr e, ann a) -> @expr) fold_expr_be,
195195

196-
(fn(&ENV e, &span sp,
196+
(fn(&ENV e, &span sp, int lvl,
197197
@expr e, ann a) -> @expr) fold_expr_log,
198198

199199
(fn(&ENV e, &span sp,
@@ -793,10 +793,10 @@ fn fold_expr[ENV](&ENV env, ast_fold[ENV] fld, &@expr e) -> @expr {
793793
ret fld.fold_expr_be(env_, e.span, ee, t2);
794794
}
795795

796-
case (ast.expr_log(?x, ?t)) {
796+
case (ast.expr_log(?l, ?x, ?t)) {
797797
auto ee = fold_expr(env_, fld, x);
798798
auto t2 = fld.fold_ann(env_, t);
799-
ret fld.fold_expr_log(env_, e.span, ee, t2);
799+
ret fld.fold_expr_log(env_, e.span, l, ee, t2);
800800
}
801801

802802
case (ast.expr_check_expr(?x, ?t)) {
@@ -1378,9 +1378,9 @@ fn identity_fold_expr_be[ENV](&ENV env, &span sp, @expr x, ann a) -> @expr {
13781378
ret @respan(sp, ast.expr_be(x, a));
13791379
}
13801380

1381-
fn identity_fold_expr_log[ENV](&ENV e, &span sp, @expr x,
1381+
fn identity_fold_expr_log[ENV](&ENV e, &span sp, int lvl, @expr x,
13821382
ann a) -> @expr {
1383-
ret @respan(sp, ast.expr_log(x, a));
1383+
ret @respan(sp, ast.expr_log(lvl, x, a));
13841384
}
13851385

13861386
fn identity_fold_expr_check_expr[ENV](&ENV e, &span sp, @expr x, ann a)
@@ -1679,7 +1679,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
16791679
fold_expr_ret = bind identity_fold_expr_ret[ENV](_,_,_,_),
16801680
fold_expr_put = bind identity_fold_expr_put[ENV](_,_,_,_),
16811681
fold_expr_be = bind identity_fold_expr_be[ENV](_,_,_,_),
1682-
fold_expr_log = bind identity_fold_expr_log[ENV](_,_,_,_),
1682+
fold_expr_log = bind identity_fold_expr_log[ENV](_,_,_,_,_),
16831683
fold_expr_check_expr
16841684
= bind identity_fold_expr_check_expr[ENV](_,_,_,_),
16851685
fold_expr_port = bind identity_fold_expr_port[ENV](_,_,_),

trunk/src/comp/middle/trans.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4901,8 +4901,8 @@ fn trans_expr(@block_ctxt cx, @ast.expr e) -> result {
49014901
ret trans_fail(cx, e.span, "explicit failure");
49024902
}
49034903

4904-
case (ast.expr_log(?a, _)) {
4905-
ret trans_log(cx, a);
4904+
case (ast.expr_log(?lvl, ?a, _)) {
4905+
ret trans_log(lvl, cx, a);
49064906
}
49074907

49084908
case (ast.expr_check_expr(?a, _)) {
@@ -4989,7 +4989,7 @@ fn load_if_immediate(@block_ctxt cx, ValueRef v, @ty.t t) -> ValueRef {
49894989
ret v;
49904990
}
49914991

4992-
fn trans_log(@block_ctxt cx, @ast.expr e) -> result {
4992+
fn trans_log(int lvl, @block_ctxt cx, @ast.expr e) -> result {
49934993
auto lcx = cx.fcx.lcx;
49944994
auto modname = _str.connect(lcx.module_path, ".");
49954995
auto global;
@@ -5008,7 +5008,7 @@ fn trans_log(@block_ctxt cx, @ast.expr e) -> result {
50085008
auto log_cx = new_sub_block_ctxt(cx, "log");
50095009
auto after_cx = new_sub_block_ctxt(cx, "after");
50105010
auto load = cx.build.Load(global);
5011-
auto test = cx.build.ICmp(lib.llvm.LLVMIntSGE, load, C_int(1));
5011+
auto test = cx.build.ICmp(lib.llvm.LLVMIntSGE, load, C_int(lvl));
50125012
cx.build.CondBr(test, log_cx.llbb, after_cx.llbb);
50135013

50145014
auto sub = trans_expr(log_cx, e);
@@ -5032,27 +5032,28 @@ fn trans_log(@block_ctxt cx, @ast.expr e) -> result {
50325032
if (is32bit) {
50335033
trans_upcall(sub.bcx,
50345034
"upcall_log_float",
5035-
vec(sub.val)).bcx.build.Br(after_cx.llbb);
5035+
vec(C_int(lvl), sub.val)).bcx.build.Br(after_cx.llbb);
50365036
} else {
50375037
auto tmp = alloca(sub.bcx, tr);
50385038
sub.bcx.build.Store(sub.val, tmp);
50395039
auto v = vp2i(sub.bcx, tmp);
50405040
trans_upcall(sub.bcx,
50415041
"upcall_log_double",
5042-
vec(v)).bcx.build.Br(after_cx.llbb);
5042+
vec(C_int(lvl), v)).bcx.build.Br(after_cx.llbb);
50435043
}
50445044
} else {
50455045
alt (e_ty.struct) {
50465046
case (ty.ty_str) {
50475047
auto v = vp2i(sub.bcx, sub.val);
50485048
trans_upcall(sub.bcx,
50495049
"upcall_log_str",
5050-
vec(v)).bcx.build.Br(after_cx.llbb);
5050+
vec(C_int(lvl), v)).bcx.build.Br(after_cx.llbb);
50515051
}
50525052
case (_) {
5053+
auto v = vec(C_int(lvl), sub.val);
50535054
trans_upcall(sub.bcx,
50545055
"upcall_log_int",
5055-
vec(sub.val)).bcx.build.Br(after_cx.llbb);
5056+
v).bcx.build.Br(after_cx.llbb);
50565057
}
50575058
}
50585059
}

trunk/src/comp/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ fn expr_ann(@ast.expr expr) -> option.t[ast.ann] {
913913
case (ast.expr_fail(_)) { ret none[ast.ann]; }
914914
case (ast.expr_break(_)) { ret none[ast.ann]; }
915915
case (ast.expr_cont(_)) { ret none[ast.ann]; }
916-
case (ast.expr_log(_,_)) { ret none[ast.ann]; }
916+
case (ast.expr_log(_,_,_)) { ret none[ast.ann]; }
917917
case (ast.expr_check_expr(_,_)) { ret none[ast.ann]; }
918918
case (ast.expr_ret(_,_)) { ret none[ast.ann]; }
919919
case (ast.expr_put(_,_)) { ret none[ast.ann]; }

trunk/src/comp/middle/typeck.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ mod Pushdown {
13821382
}
13831383
/* FIXME: should this check the type annotations? */
13841384
case (ast.expr_fail(_)) { e_1 = e.node; }
1385-
case (ast.expr_log(_,_)) { e_1 = e.node; }
1385+
case (ast.expr_log(_,_,_)) { e_1 = e.node; }
13861386
case (ast.expr_break(_)) { e_1 = e.node; }
13871387
case (ast.expr_cont(_)) { e_1 = e.node; }
13881388
case (ast.expr_ret(_,_)) { e_1 = e.node; }
@@ -1905,10 +1905,10 @@ fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
19051905
boring_ann()));
19061906
}
19071907

1908-
case (ast.expr_log(?e,_)) {
1908+
case (ast.expr_log(_,?e,_)) {
19091909
auto expr_t = check_expr(fcx, e);
19101910
ret @fold.respan[ast.expr_]
1911-
(expr.span, ast.expr_log(expr_t, boring_ann()));
1911+
(expr.span, ast.expr_log(_, expr_t, boring_ann()));
19121912
}
19131913

19141914
case (ast.expr_check_expr(?e, _)) {

trunk/src/comp/middle/typestate_check.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ fn expr_ann(&expr e) -> ann {
384384
case (ast.expr_be(_,?a)) {
385385
ret a;
386386
}
387-
case (ast.expr_log(_,?a)) {
387+
case (ast.expr_log(_,_,?a)) {
388388
ret a;
389389
}
390390
case (ast.expr_check_expr(_,?a)) {
@@ -784,7 +784,7 @@ fn find_pre_post_expr(&_fn_info_map fm, &fn_info enclosing, &expr e) -> () {
784784
// Otherwise, variable is global, so it must be initialized
785785
set_pre_and_post(a, res);
786786
}
787-
case(expr_log(?arg, ?a)) {
787+
case(expr_log(_, ?arg, ?a)) {
788788
find_pre_post_expr(fm, enclosing, *arg);
789789
set_pre_and_post(a, expr_pp(*arg));
790790
}
@@ -1099,7 +1099,7 @@ fn find_pre_post_state_expr(&_fn_info_map fm, &fn_info enclosing,
10991099
case (expr_path(_,_,?a)) {
11001100
ret pure_exp(a, pres);
11011101
}
1102-
case (expr_log(?e,?a)) {
1102+
case (expr_log(_,?e,?a)) {
11031103
changed = find_pre_post_state_expr(fm, enclosing, pres, e);
11041104
changed = extend_prestate_ann(a, pres) || changed;
11051105
changed = extend_poststate_ann(a, expr_poststate(*e)) || changed;

trunk/src/comp/pretty/pprust.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,11 @@ impure fn print_expr(ps s, &@ast.expr expr) {
647647
wrd1(s, "be");
648648
print_expr(s, result);
649649
}
650-
case (ast.expr_log(?expr,_)) {
651-
wrd1(s, "log");
650+
case (ast.expr_log(?lvl,?expr,_)) {
651+
alt (lvl) {
652+
case (1) {wrd1(s, "log");}
653+
case (0) {wrd1(s, "log_err");}
654+
}
652655
print_expr(s, expr);
653656
}
654657
case (ast.expr_check_expr(?expr,_)) {

0 commit comments

Comments
 (0)