aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarijn Haverbeke <[email protected]>2011-04-19 10:15:26 +0200
committerMarijn Haverbeke <[email protected]>2011-04-19 16:57:13 +0200
commit9bfc8bf11e15b7b9a782f1757f9a0ebe324b16e4 (patch)
tree688d5ac52ff6cdcdeb364dfe4b418370a9aee5ab /src
parentPrecision overrides 0-padding in #fmt (diff)
downloadrust-9bfc8bf11e15b7b9a782f1757f9a0ebe324b16e4.tar.xz
rust-9bfc8bf11e15b7b9a782f1757f9a0ebe324b16e4.zip
Add log_err to rustboot
Diffstat (limited to 'src')
-rw-r--r--src/boot/fe/ast.ml8
-rw-r--r--src/boot/fe/item.ml5
-rw-r--r--src/boot/fe/lexer.mll1
-rw-r--r--src/boot/fe/token.ml2
-rw-r--r--src/boot/me/trans.ml19
-rw-r--r--src/boot/me/type.ml2
-rw-r--r--src/boot/me/typestate.ml2
-rw-r--r--src/boot/me/walk.ml2
-rw-r--r--src/comp/middle/walk.rs2
-rw-r--r--src/rt/rust_upcall.cpp8
10 files changed, 35 insertions, 16 deletions
diff --git a/src/boot/fe/ast.ml b/src/boot/fe/ast.ml
index 8ea03a63..f498fb0e 100644
--- a/src/boot/fe/ast.ml
+++ b/src/boot/fe/ast.ml
@@ -229,6 +229,7 @@ and stmt' =
| STMT_join of lval
| STMT_send of (lval * lval)
| STMT_log of atom
+ | STMT_log_err of atom
| STMT_note of atom
| STMT_prove of (constrs)
| STMT_check of (constrs * check_calls)
@@ -1210,6 +1211,13 @@ and fmt_stmt_body (ff:Format.formatter) (s:stmt) : unit =
fmt ff ";"
end
+ | STMT_log_err at ->
+ begin
+ fmt ff "log_err ";
+ fmt_atom ff at;
+ fmt ff ";"
+ end
+
| STMT_spawn (dst, domain, name, fn, args) ->
fmt_lval ff dst;
fmt ff " = spawn ";
diff --git a/src/boot/fe/item.ml b/src/boot/fe/item.ml
index fce89373..5f8a0d30 100644
--- a/src/boot/fe/item.ml
+++ b/src/boot/fe/item.ml
@@ -186,6 +186,11 @@ and parse_stmts_including_none (ps:pstate) : Ast.stmt array =
let (stmts, atom) = ctxt "stmts: log value" parse_expr_atom ps in
expect ps SEMI;
spans ps stmts apos (Ast.STMT_log atom)
+ | LOG_ERR ->
+ bump ps;
+ let (stmts, atom) = ctxt "stmts: log value" parse_expr_atom ps in
+ expect ps SEMI;
+ spans ps stmts apos (Ast.STMT_log_err atom)
| BREAK ->
bump ps;
expect ps SEMI;
diff --git a/src/boot/fe/lexer.mll b/src/boot/fe/lexer.mll
index 40e13141..513818b3 100644
--- a/src/boot/fe/lexer.mll
+++ b/src/boot/fe/lexer.mll
@@ -117,6 +117,7 @@
("const", CONST);
("log", LOG);
+ ("log_err", LOG_ERR);
("break", BREAK);
("cont", CONT);
("spawn", SPAWN);
diff --git a/src/boot/fe/token.ml b/src/boot/fe/token.ml
index 18da8c6d..7b4f04b2 100644
--- a/src/boot/fe/token.ml
+++ b/src/boot/fe/token.ml
@@ -106,6 +106,7 @@ type token =
(* Magic runtime services *)
| LOG
+ | LOG_ERR
| SPAWN
| BIND
| THREAD
@@ -269,6 +270,7 @@ let rec string_of_tok t =
(* Magic runtime services *)
| LOG -> "log"
+ | LOG_ERR -> "log_err"
| SPAWN -> "spawn"
| BIND -> "bind"
| THREAD -> "thread"
diff --git a/src/boot/me/trans.ml b/src/boot/me/trans.ml
index bb74d721..52a78cec 100644
--- a/src/boot/me/trans.ml
+++ b/src/boot/me/trans.ml
@@ -2663,11 +2663,11 @@ let trans_visitor
abi.Abi.abi_emit_native_void_call (emitter())
nabi_rust (upcall_fixup name) args);
- and trans_log_int (a:Ast.atom) : unit =
- trans_void_upcall "upcall_log_int" [| (trans_atom a) |]
+ and trans_log_int lev (a:Ast.atom) : unit =
+ trans_void_upcall "upcall_log_int" [| simm (Int64.of_int lev); (trans_atom a) |]
- and trans_log_str (a:Ast.atom) : unit =
- trans_void_upcall "upcall_log_str" [| (trans_atom a) |]
+ and trans_log_str lev (a:Ast.atom) : unit =
+ trans_void_upcall "upcall_log_str" [| simm (Int64.of_int lev); (trans_atom a) |]
and trans_spawn
((*initializing*)_:bool)
@@ -5236,17 +5236,17 @@ let trans_visitor
| _ -> bug () "Calling unexpected lval."
- and trans_log id a =
+ and trans_log lev id a =
match simplified_ty (atom_type cx a) with
(* NB: If you extend this, be sure to update the
* typechecking code in type.ml as well. *)
- Ast.TY_str -> trans_log_str a
+ Ast.TY_str -> trans_log_str lev a
| Ast.TY_int | Ast.TY_uint | Ast.TY_bool
| Ast.TY_char | Ast.TY_mach (TY_u8)
| Ast.TY_mach (TY_u16) | Ast.TY_mach (TY_u32)
| Ast.TY_mach (TY_i8) | Ast.TY_mach (TY_i16)
| Ast.TY_mach (TY_i32) ->
- trans_log_int a
+ trans_log_int lev a
| _ -> unimpl (Some id) "logging type"
and trans_while (id:node_id) (sw:Ast.stmt_while) : unit =
@@ -5284,7 +5284,10 @@ let trans_visitor
match stmt.node with
Ast.STMT_log a ->
- trans_log stmt.id a
+ trans_log 1 stmt.id a
+
+ | Ast.STMT_log_err a ->
+ trans_log 0 stmt.id a
| Ast.STMT_check_expr e ->
trans_check_expr stmt.id e
diff --git a/src/boot/me/type.ml b/src/boot/me/type.ml
index b8ebf242..b9aaf360 100644
--- a/src/boot/me/type.ml
+++ b/src/boot/me/type.ml
@@ -1125,7 +1125,7 @@ let check_block (cx:Semant.ctxt) : (fn_ctx -> Ast.block -> unit) =
let value_ty = demand_chan (check_lval chan) in
infer_lval ~mut:Ast.MUT_immutable value_ty value
- | Ast.STMT_log x | Ast.STMT_note x ->
+ | Ast.STMT_log x | Ast.STMT_note x | Ast.STMT_log_err x ->
(* always well-typed, just record type in passing. *)
ignore (check_atom x)
diff --git a/src/boot/me/typestate.ml b/src/boot/me/typestate.ml
index 4c55c12e..58b2f673 100644
--- a/src/boot/me/typestate.ml
+++ b/src/boot/me/typestate.ml
@@ -697,7 +697,7 @@ let condition_assigning_visitor
let precond = slot_inits (lval_slots cx lval) in
raise_pre_post_cond s.id precond
- | Ast.STMT_log atom ->
+ | Ast.STMT_log atom | Ast.STMT_log_err atom ->
let precond = slot_inits (atom_slots cx atom) in
raise_pre_post_cond s.id precond
diff --git a/src/boot/me/walk.ml b/src/boot/me/walk.ml
index d703ee69..131005e5 100644
--- a/src/boot/me/walk.ml
+++ b/src/boot/me/walk.ml
@@ -387,7 +387,7 @@ and walk_stmt
in
let children _ =
match s.node with
- Ast.STMT_log a ->
+ Ast.STMT_log a | Ast.STMT_log_err a ->
walk_atom v a
| Ast.STMT_new_rec (lv, atab, base) ->
diff --git a/src/comp/middle/walk.rs b/src/comp/middle/walk.rs
index c0248864..cdfa363a 100644
--- a/src/comp/middle/walk.rs
+++ b/src/comp/middle/walk.rs
@@ -390,7 +390,7 @@ fn walk_expr(&ast_visitor v, @ast.expr e) {
case (ast.expr_be(?x, _)) {
walk_expr(v, x);
}
- case (ast.expr_log(?x, _)) {
+ case (ast.expr_log(_,?x, _)) {
walk_expr(v, x);
}
case (ast.expr_check_expr(?x, _)) {
diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp
index 6318b6e2..b022b853 100644
--- a/src/rt/rust_upcall.cpp
+++ b/src/rt/rust_upcall.cpp
@@ -29,28 +29,28 @@ upcall_grow_task(rust_task *task, size_t n_frame_bytes) {
}
extern "C" CDECL
-void upcall_log_int(rust_task *task, int32_t i) {
+void upcall_log_int(rust_task *task, int32_t level, int32_t i) {
LOG_UPCALL_ENTRY(task);
LOG(task, rust_log::UPCALL | rust_log::ULOG,
"rust: %" PRId32 " (0x%" PRIx32 ")", i, i);
}
extern "C" CDECL
-void upcall_log_float(rust_task *task, float f) {
+void upcall_log_float(rust_task *task, int32_t level, float f) {
LOG_UPCALL_ENTRY(task);
LOG(task, rust_log::UPCALL | rust_log::ULOG,
"rust: %12.12f", f);
}
extern "C" CDECL
-void upcall_log_double(rust_task *task, double *f) {
+void upcall_log_double(rust_task *task, int32_t level, double *f) {
LOG_UPCALL_ENTRY(task);
LOG(task, rust_log::UPCALL | rust_log::ULOG,
"rust: %12.12f", *f);
}
extern "C" CDECL void
-upcall_log_str(rust_task *task, rust_str *str) {
+upcall_log_str(rust_task *task, int32_t level, rust_str *str) {
LOG_UPCALL_ENTRY(task);
const char *c = str_buf(task, str);
LOG(task, rust_log::UPCALL | rust_log::ULOG, "rust: %s", c);