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 other;
|
||||
pub mod script;
|
||||
pub mod var;
|
||||
|
||||
pub use command::*;
|
||||
pub use other::*;
|
||||
pub use script::*;
|
||||
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::script::ScriptError;
|
||||
use super::super::other::Pohuy;
|
||||
use super::super::var::{VarType, Variable};
|
||||
use super::RunningScript;
|
||||
use super::{RunningScript, ScriptError};
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
@ -33,7 +33,6 @@ impl Function {
|
||||
script: &mut RunningScript,
|
||||
result_var: String,
|
||||
args: Vec<Variable>,
|
||||
globals: &mut HashMap<String, Variable>,
|
||||
is_global: bool,
|
||||
) -> Result<(), (ScriptError, Command)> {
|
||||
let mut locals: HashMap<String, Variable> = HashMap::new();
|
||||
@ -54,27 +53,30 @@ impl Function {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
command
|
||||
.execute(script, is_global, &mut locals, globals, &mut temp_vars)
|
||||
.map_err(|f| (f, command.clone()))?;
|
||||
command.execute(script, is_global, &mut locals, &mut temp_vars)?;
|
||||
|
||||
if let CommandType::TempVar = command.command_type {
|
||||
continue;
|
||||
}
|
||||
|
||||
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" {
|
||||
script.set_var(
|
||||
script
|
||||
.set_var(
|
||||
result_var,
|
||||
locals.get("result").unwrap().clone(),
|
||||
is_global,
|
||||
false,
|
||||
&mut locals,
|
||||
);
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -288,9 +288,8 @@ impl RunningScript {
|
||||
}
|
||||
|
||||
pub fn run(&mut self) -> Result<(), (ScriptError, Command)> {
|
||||
let globals = &mut self.variables.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