From 4a5ef76889b9600d02624a066c17834262febd3b Mon Sep 17 00:00:00 2001 From: n3tael Date: Tue, 13 Feb 2024 18:00:50 +0200 Subject: [PATCH] =?UTF-8?q?1.15=20(=D0=BF=D1=80=D0=BE=D0=BF=D1=83=D1=89?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=201.14=20=D1=87=D0=B5=D0=BA=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BC=D0=BC=D0=B5=D0=BD=D1=82)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/execute.rs | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/execute.rs b/src/execute.rs index 7351d10..5977385 100644 --- a/src/execute.rs +++ b/src/execute.rs @@ -8,6 +8,11 @@ fn find_labels(stack: &mut Stack) { let label = &stack.program[stack.program_counter as usize]; stack.program_counter += 1; + /* + * "Теперь трубой можно подменять значения в лейблах" + ? но как это реализовать? + Да и тем более, не понятно работает ли это вообще в lbruntime + */ if !label.name.starts_with('@') { continue; } @@ -32,8 +37,15 @@ fn find_prefix_operators(instruction: &mut Instruction, memory: &mut StackVec) { match instruction.name.chars().nth(0) { Some('|') => { instruction.name = instruction.name.chars().skip(1).collect(); + instruction.data = memory.pop(); } + Some('/') => { + instruction.name = instruction.name.chars().skip(1).collect(); + + memory.push(instruction.data); + instruction.data = 0; + } _ => {} } } @@ -46,6 +58,12 @@ pub fn execute(stack: &mut Stack, mut origin_stack: Option<&mut Stack>, mod_name find_prefix_operators(&mut instruction, &mut stack.memory); + if instruction.name.chars().nth(0) == Some('#') + || instruction.name.chars().nth(0) == Some('$') + { + instruction.name = instruction.name.chars().skip(1).collect(); + } + if instruction.name.starts_with('@') { continue; } @@ -120,22 +138,20 @@ pub fn execute(stack: &mut Stack, mut origin_stack: Option<&mut Stack>, mod_name "getc" => instructions::io::getc(&mut stack.memory), "scan" => instructions::io::scan(&mut stack.memory), "meow" => instructions::io::meow(&mut stack.memory), - "#print" => instructions::io::print(instruction.arg.clone()), - "$print" => instructions::io::print(instruction.arg.clone()), - "#println" => instructions::io::println(instruction.arg.clone()), - "$println" => instructions::io::println(instruction.arg.clone()), + "print" => instructions::io::print(instruction.arg.clone()), + "println" => instructions::io::println(instruction.arg.clone()), // Modules "args" => { instructions::modules::args(&mut stack.memory, &mut origin_stack, instruction.data) } - "#exec" => { + "exec" => { let arg = instruction.arg.clone(); instructions::modules::exec(stack, arg, mod_name.clone()) } // Self-modifying - "#insert" => { + "insert" => { let arg = instruction.arg.clone(); let data = instruction.data.clone(); instructions::self_modify::insert(&mut stack.program, arg, data) @@ -145,8 +161,8 @@ pub fn execute(stack: &mut Stack, mut origin_stack: Option<&mut Stack>, mod_name "dump" => instructions::special::dump(&mut stack.memory), "size" => instructions::special::size(&mut stack.memory), "maxsize" => instructions::special::maxsize(&mut stack.memory), - "#expr" => instructions::special::expr(&mut stack.memory, instruction.arg.clone()), - "nop" => continue, + "expr" => instructions::special::expr(&mut stack.memory, instruction.arg.clone()), + "field" => continue, "quit" => break, "exit" => instructions::special::exit(instruction.data),