gbf_core/decompiler/ast/
phi_array.rs1#![deny(missing_docs)]
2
3use gbf_macros::AstNodeTransform;
4use serde::{Deserialize, Serialize};
5
6use super::{
7 AstKind, AstVisitable, array_kind::ArrayKind, expr::ExprKind, phi::PhiNode, ptr::P,
8 visitors::AstVisitor,
9};
10
11#[derive(Debug, Clone, Serialize, Deserialize, Eq, AstNodeTransform)]
13#[convert_to(ArrayKind::PhiArray, ExprKind::Array, AstKind::Expression)]
14pub struct PhiArrayNode {
15 pub phi: P<PhiNode>,
17 pub elements: Vec<ExprKind>,
19}
20
21impl PhiArrayNode {
22 pub fn new(phi: P<PhiNode>, elements: Vec<ExprKind>) -> Self {
27 Self { phi, elements }
28 }
29}
30
31impl AstVisitable for P<PhiArrayNode> {
32 fn accept<V: AstVisitor>(&self, visitor: &mut V) -> V::Output {
33 visitor.visit_phi_array(self)
34 }
35}
36
37impl PartialEq for PhiArrayNode {
39 fn eq(&self, other: &Self) -> bool {
40 self.elements == other.elements && self.phi == other.phi
41 }
42}