summaryrefslogtreecommitdiff
path: root/src/environment.rs
diff options
context:
space:
mode:
authorBen Bridle <ben@derelict.engineering>2025-02-27 14:53:21 +1300
committerBen Bridle <ben@derelict.engineering>2025-02-27 14:53:31 +1300
commit67470aea034fd46f4bbcfe815c51ad3451043188 (patch)
tree83d78d3d28e094d6a3af347d2ff2ff16472e5421 /src/environment.rs
parent4e8fae09f0f7d6f3a4ddbe285aeb01ef0622b761 (diff)
downloadtorque-asm-67470aea034fd46f4bbcfe815c51ad3451043188.zip
Finish first working version of Torque
This is a huge and messy commit, worked on piecemeal while traveling and while the language was still being designed.
Diffstat (limited to 'src/environment.rs')
-rw-r--r--src/environment.rs56
1 files changed, 0 insertions, 56 deletions
diff --git a/src/environment.rs b/src/environment.rs
deleted file mode 100644
index 2bb3f5b..0000000
--- a/src/environment.rs
+++ /dev/null
@@ -1,56 +0,0 @@
-use crate::*;
-use semantic::*;
-
-use std::collections::HashMap;
-
-
-pub struct Environment {
- pub scopes: Vec<Scope>,
-}
-
-impl Environment {
- pub fn get_integer(&self, name: &str) -> Result<usize, ()> {
- for scope in self.scopes.iter().rev() {
- if let Ok(value) = scope.get_integer(name, &self) {
- return Ok(value);
- }
- }
- return Err(());
- }
-
- pub fn get_block(&self, name: &str) -> Result<usize, ()> {
- for scope in self.scopes.iter().rev() {
- if let Ok(value) = scope.get_block(name, &self) {
- return Ok(value);
- }
- }
- return Err(());
- }
-}
-
-pub struct Scope {
- pub definitions: HashMap<String, Definition>,
-}
-
-impl Scope {
- pub fn get_integer(&self, _name: &str, _environment: &Environment) -> Result<usize, ()> {
- todo!()
- // use semantic::IntegerDefinition as IntDef;
-
- // if let Some(Definition { variant, ..}) = self.definitions.get(name) {
- // if let IntegerDefinition::Integer(integer) = definition {
- // match integer {
- // IntDef::Literal(value) => return Ok(*value),
- // IntDef::ConstantExpression(expr) => match expr.evaluate(environment) {
- // Ok(_) | Err(_) => todo!(),
- // },
- // };
- // }
- // }
- // return Err(());
- }
-
- pub fn get_block(&self, _name: &str, _environment: &Environment) -> Result<usize, ()> {
- todo!()
- }
-}