shape_vm/executor/vm_impl/
output.rs1use super::super::*;
2
3impl VirtualMachine {
4 pub fn enable_output_capture(&mut self) {
7 self.output_buffer = Some(Vec::new());
8 }
9
10 pub fn disable_output_capture(&mut self) {
12 self.output_buffer = None;
13 }
14
15 pub fn get_captured_output(&self) -> Vec<String> {
17 self.output_buffer.clone().unwrap_or_default()
18 }
19
20 pub fn clear_captured_output(&mut self) {
22 if let Some(ref mut buf) = self.output_buffer {
23 buf.clear();
24 }
25 }
26
27 pub(crate) fn write_output(&mut self, text: &str) {
29 if let Some(ref mut buf) = self.output_buffer {
30 buf.push(text.to_string());
31 } else {
32 println!("{}", text);
33 }
34 }
35
36 pub(crate) fn set_module_binding_by_name_nb(&mut self, _name: &str, _value: KindedSlot) {
45 todo!(
46 "phase-2c — see ADR-006 §2.7.4: set_module_binding_by_name_nb \
47 dispatch through `module_binding_write_kinded` (§2.7.8 \
48 parallel track is live); host-API caller wiring lands in \
49 the Phase-2c host rebuild"
50 );
51 }
52
53 pub fn last_error_line(&self) -> Option<u32> {
55 self.last_error_line
56 }
57
58 pub fn last_error_file(&self) -> Option<&str> {
60 self.last_error_file.as_deref()
61 }
62
63 pub(crate) fn set_last_uncaught_exception(&mut self, value: KindedSlot) {
67 self.last_uncaught_exception = Some(value);
68 }
69
70 pub(crate) fn clear_last_uncaught_exception(&mut self) {
72 self.last_uncaught_exception = None;
73 }
74
75 pub fn take_last_uncaught_exception(&mut self) -> Option<KindedSlot> {
77 self.last_uncaught_exception.take()
78 }
79}