get lifetime out of Chunk, thus out of Value
This commit is contained in:
parent
be23ee6c44
commit
9f4e630544
|
@ -77,7 +77,7 @@ pub struct Binding {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Chunk<'a> {
|
||||
pub struct Chunk {
|
||||
pub bindings: Vec<Binding>,
|
||||
scope_depth: isize,
|
||||
num_bindings: usize,
|
||||
|
@ -86,8 +86,8 @@ pub struct Chunk<'a> {
|
|||
pub spans: Vec<SimpleSpan>,
|
||||
pub strings: Vec<&'static str>,
|
||||
pub keywords: Vec<&'static str>,
|
||||
pub nodes: Vec<&'a Ast>,
|
||||
pub ast: &'a Ast,
|
||||
pub nodes: Vec<&'static Ast>,
|
||||
pub ast: &'static Ast,
|
||||
pub span: SimpleSpan,
|
||||
pub src: &'static str,
|
||||
pub name: &'static str,
|
||||
|
@ -103,8 +103,8 @@ fn is_binding(expr: &Spanned<Ast>) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> Chunk<'a> {
|
||||
pub fn new(ast: &'a Spanned<Ast>, name: &'static str, src: &'static str) -> Chunk<'a> {
|
||||
impl Chunk {
|
||||
pub fn new(ast: &'static Spanned<Ast>, name: &'static str, src: &'static str) -> Chunk {
|
||||
Chunk {
|
||||
bindings: vec![],
|
||||
scope_depth: -1,
|
||||
|
@ -132,7 +132,7 @@ impl<'a> Chunk<'a> {
|
|||
self.keywords.iter().position(|s| *s == kw)
|
||||
}
|
||||
|
||||
pub fn visit(&mut self, node: &'a Spanned<Ast>) {
|
||||
pub fn visit(&mut self, node: &'static Spanned<Ast>) {
|
||||
let root_node = self.ast;
|
||||
let root_span = self.span;
|
||||
let (ast, span) = node;
|
||||
|
|
|
@ -6,12 +6,13 @@ const DEBUG_RUN: bool = true;
|
|||
mod memory_sandbox;
|
||||
|
||||
mod spans;
|
||||
use crate::spans::Spanned;
|
||||
|
||||
mod lexer;
|
||||
use crate::lexer::lexer;
|
||||
|
||||
mod parser;
|
||||
use crate::parser::parser;
|
||||
use crate::parser::{parser, Ast};
|
||||
|
||||
mod validator;
|
||||
|
||||
|
@ -40,9 +41,9 @@ pub fn run(src: &'static str) {
|
|||
return;
|
||||
}
|
||||
|
||||
let parsed = parse_result.unwrap();
|
||||
let parsed: &'static Spanned<Ast> = Box::leak(Box::new(parse_result.unwrap()));
|
||||
|
||||
let mut chunk = Chunk::new(&parsed, "test", src);
|
||||
let mut chunk = Chunk::new(parsed, "test", src);
|
||||
chunk.compile();
|
||||
if DEBUG_COMPILE {
|
||||
chunk.disassemble();
|
||||
|
|
|
@ -14,6 +14,7 @@ pub struct LFn {
|
|||
pub has_run: bool,
|
||||
pub input: &'static str,
|
||||
pub src: &'static str,
|
||||
pub chunk: Chunk,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
|
Loading…
Reference in New Issue
Block a user