Formats this value as EndBASIC source code.
(&self)
| 145 | |
| 146 | /// Formats this value as EndBASIC source code. |
| 147 | pub fn as_source(&self) -> String { |
| 148 | match self { |
| 149 | Self::Boolean(v) => { |
| 150 | if *v { |
| 151 | "TRUE".to_owned() |
| 152 | } else { |
| 153 | "FALSE".to_owned() |
| 154 | } |
| 155 | } |
| 156 | Self::Double(v) => { |
| 157 | let mut s = format!("{}", v); |
| 158 | if !s.contains('.') && !s.contains('e') && !s.contains('E') { |
| 159 | s.push_str(".0"); |
| 160 | } |
| 161 | s |
| 162 | } |
| 163 | Self::Integer(v) => format!("{}", v), |
| 164 | Self::Text(v) => format!("\"{}\"", v.replace('"', "\"\"")), |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | /// Formats this value for display in disassembly output. |
| 169 | pub(crate) fn as_disassembly(&self) -> String { |