feat(library/vm): add 'trace'
This commit is contained in:
parent
586e9447d1
commit
dde4a46fe3
3 changed files with 13 additions and 3 deletions
|
|
@ -8,7 +8,7 @@ import init.datatypes init.reserved_notation init.logic
|
|||
import init.relation init.nat init.prod
|
||||
import init.bool init.num init.sigma init.measurable init.setoid init.quot
|
||||
import init.funext init.function init.subtype init.classical init.simplifier
|
||||
import init.monad init.fin init.list init.char init.string init.to_string init.timeit
|
||||
import init.unsigned init.ordering
|
||||
import init.monad init.fin init.list init.char init.string init.to_string
|
||||
import init.timeit init.trace init.unsigned init.ordering
|
||||
import init.meta
|
||||
import init.wf init.wf_k
|
||||
|
|
|
|||
|
|
@ -7,18 +7,25 @@ Author: Leonardo de Moura
|
|||
#include <string>
|
||||
#include <iostream>
|
||||
#include "util/timeit.h"
|
||||
#include "library/trace.h"
|
||||
#include "library/vm/vm.h"
|
||||
#include "library/vm/vm_string.h"
|
||||
|
||||
namespace lean {
|
||||
vm_obj vm_timeit(vm_obj const &, vm_obj const & s, vm_obj const & fn) {
|
||||
std::string msg = to_string(s);
|
||||
timeit timer(std::cout, msg.c_str());
|
||||
timeit timer(tout().get_stream(), msg.c_str());
|
||||
return invoke(fn, mk_vm_unit());
|
||||
}
|
||||
|
||||
vm_obj vm_trace(vm_obj const &, vm_obj const & s, vm_obj const & fn) {
|
||||
tout() << to_string(s) << "\n";
|
||||
return invoke(fn, mk_vm_unit());
|
||||
}
|
||||
|
||||
void initialize_vm_aux() {
|
||||
DECLARE_VM_BUILTIN("timeit", vm_timeit);
|
||||
DECLARE_VM_BUILTIN("trace", vm_trace);
|
||||
}
|
||||
|
||||
void finalize_vm_aux() {
|
||||
|
|
|
|||
3
tests/lean/run/trace_tst.lean
Normal file
3
tests/lean/run/trace_tst.lean
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
open nat
|
||||
|
||||
vm_eval trace "step1" (λ u, trace "hello" (λ u, succ 3))
|
||||
Loading…
Add table
Reference in a new issue