From 826eb43254ddf8baadcd2ec1dacce594690526db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Fri, 5 Feb 2021 20:54:20 +0100 Subject: document public things and change some visibility and rename some variables and good commit yes thank --- src/compiler.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'src/compiler.rs') diff --git a/src/compiler.rs b/src/compiler.rs index 4988c4d..2caa4e9 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -103,7 +103,7 @@ impl Frame { } } -struct Compiler { +pub(crate) struct Compiler { curr: usize, tokens: TokenStream, current_file: PathBuf, @@ -130,7 +130,7 @@ macro_rules! push_frame { }); // Return value stored as a variable - $compiler.define_variable("", Type::UnknownType, &mut $block).unwrap(); + $compiler.define_variable("", Type::Unknown, &mut $block).unwrap(); $code $compiler.frames.pop().unwrap(); @@ -165,10 +165,8 @@ fn add_op(compiler: &Compiler, block: &mut Block, op: Op) -> usize { block.add(op, compiler.line()) } - - impl Compiler { - pub fn new(current_file: &Path, tokens: TokenStream) -> Self { + pub(crate) fn new(current_file: &Path, tokens: TokenStream) -> Self { Self { curr: 0, tokens, @@ -575,7 +573,7 @@ impl Compiler { self.scope(&mut function_block); for var in self.frame().upvalues.iter() { - function_block.ups.push((var.outer_slot, var.outer_upvalue, var.typ.clone())); + function_block.upvalues.push((var.outer_slot, var.outer_upvalue, var.typ.clone())); } }); @@ -775,7 +773,7 @@ impl Compiler { (Token::Identifier(name), Token::ColonEqual, ..) => { self.eat(); self.eat(); - self.definition_statement(&name, Type::UnknownType, block); + self.definition_statement(&name, Type::Unknown, block); } (Token::Comma, ..) => {} @@ -1028,7 +1026,7 @@ impl Compiler { (Token::Identifier(name), Token::ColonEqual, ..) => { self.eat(); self.eat(); - self.definition_statement(&name, Type::UnknownType, block); + self.definition_statement(&name, Type::Unknown, block); } (Token::Blob, Token::Identifier(_), ..) => { @@ -1068,7 +1066,7 @@ impl Compiler { } - pub fn compile(&mut self, name: &str, file: &Path, functions: &[(String, RustFunction)]) -> Result> { + pub(crate) fn compile(&mut self, name: &str, file: &Path, functions: &[(String, RustFunction)]) -> Result> { self.functions = functions .to_vec() .into_iter() @@ -1109,7 +1107,3 @@ impl Compiler { } } } - -pub fn compile(name: &str, file: &Path, tokens: TokenStream, functions: &[(String, RustFunction)]) -> Result> { - Compiler::new(file, tokens).compile(name, file, functions) -} -- cgit v1.2.1