about summary refs log tree commit diff stats
path: root/cpp/090debug
blob: 670b284fca15def27a7c94e21538bc325e312766 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
:(before "End Globals")
// Operator to look at elements of containers.
const int _PRINT = 99;
:(before "End Primitive Recipe Numbers")
Recipe_number["$print"] = _PRINT;
assert(Next_recipe_number < _PRINT);
:(before "End Primitive Recipe Implementations")
case _PRINT: {
  if (isa_literal(instructions[pc].ingredients[0])) {
    trace("run") << "$print: " << instructions[pc].ingredients[0].name;
    cout << instructions[pc].ingredients[0].name;
    break;
  }
  vector<int> result(read_memory(instructions[pc].ingredients[0]));
  for (size_t i = 0; i < result.size(); ++i) {
    trace("run") << "$print: " << result[i];
    if (i > 0) cout << " ";
    cout << result[i];
  }
  break;
}