MCPcopy Index your code
hub / github.com/endbasic/endbasic / new

Method new

core/src/compiler/mod.rs:229–244  ·  view source on GitHub ↗

Creates a new compiler instance. `global_defs` provides pre-defined global variables visible to the compiled program. `upcalls` contains the metadata of all built-in callables that the compiled code can use.

(
        upcalls: &HashMap<SymbolKey, Rc<dyn Callable>>,
        global_defs: &[GlobalDef],
    )

Source from the content-addressed store, hash-verified

227 ///
228 /// `upcalls` contains the metadata of all built-in callables that the compiled code can use.
229 pub fn new(
230 upcalls: &HashMap<SymbolKey, Rc<dyn Callable>>,
231 global_defs: &[GlobalDef],
232 ) -> Result<Self> {
233 let mut upcalls_metadata = HashMap::with_capacity(upcalls.len());
234 for (k, v) in upcalls.iter() {
235 upcalls_metadata.insert(k.clone(), v.metadata());
236 }
237
238 let mut context = Context::default();
239
240 let mut symtable = GlobalSymtable::new(upcalls_metadata);
241 prepare_globals(&mut context, &mut symtable, global_defs)?;
242
243 Ok(Self { context, symtable, program_scope: LocalSymtableSnapshot::default() })
244 }
245
246 /// Compiles a chunk of code.
247 pub fn compile(mut self, input: &mut dyn io::Read) -> Result<Image> {

Callers

nothing calls this directly

Calls 5

prepare_globalsFunction · 0.85
iterMethod · 0.80
lenMethod · 0.45
insertMethod · 0.45
metadataMethod · 0.45

Tested by

no test coverage detected