about summary refs log tree commit diff stats
path: root/cpp/025trace
blob: 017c24b984173da8baf92e5136e915424839ed2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//: Allow mu programs to log facts just like we've been doing in C++ so far.

:(scenario trace)
recipe main [
  trace [foo], [this is a trace in mu]
]
+foo: this is a trace in mu

:(before "End Primitive Recipe Declarations")
TRACE,
:(before "End Primitive Recipe Numbers")
Recipe_number["trace"] = TRACE;
:(before "End Primitive Recipe Implementations")
case TRACE: {
  assert(isa_literal(instructions[pc].ingredients[0]));
  string label = instructions[pc].ingredients[0].name;
  assert(isa_literal(instructions[pc].ingredients[1]));
  string message = instructions[pc].ingredients[1].name;
  trace(label) << message;
  break;
}