Skip to content

Commit

Permalink
asm: add forms to call and exec macros
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Oct 18, 2024
1 parent e49f7f7 commit 9a99445
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/isa/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::isa::ControlFlowOp;

/// Macro compiler for AluVM assembler.
///
/// # Example
Expand Down Expand Up @@ -97,6 +95,10 @@ macro_rules! aluasm_inner {
$code.push($crate::instr!{ $op });
$crate::aluasm_inner! { $code => $( $tt )* }
};
{ $code:ident => $op:ident $arg:literal @ $lib:ident ; $($tt:tt)* } => {
$code.push($crate::instr!{ $op $arg @ $lib });
$crate::aluasm_inner! { $code => $( $tt )* }
};
{ $code:ident => $op:ident $arg:literal @ $lib:literal ; $($tt:tt)* } => {
$code.push($crate::instr!{ $op $arg @ $lib });
$crate::aluasm_inner! { $code => $( $tt )* }
Expand Down Expand Up @@ -186,12 +188,24 @@ macro_rules! instr {
(routine $offset:ident) => {
Instr::ControlFlow(ControlFlowOp::Routine($offset))
};
(call $offset:literal @ $lib:ident) => {
Instr::ControlFlow(ControlFlowOp::Call(LibSite::with(
$offset,
$lib
)))
};
(call $offset:literal @ $lib:literal) => {
Instr::ControlFlow(ControlFlowOp::Call(LibSite::with(
$offset,
$lib.parse().expect("wrong library reference"),
)))
};
(exec $offset:literal @ $lib:ident) => {
Instr::ControlFlow(ControlFlowOp::Exec(LibSite::with(
$offset,
$lib
)))
};
(call $offset:ident @ $lib:ident) => {
Instr::ControlFlow(ControlFlowOp::Call(LibSite::with(
$offset,
Expand Down

0 comments on commit 9a99445

Please sign in to comment.