mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
feat: construct pool, env, and scope
This commit is contained in:
parent
90e8fc6c44
commit
ef149bedd0
2 changed files with 36 additions and 5 deletions
|
@ -1,9 +1,9 @@
|
||||||
pub mod ast;
|
pub mod ast;
|
||||||
mod def;
|
mod def;
|
||||||
mod expr;
|
pub mod expr;
|
||||||
mod module;
|
mod module;
|
||||||
mod pattern;
|
mod pattern;
|
||||||
pub mod pool;
|
pub mod pool;
|
||||||
pub mod roc_file;
|
pub mod roc_file;
|
||||||
mod scope;
|
pub mod scope;
|
||||||
mod types;
|
mod types;
|
||||||
|
|
|
@ -31,7 +31,12 @@ use crate::vec_result::get_res;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use cgmath::Vector2;
|
use cgmath::Vector2;
|
||||||
use ed_model::Position;
|
use ed_model::Position;
|
||||||
|
use lang::{ast::Expr2, pool::Pool, scope::Scope};
|
||||||
use pipelines::RectResources;
|
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::error::Error;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
@ -266,7 +271,33 @@ fn run_event_loop(file_path_opt: Option<&Path>) -> Result<(), Box<dyn Error>> {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
queue_no_file_text(&size, NOTHING_OPENED, CODE_TXT_XY.into(), &mut glyph_brush);
|
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);
|
render_node(&size, ast, CODE_TXT_XY.into(), &mut glyph_brush);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,14 +419,14 @@ fn render_node(
|
||||||
position,
|
position,
|
||||||
area_bounds,
|
area_bounds,
|
||||||
color: CODE_COLOR.into(),
|
color: CODE_COLOR.into(),
|
||||||
text: number.into(),
|
text: String::from("1"),
|
||||||
size: CODE_FONT_SIZE,
|
size: CODE_FONT_SIZE,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
queue_code_text_draw(&code_text, glyph_brush);
|
queue_code_text_draw(&code_text, glyph_brush);
|
||||||
}
|
}
|
||||||
_ =>
|
rest => panic!("implement {:?} render", rest)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue