mirror of
https://github.com/MeexReay/sustlang.git
synced 2025-06-24 10:33:01 +03:00
fix problem with Pohuy trait
This commit is contained in:
parent
31fac01e46
commit
8897ccfb0a
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,9 @@
|
|||||||
pub mod command;
|
pub mod command;
|
||||||
|
pub mod other;
|
||||||
pub mod script;
|
pub mod script;
|
||||||
pub mod var;
|
pub mod var;
|
||||||
|
|
||||||
pub use command::*;
|
pub use command::*;
|
||||||
|
pub use other::*;
|
||||||
pub use script::*;
|
pub use script::*;
|
||||||
pub use var::*;
|
pub use var::*;
|
||||||
|
5
src/sustlang/other.rs
Normal file
5
src/sustlang/other.rs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
pub trait Pohuy<T, E> {
|
||||||
|
fn pohuy(&self) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T, E> Pohuy<T, E> for Result<T, E> {}
|
@ -1,7 +1,7 @@
|
|||||||
use super::super::command::{Command, CommandType};
|
use super::super::command::{Command, CommandType};
|
||||||
use super::super::script::ScriptError;
|
use super::super::other::Pohuy;
|
||||||
use super::super::var::{VarType, Variable};
|
use super::super::var::{VarType, Variable};
|
||||||
use super::RunningScript;
|
use super::{RunningScript, ScriptError};
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
@ -33,7 +33,6 @@ impl Function {
|
|||||||
script: &mut RunningScript,
|
script: &mut RunningScript,
|
||||||
result_var: String,
|
result_var: String,
|
||||||
args: Vec<Variable>,
|
args: Vec<Variable>,
|
||||||
globals: &mut HashMap<String, Variable>,
|
|
||||||
is_global: bool,
|
is_global: bool,
|
||||||
) -> Result<(), (ScriptError, Command)> {
|
) -> Result<(), (ScriptError, Command)> {
|
||||||
let mut locals: HashMap<String, Variable> = HashMap::new();
|
let mut locals: HashMap<String, Variable> = HashMap::new();
|
||||||
@ -54,27 +53,30 @@ impl Function {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
command
|
command.execute(script, is_global, &mut locals, &mut temp_vars)?;
|
||||||
.execute(script, is_global, &mut locals, globals, &mut temp_vars)
|
|
||||||
.map_err(|f| (f, command.clone()))?;
|
|
||||||
|
|
||||||
if let CommandType::TempVar = command.command_type {
|
if let CommandType::TempVar = command.command_type {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ele in temp_vars.clone() {
|
for ele in temp_vars.clone() {
|
||||||
script.drop_var(ele, &mut locals);
|
script
|
||||||
|
.drop_var(ele, &mut locals)
|
||||||
|
.map_err(|f| (f, command.clone()))
|
||||||
|
.pohuy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if result_var != "null" {
|
if result_var != "null" {
|
||||||
script.set_var(
|
script
|
||||||
result_var,
|
.set_var(
|
||||||
locals.get("result").unwrap().clone(),
|
result_var,
|
||||||
is_global,
|
locals.get("result").unwrap().clone(),
|
||||||
false,
|
is_global,
|
||||||
&mut locals,
|
false,
|
||||||
);
|
&mut locals,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -288,9 +288,8 @@ impl RunningScript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(&mut self) -> Result<(), (ScriptError, Command)> {
|
pub fn run(&mut self) -> Result<(), (ScriptError, Command)> {
|
||||||
let globals = &mut self.variables.clone();
|
|
||||||
let main_function = self.main_function.clone();
|
let main_function = self.main_function.clone();
|
||||||
|
|
||||||
main_function.execute(self, "null".to_string(), Vec::new(), globals, true)
|
main_function.execute(self, "null".to_string(), Vec::new(), true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user