Fixed warnings
This commit is contained in:
@@ -2,7 +2,7 @@ use std::collections::HashMap;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use crate::ast::nodes::{Node, UntypedKind};
|
||||
use crate::ast::compiler::bound_nodes::{BoundKind, Address};
|
||||
use crate::ast::types::{Value, Identity};
|
||||
use crate::ast::types::Identity;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct CompilerScope {
|
||||
@@ -185,18 +185,15 @@ impl Binder {
|
||||
}
|
||||
|
||||
// 2. Try enclosing scopes (capture chain)
|
||||
let mut captured_addr: Option<Address> = None;
|
||||
|
||||
// Walk backwards from parent of current function up to root (0)
|
||||
// We look for where the variable is DEFINED.
|
||||
for i in (0..current_fn_idx).rev() {
|
||||
let func = &self.functions[i];
|
||||
if let Some(slot) = func.scope.resolve(name) {
|
||||
// Found definition! It's a Local variable in function 'i'.
|
||||
captured_addr = Some(Address::Local(slot));
|
||||
let mut addr = Address::Local(slot);
|
||||
|
||||
// Now we must propagate this capture down through all functions from i+1 to current.
|
||||
let mut addr = captured_addr.unwrap();
|
||||
for k in (i + 1)..=current_fn_idx {
|
||||
addr = Address::Upvalue(self.functions[k].add_upvalue(addr));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
use crate::ast::types::Value;
|
||||
use crate::ast::nodes::{Node, CustomNode};
|
||||
use crate::ast::nodes::Node;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum Address {
|
||||
|
||||
Reference in New Issue
Block a user