mirror of
https://github.com/exoticorn/curlywas.git
synced 2026-01-20 19:56:42 +01:00
implement table of intrinsics
This commit is contained in:
22
src/main.rs
22
src/main.rs
@@ -7,6 +7,7 @@ mod constfold;
|
||||
mod emit;
|
||||
mod parser;
|
||||
mod typecheck;
|
||||
mod intrinsics;
|
||||
|
||||
type Span = std::ops::Range<usize>;
|
||||
|
||||
@@ -35,26 +36,5 @@ fn main() -> Result<()> {
|
||||
filename.set_extension("wasm");
|
||||
File::create(filename)?.write_all(&wasm)?;
|
||||
|
||||
println!("Size of code section: {} bytes", code_section_size(&wasm)?);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn code_section_size(wasm: &[u8]) -> Result<usize> {
|
||||
for payload in wasmparser::Parser::new(0).parse_all(wasm) {
|
||||
match payload? {
|
||||
wasmparser::Payload::CodeSectionStart { range, .. } => {
|
||||
let size = range.end - range.start;
|
||||
let section_header_size = match size {
|
||||
0..=127 => 2,
|
||||
128..=16383 => 3,
|
||||
_ => 4,
|
||||
};
|
||||
return Ok(size + section_header_size);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
bail!("No code section found");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user