mirror of
https://github.com/artegoser/ONLang
synced 2024-12-23 01:23:46 +03:00
feat: scope, isExist
This commit is contained in:
parent
c6251e3fb1
commit
d11d174cfa
1 changed files with 22 additions and 1 deletions
|
@ -107,14 +107,23 @@ impl Interpreter {
|
|||
self.error("Unsupported data type for the `assign` argument, must be an object");
|
||||
}
|
||||
},
|
||||
|
||||
"var" => match value {
|
||||
Value::String(value) => {
|
||||
self.get_var(value);
|
||||
return self.get_var(value);
|
||||
}
|
||||
_ => {
|
||||
self.error("Unsupported data type for the `var` argument, must be a string");
|
||||
}
|
||||
},
|
||||
"isExist" => match value {
|
||||
Value::String(value) => {
|
||||
return Value::Bool(self.var_exists(value));
|
||||
}
|
||||
_ => {
|
||||
self.error("Unsupported data type for the `isExist` argument, must be a string");
|
||||
}
|
||||
},
|
||||
"delete" => match value {
|
||||
Value::String(value) => {
|
||||
self.delete(value);
|
||||
|
@ -155,6 +164,14 @@ impl Interpreter {
|
|||
self.error("Unsupported data type for the `loop cycle` argument, must be an array");
|
||||
}
|
||||
},
|
||||
"scope" => match value {
|
||||
Value::Array(value) => {
|
||||
self.run_nodes(value);
|
||||
}
|
||||
_ => {
|
||||
self.error("Unsupported data type for the `scope` argument, must be an array");
|
||||
}
|
||||
},
|
||||
name => {
|
||||
self.unk_token(&name);
|
||||
}
|
||||
|
@ -324,6 +341,10 @@ impl Interpreter {
|
|||
self.vars.insert(
|
||||
name.to_string(),
|
||||
Var {
|
||||
scope: self.scope,
|
||||
body: value.clone(),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue