Mercurial > python-compiler.rs
changeset 12:0e96c5bc401d
Remove the need for a Box in BlockStatement.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 02 Jun 2016 03:14:01 +0100 |
parents | 5c169d5807b5 |
children | 38b0d63697b1 |
files | src/ast_scope.rs |
diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ast_scope.rs +++ b/src/ast_scope.rs @@ -3,8 +3,14 @@ use python_ast::{Module, Statement, Expr use std::collections::HashMap; #[derive(Debug)] +struct BlockStatement { + statement: Statement, + block: Option<Block> +} + +#[derive(Debug)] struct Block { - statements: Vec<(Statement, Option<Box<Block>>)>, + statements: Vec<BlockStatement>, bindings: Vec<String> } @@ -35,7 +41,7 @@ fn scope_statement(statement: Statement, for statement in statements { scope_statement(statement, &mut function_block); } - Some(Box::new(function_block)) + Some(function_block) }, Statement::ImportFrom(module, names) => { for name in names { @@ -54,7 +60,7 @@ fn scope_statement(statement: Statement, }, _ => None }; - block.statements.push((statement, new_block)); + block.statements.push(BlockStatement{statement: statement, block: new_block}); } #[allow(dead_code)]