mirror of
https://github.com/artegoser/ONLang
synced 2024-12-23 09:33:44 +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");
|
self.error("Unsupported data type for the `assign` argument, must be an object");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"var" => match value {
|
"var" => match value {
|
||||||
Value::String(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");
|
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 {
|
"delete" => match value {
|
||||||
Value::String(value) => {
|
Value::String(value) => {
|
||||||
self.delete(value);
|
self.delete(value);
|
||||||
|
@ -155,6 +164,14 @@ impl Interpreter {
|
||||||
self.error("Unsupported data type for the `loop cycle` argument, must be an array");
|
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 => {
|
name => {
|
||||||
self.unk_token(&name);
|
self.unk_token(&name);
|
||||||
}
|
}
|
||||||
|
@ -324,6 +341,10 @@ impl Interpreter {
|
||||||
self.vars.insert(
|
self.vars.insert(
|
||||||
name.to_string(),
|
name.to_string(),
|
||||||
Var {
|
Var {
|
||||||
|
scope: self.scope,
|
||||||
|
body: value.clone(),
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue