Include stdlib in executable
This commit is contained in:
		
							parent
							
								
									fa4df50a04
								
							
						
					
					
						commit
						3f90b46dc8
					
				| @ -15,6 +15,8 @@ use super::{ | ||||
|     Context, FunctionDefinition, Import, Metadata, Module, | ||||
| }; | ||||
| 
 | ||||
| pub static STD_SOURCE: &str = include_str!("../lib/std.reid"); | ||||
| 
 | ||||
| #[derive(thiserror::Error, Debug, Clone)] | ||||
| pub enum ErrorKind { | ||||
|     #[error("Unable to import inner modules, not yet supported: {0}")] | ||||
| @ -39,6 +41,19 @@ pub enum ErrorKind { | ||||
|     FunctionIsPrivate(String, String), | ||||
| } | ||||
| 
 | ||||
| fn compile_main() -> super::Module { | ||||
|     let module = compile_module(STD_SOURCE, "standard_library".to_owned(), None, false).unwrap(); | ||||
| 
 | ||||
|     let mut mir_context = super::Context::from(vec![module], Default::default()); | ||||
| 
 | ||||
|     let mut refs = super::typerefs::TypeRefs::default(); | ||||
|     mir_context.pass(&mut super::typeinference::TypeInference { refs: &mut refs }); | ||||
|     mir_context.pass(&mut super::typecheck::TypeCheck { refs: &mut refs }); | ||||
| 
 | ||||
|     let std_compiled = mir_context.modules.remove(0); | ||||
|     std_compiled | ||||
| } | ||||
| 
 | ||||
| /// Struct used to implement a type-checking pass that can be performed on the
 | ||||
| /// MIR.
 | ||||
| pub struct LinkerPass; | ||||
| @ -71,6 +86,8 @@ impl Pass for LinkerPass { | ||||
|             modules.insert(module.name.clone(), Rc::new(RefCell::new(module))); | ||||
|         } | ||||
| 
 | ||||
|         modules.insert("std".to_owned(), Rc::new(RefCell::new(compile_main()))); | ||||
| 
 | ||||
|         let mut modules_to_process: Vec<Rc<RefCell<Module>>> = modules.values().cloned().collect(); | ||||
| 
 | ||||
|         while let Some(module) = modules_to_process.pop() { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user