-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement closure (todo add tests)
- Loading branch information
1 parent
272836e
commit 1e2b3af
Showing
7 changed files
with
142 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
use crate::op_code::Instructions; | ||
use object::CompiledFunction; | ||
use object::{Closure}; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct Frame { | ||
func: CompiledFunction, | ||
pub cl: Closure, | ||
pub ip: i32, | ||
pub base_pointer: usize, | ||
} | ||
|
||
impl Frame { | ||
pub fn new(func: CompiledFunction, base_pointer: usize) -> Self { | ||
Frame { func, ip: -1, base_pointer } | ||
pub fn new(func: Closure, base_pointer: usize) -> Self { | ||
Frame { cl: func, ip: -1, base_pointer } | ||
} | ||
|
||
pub fn instructions(&self) -> Instructions { | ||
return Instructions { data: self.func.instructions.clone() }; | ||
return Instructions { data: self.cl.func.instructions.clone() }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.