mod.rs
 1  // Copyright (c) 2019-2025 Alpha-Delta Network Inc.
 2  // This file is part of the deltavm library.
 3  
 4  // Licensed under the Apache License, Version 2.0 (the "License");
 5  // you may not use this file except in compliance with the License.
 6  // You may obtain a copy of the License at:
 7  
 8  // http://www.apache.org/licenses/LICENSE-2.0
 9  
10  // Unless required by applicable law or agreed to in writing, software
11  // distributed under the License is distributed on an "AS IS" BASIS,
12  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  // See the License for the specific language governing permissions and
14  // limitations under the License.
15  
16  mod bytes;
17  mod parse;
18  
19  use crate::Operand;
20  
21  use console::{network::prelude::*, program::RegisterType};
22  
23  /// An output statement defines an output of a closure.
24  /// An output statement is of the form `output {operand} as {register_type};`.
25  #[derive(Clone, PartialEq, Eq, Hash)]
26  pub struct Output<N: Network> {
27      /// The output operand.
28      operand: Operand<N>,
29      /// The output register type.
30      register_type: RegisterType<N>,
31  }
32  
33  impl<N: Network> Output<N> {
34      /// Returns the output register.
35      #[inline]
36      pub const fn operand(&self) -> &Operand<N> {
37          &self.operand
38      }
39  
40      /// Returns the output register type.
41      #[inline]
42      pub const fn register_type(&self) -> &RegisterType<N> {
43          &self.register_type
44      }
45  }
46  
47  impl<N: Network> TypeName for Output<N> {
48      /// Returns the type name as a string.
49      #[inline]
50      fn type_name() -> &'static str {
51          "output"
52      }
53  }
54  
55  #[cfg(test)]
56  mod tests {
57      use super::*;
58      use console::network::MainnetV0;
59  
60      type CurrentNetwork = MainnetV0;
61  
62      #[test]
63      fn test_output_type_name() {
64          assert_eq!(Output::<CurrentNetwork>::type_name(), "output");
65      }
66  }