Skip to content

Commit e2f8091

Browse files
committed
Tweaks
1 parent 45493e3 commit e2f8091

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

lib/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ impl<'str> Eval<'str> {
129129
}
130130

131131
pub fn build_program(&mut self) -> Result<Program<'_>, String> {
132-
let table = &self.table;
133132
match &self.source {
134133
EvalSource::Source(source) => {
135134
let mut parser = Parser::new(source);
@@ -140,14 +139,14 @@ impl<'str> Eval<'str> {
140139
Some(ast) => ast,
141140
None => return Ok(Program::default()),
142141
};
143-
Sema::new(table)
142+
Sema::new(&self.table)
144143
.visit(&mut ast)
145144
.map_err(|err| FormattedError::from((&err, source.as_ref())).to_string())?;
146145
IrBuilder::new().build(&ast).map_err(|err| err.to_string())
147146
}
148147
EvalSource::File(path) => {
149148
let binary_data = fs::read(path).map_err(|err| err.to_string())?;
150-
Program::load(&binary_data, table).map_err(|err| err.to_string())
149+
Program::load(&binary_data, &self.table).map_err(|err| err.to_string())
151150
}
152151
}
153152
}

lib/src/program.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use crate::symbol::{SymTable, Symbol};
33
use bincode::config;
44
use colored::Colorize;
55
use rust_decimal::Decimal;
6-
use std::collections::HashMap;
76
use serde::{Deserialize, Serialize};
7+
use std::collections::HashMap;
88
use thiserror::Error;
99

1010
/// Current version of the program format
@@ -185,7 +185,9 @@ impl<'sym> Program<'sym> {
185185
use std::fmt::Write as _;
186186

187187
let mut out = String::new();
188-
out += &format!("; VERSION {}\n", self.version).bright_black().to_string();
188+
out += &format!("; VERSION {}\n", self.version)
189+
.bright_black()
190+
.to_string();
189191

190192
let emit = |mnemonic: &str| -> String { format!("{}", mnemonic.magenta()) };
191193
let emit1 = |mnemonic: &str, op: &str| -> String {

lib/src/symbol.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,9 @@ impl SymTable {
433433
Ok(args[2])
434434
}
435435
},
436-
description: Some("Conditional expression: if(condition, true_value, false_value)".into()),
436+
description: Some(
437+
"Conditional expression: if(condition, true_value, false_value)".into(),
438+
),
437439
},
438440
// Variadic functions
439441
Symbol::Func {

0 commit comments

Comments
 (0)