mirror of
https://github.com/artegoser/ONLang
synced 2024-12-23 09:33:44 +03:00
refactor: remove unused returns
This commit is contained in:
parent
c4c312cc88
commit
092c5a6a03
1 changed files with 13 additions and 11 deletions
|
@ -90,7 +90,7 @@ impl Interpreter {
|
||||||
},
|
},
|
||||||
"let" => match value {
|
"let" => match value {
|
||||||
Value::Object(value) => {
|
Value::Object(value) => {
|
||||||
return self.define(value);
|
self.define(value);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
self.error("Unsupported data type for the `let` argument, must be an object");
|
self.error("Unsupported data type for the `let` argument, must be an object");
|
||||||
|
@ -98,7 +98,7 @@ impl Interpreter {
|
||||||
},
|
},
|
||||||
"assign" => match value {
|
"assign" => match value {
|
||||||
Value::Object(value) => {
|
Value::Object(value) => {
|
||||||
return self.assign(value);
|
self.assign(value);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
self.error("Unsupported data type for the `assign` argument, must be an object");
|
self.error("Unsupported data type for the `assign` argument, must be an object");
|
||||||
|
@ -106,7 +106,7 @@ impl Interpreter {
|
||||||
},
|
},
|
||||||
"var" => match value {
|
"var" => match value {
|
||||||
Value::String(value) => {
|
Value::String(value) => {
|
||||||
return self.get_var(value);
|
self.get_var(value);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
self.error("Unsupported data type for the `var` argument, must be a string");
|
self.error("Unsupported data type for the `var` argument, must be a string");
|
||||||
|
@ -283,7 +283,7 @@ impl Interpreter {
|
||||||
"end".to_string()
|
"end".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn define(&mut self, vars: &Map<String, Value>) -> Value {
|
fn define(&mut self, vars: &Map<String, Value>) {
|
||||||
for (name, value) in vars {
|
for (name, value) in vars {
|
||||||
if !self.var_exists(&name) {
|
if !self.var_exists(&name) {
|
||||||
match value {
|
match value {
|
||||||
|
@ -297,24 +297,27 @@ impl Interpreter {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.error(&format!("The variable {} already exist, use assign", name));
|
self.error(&format!("The variable {} already exist, use assign", name));
|
||||||
panic!()
|
panic!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Value::Null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_var(&mut self, var_name: &String) -> Value {
|
fn delete(&mut self, var_name: &String) {}
|
||||||
|
|
||||||
|
fn get_var(&mut self, var_name: &String) {
|
||||||
let var = self.vars.get(var_name);
|
let var = self.vars.get(var_name);
|
||||||
match var {
|
match var {
|
||||||
Some(var) => var.clone(),
|
Some(var) => {
|
||||||
|
var.clone();
|
||||||
|
}
|
||||||
None => {
|
None => {
|
||||||
self.error(&format!("The variable {} does not exist", var_name));
|
self.error(&format!("The variable {} does not exist", var_name));
|
||||||
panic!()
|
panic!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn assign(&mut self, vars: &Map<String, Value>) -> Value {
|
fn assign(&mut self, vars: &Map<String, Value>) {
|
||||||
for (name, value) in vars {
|
for (name, value) in vars {
|
||||||
if self.var_exists(&name) {
|
if self.var_exists(&name) {
|
||||||
match value {
|
match value {
|
||||||
|
@ -331,7 +334,6 @@ impl Interpreter {
|
||||||
panic!();
|
panic!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Value::Null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn var_exists(&self, name: &String) -> bool {
|
fn var_exists(&self, name: &String) -> bool {
|
||||||
|
|
Loading…
Add table
Reference in a new issue