Implement new features #6

Merged
n3tael merged 9 commits from bedohswe/labast:master into master 2024-06-20 20:39:40 +00:00
2 changed files with 9 additions and 0 deletions
Showing only changes of commit 065df34eb1 - Show all commits

View File

@ -70,6 +70,7 @@ pub fn execute(stack: &mut Stack, mut origin_stack: Option<&mut Stack>, mod_name
"dup" => instructions::stack_manage::dup(&mut stack.memory), "dup" => instructions::stack_manage::dup(&mut stack.memory),
"swap" => instructions::stack_manage::swap(&mut stack.memory), "swap" => instructions::stack_manage::swap(&mut stack.memory),
"pick" => instructions::stack_manage::pick(&mut stack.memory, instruction.data), "pick" => instructions::stack_manage::pick(&mut stack.memory, instruction.data),
"string" => instructions::stack_manage::string(&mut stack.memory, instruction.arg.clone()),
// Math operations // Math operations
"add" => instructions::math::add(&mut stack.memory), "add" => instructions::math::add(&mut stack.memory),

View File

@ -34,3 +34,11 @@ pub fn pick(memory: &mut StackVec, data: u16) {
.expect(&format!("{}", RunError::PickOutOfBounds)), .expect(&format!("{}", RunError::PickOutOfBounds)),
); );
} }
pub fn string(memory: &mut StackVec, arg: String) {
for i in arg.chars() {
memory.push(i as u16);
}
memory.push(arg.len() as u16);
}