1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
use super::super::super::HighLevelEmitter; impl HighLevelEmitter { /// Strips VM-level stack operation comments that add noise to the output. pub(crate) fn strip_stack_comments(statements: &mut [String]) { for stmt in statements.iter_mut() { let trimmed = stmt.trim(); if trimmed.starts_with("// drop ") || trimmed.starts_with("// remove second") || trimmed.starts_with("// swapped top") || trimmed.starts_with("// xdrop stack") || trimmed.starts_with("// rotate top") || trimmed.starts_with("// tuck top") || trimmed.starts_with("// reverse top") || trimmed == "// clear stack" { stmt.clear(); continue; } for suffix in [" // duplicate top of stack", " // copy second stack value"] { if let Some(pos) = stmt.find(suffix) { stmt.truncate(pos); } } } } }