A couple simplifications

This commit is contained in:
Greg Shuflin 2021-12-11 18:38:23 -08:00
parent 5bfd79669e
commit 8e8be1b449

View File

@ -51,9 +51,8 @@ impl<'a, 'b> Reducer<'a, 'b> {
..
}) => {
let symbol = self.symbol_table.lookup_symbol(item_id).unwrap();
let def_id = symbol.def_id();
entrypoint.push(Statement::Binding {
id: def_id,
id: symbol.def_id(),
constant: *constant,
expr: self.expression(expr),
});
@ -99,8 +98,7 @@ impl<'a, 'b> Reducer<'a, 'b> {
}
ast::Declaration::Binding { constant, expr, .. } => {
let symbol = self.symbol_table.lookup_symbol(item_id).unwrap();
let def_id = symbol.def_id();
Some(Statement::Binding { id: def_id, constant: *constant, expr: self.expression(expr) })
Some(Statement::Binding { id: symbol.def_id(), constant: *constant, expr: self.expression(expr) })
}
_ => None,
},
@ -118,9 +116,8 @@ impl<'a, 'b> Reducer<'a, 'b> {
fn insert_function_definition(&mut self, item_id: &ast::ItemId, statements: &ast::Block) {
let symbol = self.symbol_table.lookup_symbol(item_id).unwrap();
let def_id = symbol.def_id();
let function_def = FunctionDefinition { body: self.function_internal_block(statements) };
self.functions.insert(def_id, function_def);
self.functions.insert(symbol.def_id(), function_def);
}
fn expression(&mut self, expr: &ast::Expression) -> Expression {