Skip to content

Commit 97cf83c

Browse files
committed
---
yaml --- r: 2147 b: refs/heads/master c: 9bfc8bf h: refs/heads/master i: 2145: 9dcba14 2143: 4b62981 v: v3
1 parent 9fa5972 commit 97cf83c

File tree

11 files changed

+36
-17
lines changed

11 files changed

+36
-17
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: 7f90000ab6d823300c73a232715bb965935c932d
2+
refs/heads/master: 9bfc8bf11e15b7b9a782f1757f9a0ebe324b16e4

trunk/src/boot/fe/ast.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ and stmt' =
229229
| STMT_join of lval
230230
| STMT_send of (lval * lval)
231231
| STMT_log of atom
232+
| STMT_log_err of atom
232233
| STMT_note of atom
233234
| STMT_prove of (constrs)
234235
| STMT_check of (constrs * check_calls)
@@ -1210,6 +1211,13 @@ and fmt_stmt_body (ff:Format.formatter) (s:stmt) : unit =
12101211
fmt ff ";"
12111212
end
12121213

1214+
| STMT_log_err at ->
1215+
begin
1216+
fmt ff "log_err ";
1217+
fmt_atom ff at;
1218+
fmt ff ";"
1219+
end
1220+
12131221
| STMT_spawn (dst, domain, name, fn, args) ->
12141222
fmt_lval ff dst;
12151223
fmt ff " = spawn ";

trunk/src/boot/fe/item.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ and parse_stmts_including_none (ps:pstate) : Ast.stmt array =
186186
let (stmts, atom) = ctxt "stmts: log value" parse_expr_atom ps in
187187
expect ps SEMI;
188188
spans ps stmts apos (Ast.STMT_log atom)
189+
| LOG_ERR ->
190+
bump ps;
191+
let (stmts, atom) = ctxt "stmts: log value" parse_expr_atom ps in
192+
expect ps SEMI;
193+
spans ps stmts apos (Ast.STMT_log_err atom)
189194
| BREAK ->
190195
bump ps;
191196
expect ps SEMI;

trunk/src/boot/fe/lexer.mll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
("const", CONST);
118118

119119
("log", LOG);
120+
("log_err", LOG_ERR);
120121
("break", BREAK);
121122
("cont", CONT);
122123
("spawn", SPAWN);

trunk/src/boot/fe/token.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ type token =
106106

107107
(* Magic runtime services *)
108108
| LOG
109+
| LOG_ERR
109110
| SPAWN
110111
| BIND
111112
| THREAD
@@ -269,6 +270,7 @@ let rec string_of_tok t =
269270

270271
(* Magic runtime services *)
271272
| LOG -> "log"
273+
| LOG_ERR -> "log_err"
272274
| SPAWN -> "spawn"
273275
| BIND -> "bind"
274276
| THREAD -> "thread"

trunk/src/boot/me/trans.ml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2663,11 +2663,11 @@ let trans_visitor
26632663
abi.Abi.abi_emit_native_void_call (emitter())
26642664
nabi_rust (upcall_fixup name) args);
26652665

2666-
and trans_log_int (a:Ast.atom) : unit =
2667-
trans_void_upcall "upcall_log_int" [| (trans_atom a) |]
2666+
and trans_log_int lev (a:Ast.atom) : unit =
2667+
trans_void_upcall "upcall_log_int" [| simm (Int64.of_int lev); (trans_atom a) |]
26682668

2669-
and trans_log_str (a:Ast.atom) : unit =
2670-
trans_void_upcall "upcall_log_str" [| (trans_atom a) |]
2669+
and trans_log_str lev (a:Ast.atom) : unit =
2670+
trans_void_upcall "upcall_log_str" [| simm (Int64.of_int lev); (trans_atom a) |]
26712671

26722672
and trans_spawn
26732673
((*initializing*)_:bool)
@@ -5236,17 +5236,17 @@ let trans_visitor
52365236
| _ -> bug () "Calling unexpected lval."
52375237

52385238

5239-
and trans_log id a =
5239+
and trans_log lev id a =
52405240
match simplified_ty (atom_type cx a) with
52415241
(* NB: If you extend this, be sure to update the
52425242
* typechecking code in type.ml as well. *)
5243-
Ast.TY_str -> trans_log_str a
5243+
Ast.TY_str -> trans_log_str lev a
52445244
| Ast.TY_int | Ast.TY_uint | Ast.TY_bool
52455245
| Ast.TY_char | Ast.TY_mach (TY_u8)
52465246
| Ast.TY_mach (TY_u16) | Ast.TY_mach (TY_u32)
52475247
| Ast.TY_mach (TY_i8) | Ast.TY_mach (TY_i16)
52485248
| Ast.TY_mach (TY_i32) ->
5249-
trans_log_int a
5249+
trans_log_int lev a
52505250
| _ -> unimpl (Some id) "logging type"
52515251

52525252
and trans_while (id:node_id) (sw:Ast.stmt_while) : unit =
@@ -5284,7 +5284,10 @@ let trans_visitor
52845284
match stmt.node with
52855285

52865286
Ast.STMT_log a ->
5287-
trans_log stmt.id a
5287+
trans_log 1 stmt.id a
5288+
5289+
| Ast.STMT_log_err a ->
5290+
trans_log 0 stmt.id a
52885291

52895292
| Ast.STMT_check_expr e ->
52905293
trans_check_expr stmt.id e

trunk/src/boot/me/type.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ let check_block (cx:Semant.ctxt) : (fn_ctx -> Ast.block -> unit) =
11251125
let value_ty = demand_chan (check_lval chan) in
11261126
infer_lval ~mut:Ast.MUT_immutable value_ty value
11271127

1128-
| Ast.STMT_log x | Ast.STMT_note x ->
1128+
| Ast.STMT_log x | Ast.STMT_note x | Ast.STMT_log_err x ->
11291129
(* always well-typed, just record type in passing. *)
11301130
ignore (check_atom x)
11311131

trunk/src/boot/me/typestate.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ let condition_assigning_visitor
697697
let precond = slot_inits (lval_slots cx lval) in
698698
raise_pre_post_cond s.id precond
699699

700-
| Ast.STMT_log atom ->
700+
| Ast.STMT_log atom | Ast.STMT_log_err atom ->
701701
let precond = slot_inits (atom_slots cx atom) in
702702
raise_pre_post_cond s.id precond
703703

trunk/src/boot/me/walk.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ and walk_stmt
387387
in
388388
let children _ =
389389
match s.node with
390-
Ast.STMT_log a ->
390+
Ast.STMT_log a | Ast.STMT_log_err a ->
391391
walk_atom v a
392392

393393
| Ast.STMT_new_rec (lv, atab, base) ->

trunk/src/comp/middle/walk.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ fn walk_expr(&ast_visitor v, @ast.expr e) {
390390
case (ast.expr_be(?x, _)) {
391391
walk_expr(v, x);
392392
}
393-
case (ast.expr_log(?x, _)) {
393+
case (ast.expr_log(_,?x, _)) {
394394
walk_expr(v, x);
395395
}
396396
case (ast.expr_check_expr(?x, _)) {

trunk/src/rt/rust_upcall.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,28 @@ upcall_grow_task(rust_task *task, size_t n_frame_bytes) {
2929
}
3030

3131
extern "C" CDECL
32-
void upcall_log_int(rust_task *task, int32_t i) {
32+
void upcall_log_int(rust_task *task, int32_t level, int32_t i) {
3333
LOG_UPCALL_ENTRY(task);
3434
LOG(task, rust_log::UPCALL | rust_log::ULOG,
3535
"rust: %" PRId32 " (0x%" PRIx32 ")", i, i);
3636
}
3737

3838
extern "C" CDECL
39-
void upcall_log_float(rust_task *task, float f) {
39+
void upcall_log_float(rust_task *task, int32_t level, float f) {
4040
LOG_UPCALL_ENTRY(task);
4141
LOG(task, rust_log::UPCALL | rust_log::ULOG,
4242
"rust: %12.12f", f);
4343
}
4444

4545
extern "C" CDECL
46-
void upcall_log_double(rust_task *task, double *f) {
46+
void upcall_log_double(rust_task *task, int32_t level, double *f) {
4747
LOG_UPCALL_ENTRY(task);
4848
LOG(task, rust_log::UPCALL | rust_log::ULOG,
4949
"rust: %12.12f", *f);
5050
}
5151

5252
extern "C" CDECL void
53-
upcall_log_str(rust_task *task, rust_str *str) {
53+
upcall_log_str(rust_task *task, int32_t level, rust_str *str) {
5454
LOG_UPCALL_ENTRY(task);
5555
const char *c = str_buf(task, str);
5656
LOG(task, rust_log::UPCALL | rust_log::ULOG, "rust: %s", c);

0 commit comments

Comments
 (0)