aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler.rs')
-rw-r--r--src/compiler.rs18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/compiler.rs b/src/compiler.rs
index dcd0317..d12ee4b 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();
@@ -167,7 +167,7 @@ fn add_op(compiler: &Compiler, block: &mut Block, op: Op) -> usize {
}
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,
@@ -577,7 +577,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()));
}
});
@@ -777,7 +777,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, ..) => {}
@@ -1032,7 +1032,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(_), ..) => {
@@ -1072,7 +1072,7 @@ impl Compiler {
}
- pub fn compile(&mut self, name: &str, file: &Path, functions: &[(String, RustFunction)]) -> Result<Prog, Vec<Error>> {
+ pub(crate) fn compile(&mut self, name: &str, file: &Path, functions: &[(String, RustFunction)]) -> Result<Prog, Vec<Error>> {
self.functions = functions
.to_vec()
.into_iter()
@@ -1113,7 +1113,3 @@ impl Compiler {
}
}
}
-
-pub fn compile(name: &str, file: &Path, tokens: TokenStream, functions: &[(String, RustFunction)]) -> Result<Prog, Vec<Error>> {
- Compiler::new(file, tokens).compile(name, file, functions)
-}