feat: construct pool, env, and scope

This commit is contained in:
rvcas 2021-01-21 22:12:26 -05:00
parent 90e8fc6c44
commit ef149bedd0
2 changed files with 36 additions and 5 deletions

View file

@ -1,9 +1,9 @@
pub mod ast;
mod def;
mod expr;
pub mod expr;
mod module;
mod pattern;
pub mod pool;
pub mod roc_file;
mod scope;
pub mod scope;
mod types;

View file

@ -31,7 +31,12 @@ use crate::vec_result::get_res;
use bumpalo::Bump;
use cgmath::Vector2;
use ed_model::Position;
use lang::{ast::Expr2, pool::Pool, scope::Scope};
use pipelines::RectResources;
use roc_collections::all::MutMap;
use roc_module::symbol::{IdentIds, ModuleId, ModuleIds};
use roc_region::all::Region;
use roc_types::subs::VarStore;
use std::error::Error;
use std::io;
use std::path::Path;
@ -266,7 +271,33 @@ fn run_event_loop(file_path_opt: Option<&Path>) -> Result<(), Box<dyn Error>> {
);
} else {
queue_no_file_text(&size, NOTHING_OPENED, CODE_TXT_XY.into(), &mut glyph_brush);
let ast = crate::lang::expr::str_to_expr2();
let mut pool = Pool::with_capacity(12);
let mut var_store = VarStore::default();
let dep_idents = MutMap::default();
let mut module_ids = ModuleIds::default();
let exposed_ident_ids = IdentIds::default();
let home = module_ids.get_or_insert(&"Home".into());
let mut env = crate::lang::expr::Env::new(
home,
&arena,
&mut pool,
&mut var_store,
dep_idents,
&module_ids,
exposed_ident_ids,
);
let mut scope = Scope::new(home, env.pool, env.var_store);
let region = Region::new(0, 0, 0, 0);
let (ast, _) =
crate::lang::expr::str_to_expr2(&arena, "1", &mut env, &mut scope, region)
.unwrap();
render_node(&size, ast, CODE_TXT_XY.into(), &mut glyph_brush);
}
@ -388,14 +419,14 @@ fn render_node(
position,
area_bounds,
color: CODE_COLOR.into(),
text: number.into(),
text: String::from("1"),
size: CODE_FONT_SIZE,
..Default::default()
};
queue_code_text_draw(&code_text, glyph_brush);
}
_ =>
rest => panic!("implement {:?} render", rest)
};
}