diff --git a/sway-core/src/language/parsed/expression/asm.rs b/sway-core/src/language/parsed/expression/asm.rs index 1f4d9864596..3c0078c8529 100644 --- a/sway-core/src/language/parsed/expression/asm.rs +++ b/sway-core/src/language/parsed/expression/asm.rs @@ -7,7 +7,7 @@ use sway_types::{ident::Ident, span::Span}; #[derive(Debug, Clone)] pub struct AsmExpression { - pub(crate) registers: Vec, + pub registers: Vec, pub(crate) body: Vec, pub(crate) returns: Option<(AsmRegister, Span)>, pub(crate) return_type: TypeInfo, @@ -15,7 +15,7 @@ pub struct AsmExpression { } #[derive(Debug, Clone)] -pub(crate) struct AsmRegisterDeclaration { +pub struct AsmRegisterDeclaration { pub(crate) name: Ident, - pub(crate) initializer: Option, + pub initializer: Option, } diff --git a/sway-core/src/language/ty/expression/asm.rs b/sway-core/src/language/ty/expression/asm.rs index f4054c873ba..14b261ea083 100644 --- a/sway-core/src/language/ty/expression/asm.rs +++ b/sway-core/src/language/ty/expression/asm.rs @@ -6,7 +6,7 @@ use crate::{engine_threading::*, language::ty::*, type_system::*}; #[derive(Clone, Debug)] pub struct TyAsmRegisterDeclaration { - pub(crate) initializer: Option, + pub initializer: Option, pub(crate) name: Ident, } diff --git a/sway-lsp/src/traverse/parsed_tree.rs b/sway-lsp/src/traverse/parsed_tree.rs index 6a678733773..901e5aecc8d 100644 --- a/sway-lsp/src/traverse/parsed_tree.rs +++ b/sway-lsp/src/traverse/parsed_tree.rs @@ -588,8 +588,12 @@ impl<'a> ParsedTree<'a> { self.handle_expression(&branch.result); } } - ExpressionKind::Asm(_) => { - //TODO handle asm expressions + ExpressionKind::Asm(asm) => { + for register in &asm.registers { + if let Some(initializer) = ®ister.initializer { + self.handle_expression(initializer); + } + } } ExpressionKind::MethodApplication(method_application_expression) => { let MethodApplicationExpression { diff --git a/sway-lsp/src/traverse/typed_tree.rs b/sway-lsp/src/traverse/typed_tree.rs index dab72967a04..b2e5dd67dd9 100644 --- a/sway-lsp/src/traverse/typed_tree.rs +++ b/sway-lsp/src/traverse/typed_tree.rs @@ -642,7 +642,13 @@ impl<'a> TypedTree<'a> { self.handle_expression(r#else, namespace); } } - ty::TyExpressionVariant::AsmExpression { .. } => {} + ty::TyExpressionVariant::AsmExpression { registers, .. } => { + for register in registers { + if let Some(initializer) = ®ister.initializer { + self.handle_expression(initializer, namespace); + } + } + } ty::TyExpressionVariant::StructFieldAccess { prefix, field_to_access,