sway_ast/expr/
asm.rs

1use crate::priv_prelude::*;
2
3#[derive(Clone, Debug, Serialize)]
4pub struct AsmBlock {
5    pub asm_token: AsmToken,
6    pub registers: Parens<Punctuated<AsmRegisterDeclaration, CommaToken>>,
7    pub contents: Braces<AsmBlockContents>,
8}
9
10#[derive(Clone, Debug, Serialize)]
11pub struct AsmRegisterDeclaration {
12    pub register: Ident,
13    pub value_opt: Option<(ColonToken, Box<Expr>)>,
14}
15
16#[derive(Clone, Debug, Serialize)]
17pub struct AsmBlockContents {
18    pub instructions: Vec<(Instruction, SemicolonToken)>,
19    pub final_expr_opt: Option<AsmFinalExpr>,
20}
21
22#[derive(Clone, Debug, Serialize)]
23pub struct AsmFinalExpr {
24    pub register: Ident,
25    pub ty_opt: Option<(ColonToken, Ty)>,
26}
27
28#[derive(Clone, Debug, Serialize)]
29pub struct AsmImmediate {
30    pub span: Span,
31    pub parsed: BigUint,
32}
33
34impl Spanned for AsmImmediate {
35    fn span(&self) -> Span {
36        self.span.clone()
37    }
38}
39
40impl Spanned for AsmBlock {
41    fn span(&self) -> Span {
42        Span::join(self.asm_token.span(), &self.contents.span())
43    }
44}