rusk_vm/ops/
call_stack.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4//
5// Copyright (c) DUSK NETWORK. All rights reserved.
6
7use tracing::trace;
8
9use crate::env::Env;
10use crate::VMError;
11
12pub struct Callee;
13
14impl Callee {
15    pub fn callee(env: &Env, result_ofs: i32) -> Result<(), VMError> {
16        trace!("Executing 'callee' host function");
17
18        let result_ofs = result_ofs as usize;
19        let context = env.get_context();
20        let callee = *context.callee();
21
22        context.write_memory(callee.as_bytes(), result_ofs as u64)
23    }
24}
25
26pub struct Caller;
27
28impl Caller {
29    pub fn caller(env: &Env, result_ofs: i32) -> Result<(), VMError> {
30        trace!("Executing 'caller' host function");
31
32        let result_ofs = result_ofs as usize;
33        let context = env.get_context();
34        let caller = *context.caller();
35
36        context.write_memory(caller.as_bytes(), result_ofs as u64)
37    }
38}