Skip to main content

runmat_mir/
rvalue.rs

1use crate::{MirCallArg, MirIndexing, MirOperand, MirStmt};
2use runmat_hir::{
3    CallSyntax, FunctionId, MemberName, OperatorKind, QualifiedName, RequestedOutputCount,
4    SymbolName,
5};
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9pub enum MirRvalue {
10    Use(MirOperand),
11    Unary(OperatorKind, MirOperand),
12    Binary(MirOperand, OperatorKind, MirOperand),
13    ShortCircuit {
14        left: MirOperand,
15        op: MirShortCircuitOp,
16        right_temps: Vec<MirStmt>,
17        right: MirOperand,
18    },
19    Range {
20        start: MirOperand,
21        step: Option<MirOperand>,
22        end: MirOperand,
23    },
24    Call(crate::MirCall),
25    Aggregate {
26        kind: MirAggregateKind,
27        rows: usize,
28        cols: usize,
29        elements: Vec<MirOperand>,
30    },
31    StructLiteral {
32        fields: Vec<(MemberName, MirOperand)>,
33    },
34    ObjectLiteral {
35        class_name: QualifiedName,
36        fields: Vec<(MemberName, MirOperand)>,
37    },
38    Index {
39        base: MirOperand,
40        indexing: MirIndexing,
41    },
42    Member {
43        base: MirOperand,
44        member: MemberName,
45    },
46    DynamicMember {
47        base: MirOperand,
48        member: MirOperand,
49    },
50    WorkspaceFirstStaticProperty {
51        workspace_name: SymbolName,
52        class_name: String,
53        property: MemberName,
54    },
55    MetaClass(QualifiedName),
56    Colon,
57    End,
58    Future {
59        function: FunctionId,
60        args: Vec<MirCallArg>,
61        syntax: CallSyntax,
62        requested_outputs: RequestedOutputCount,
63    },
64    Spawn(MirOperand),
65}
66
67#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
68pub enum MirShortCircuitOp {
69    And,
70    Or,
71}
72
73#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
74pub enum MirAggregateKind {
75    Tensor,
76    Cell,
77}