From 630bd52c8d5a7d362066d8d05c88a1e76c6c81b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edvard=20Th=C3=B6rnros?= Date: Sun, 28 Feb 2021 18:48:49 +0100 Subject: imports! --- src/compiler.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/compiler.rs b/src/compiler.rs index 1d0f17b..984a666 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -581,7 +581,8 @@ impl<'a, 'b> Compiler { /// The line of the current token. fn line(&self) -> usize { if self.section().tokens.len() == 0 { - unreachable!("An error occured without a section."); + // unreachable!("An error occured without a section."); + 666666 } else { self.section().tokens[std::cmp::min(self.current_token, self.section().tokens.len() - 1)].1 } @@ -1433,17 +1434,19 @@ impl<'a, 'b> Compiler { if let Some(_) = self.find_namespace(&name) { expect!(self, Token::Dot, "Expected '.' after namespace."); if let Token::Identifier(ident) = self.eat() { + println!("{:#?}", self.find_namespace(&name)); match self.find_namespace(&name).unwrap().get(&ident) { - Some(Name::Slot(slot, _)) => { + Some(Name::Slot(slot, _)) | + Some(Name::Unknown(slot, _)) => { add_op(self, block, Op::Constant(*slot)); self.call_maybe(block); } _ => { - error!(self, "?"); + error!(self, format!("Cannot find constant '{}' in namespace '{}'.", ident, name)); } } } else { - error!(self, "?"); + error!(self, "Expected identifier after namespace."); } } else if let Some(var) = self.find_variable(&name) { self.mark_read(self.frames().len() - 1, &var); @@ -1745,6 +1748,7 @@ impl<'a, 'b> Compiler { } } + self.init_section(0); let constant = self.find_constant("start"); add_op(self, &mut block, Op::Constant(constant)); add_op(self, &mut block, Op::Call(0)); -- cgit v1.2.1