-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix passing vecnew * add bug tests * comp test * rename * sep files * refactor * impl all types * fix * fix * fix * fix * fix * fix * fix func
- Loading branch information
Showing
9 changed files
with
405 additions
and
195 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use crate::compiler::var::Var; | ||
use crate::llvm; | ||
use std::collections::HashMap; | ||
|
||
pub struct Frame { | ||
env: HashMap<String, Var>, | ||
pub fun: llvm::Value, | ||
} | ||
|
||
impl Frame { | ||
pub fn new(fun: llvm::Value) -> Self { | ||
Frame { | ||
env: HashMap::new(), | ||
fun, | ||
} | ||
} | ||
|
||
pub fn get(&self, literal: &str) -> Option<&Var> { | ||
self.env.get(literal) | ||
} | ||
|
||
pub fn set(&mut self, literal: &str, val: Var) { | ||
self.env.insert(literal.to_string(), val); | ||
} | ||
|
||
#[allow(dead_code)] | ||
pub fn remove(&mut self, literal: &str) { | ||
self.env.remove(&literal.to_string()); | ||
} | ||
} |
Oops, something went wrong.