diff --git a/rust_compiler/libs/compiler/src/v1.rs b/rust_compiler/libs/compiler/src/v1.rs index 69cf3e9..61a26f0 100644 --- a/rust_compiler/libs/compiler/src/v1.rs +++ b/rust_compiler/libs/compiler/src/v1.rs @@ -2233,10 +2233,7 @@ impl<'a> Compiler<'a> { System::LoadSlot(dev_name, slot_index, logic_type) => { let (dev_hash, hash_cleanup) = self.compile_literal_or_variable(dev_name.node, scope)?; - let (slot_index, slot_cleanup) = self.compile_literal_or_variable( - LiteralOrVariable::Literal(slot_index.node), - scope, - )?; + let (slot_index, slot_cleanup) = self.compile_operand(*slot_index, scope)?; let (logic_type, logic_cleanup) = self.compile_literal_or_variable( LiteralOrVariable::Literal(logic_type.node), scope, @@ -2261,10 +2258,7 @@ impl<'a> Compiler<'a> { System::SetSlot(dev_name, slot_index, logic_type, var) => { let (dev_name, name_cleanup) = self.compile_literal_or_variable(dev_name.node, scope)?; - let (slot_index, index_cleanup) = self.compile_literal_or_variable( - LiteralOrVariable::Literal(slot_index.node), - scope, - )?; + let (slot_index, index_cleanup) = self.compile_operand(*slot_index, scope)?; let (logic_type, type_cleanup) = self.compile_literal_or_variable( LiteralOrVariable::Literal(logic_type.node), scope, diff --git a/rust_compiler/libs/parser/src/lib.rs b/rust_compiler/libs/parser/src/lib.rs index 4cb4618..63e8ec2 100644 --- a/rust_compiler/libs/parser/src/lib.rs +++ b/rust_compiler/libs/parser/src/lib.rs @@ -1834,20 +1834,8 @@ impl<'a> Parser<'a> { let mut args = args!(3); let next = args.next(); let dev_name = literal_or_variable!(next); - let next = args.next(); - let slot_index = get_arg!(Literal, literal_or_variable!(next)); - if !matches!( - slot_index, - Spanned { - node: Literal::Number(_), - .. - }, - ) { - return Err(Error::InvalidSyntax( - slot_index.span, - "Expected a number".to_string(), - )); - } + let slot_index = args.next().ok_or(Error::UnexpectedEOF)?; + let next = args.next(); let slot_logic = get_arg!(Literal, literal_or_variable!(next)); if !matches!( @@ -1864,27 +1852,17 @@ impl<'a> Parser<'a> { } Ok(SysCall::System(System::LoadSlot( - dev_name, slot_index, slot_logic, + dev_name, + boxed!(slot_index), + slot_logic, ))) } "setSlot" | "ss" => { let mut args = args!(4); let next = args.next(); let dev_name = literal_or_variable!(next); - let next = args.next(); - let slot_index = get_arg!(Literal, literal_or_variable!(next)); - if !matches!( - slot_index, - Spanned { - node: Literal::Number(_), - .. - } - ) { - return Err(Error::InvalidSyntax( - slot_index.span, - "Expected a number".into(), - )); - } + let slot_index = args.next().ok_or(Error::UnexpectedEOF)?; + let next = args.next(); let slot_logic = get_arg!(Literal, literal_or_variable!(next)); if !matches!( @@ -1904,9 +1882,9 @@ impl<'a> Parser<'a> { Ok(SysCall::System(System::SetSlot( dev_name, - slot_index, + boxed!(slot_index), slot_logic, - Box::new(expr), + boxed!(expr), ))) } "loadReagent" | "lr" => { diff --git a/rust_compiler/libs/parser/src/sys_call.rs b/rust_compiler/libs/parser/src/sys_call.rs index 0251e91..67e03a9 100644 --- a/rust_compiler/libs/parser/src/sys_call.rs +++ b/rust_compiler/libs/parser/src/sys_call.rs @@ -223,7 +223,7 @@ documented! { /// `let isOccupied = ls(deviceHash, 2, "Occupied");` LoadSlot( Spanned>, - Spanned>, + Box>>, Spanned> ), /// Stores a value of LogicType on a device by the index value @@ -234,7 +234,7 @@ documented! { /// `ss(deviceHash, 0, "Open", true);` SetSlot( Spanned>, - Spanned>, + Box>>, Spanned>, Box>> ),