Croissant Runtime
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
crsn/crsn/src/asm/mod.rs

28 lines
778 B

use std::cell::RefCell;
use std::sync::Arc;
use crate::asm::parse::{ParserContext, ParserState};
use crate::module::CrsnExtension;
use crate::runtime::program::Program;
pub mod data;
pub mod error;
pub mod instr;
pub mod parse;
pub mod patches;
/// Parse a program from string and assemble a low level instruction sequence from it.
pub fn assemble(source: &str, parsers: Arc<Vec<Box<dyn CrsnExtension>>>) -> Result<Arc<Program>, error::CrsnError> {
let pcx = ParserContext {
parsers: &parsers,
state: RefCell::new(ParserState {
reg_aliases: Default::default(),
reg_alias_stack: vec![],
constants: Default::default(),
}),
};
let ops = parse::parse(source, &pcx)?;
Ok(Program::new(ops, parsers)?)
}