@@ -4,7 +4,7 @@ mod locals;
|
||||
mod scope;
|
||||
pub mod thunk;
|
||||
|
||||
use crate::{syn::ast::Body, obj::prelude::*, vm::consts::*};
|
||||
use crate::{obj::prelude::*, syn::ast::Body, vm::consts::*};
|
||||
use scope::*;
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -29,20 +29,28 @@ impl Compile {
|
||||
.to_vec();
|
||||
// XXX TODO(compile)
|
||||
// remove this when we get returns implemented
|
||||
main.push(crate::vm::inst::Inst::PushSym(crate::obj::reserved::NIL_NAME.sym));
|
||||
main.push(crate::vm::inst::Inst::PushSym(
|
||||
crate::obj::reserved::NIL_NAME.sym,
|
||||
));
|
||||
main.push(crate::vm::inst::Inst::Return);
|
||||
let globals_syms: std::collections::BTreeMap<_, _> = self.pop_scope_layer().unwrap()
|
||||
let globals_syms: std::collections::BTreeMap<_, _> = self
|
||||
.pop_scope_layer()
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.map(|(sym, name)| (name, sym))
|
||||
.collect();
|
||||
let globals = globals_syms.into_iter()
|
||||
let globals = globals_syms
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(index, (name, sym))| {
|
||||
assert_eq!(index, name.index());
|
||||
sym
|
||||
})
|
||||
.collect();
|
||||
Ok((self.const_data.const_pool, UserFun::new_obj(main, globals, 0)))
|
||||
Ok((
|
||||
self.const_data.const_pool,
|
||||
UserFun::new_obj(main, globals, 0),
|
||||
))
|
||||
}
|
||||
|
||||
/// Gets the constant data that is interned in this compile session.
|
||||
|
||||
Reference in New Issue
Block a user