Parse builtin#asm expressions

This commit is contained in:
Lukas Wirth 2024-09-01 13:43:05 +02:00
parent 50882fbfa2
commit 86658c66b4
21 changed files with 865 additions and 31 deletions

View file

@ -694,8 +694,11 @@ impl ExprCollector<'_> {
}
ast::Expr::UnderscoreExpr(_) => self.alloc_expr(Expr::Underscore, syntax_ptr),
ast::Expr::AsmExpr(e) => {
let e = self.collect_expr_opt(e.expr());
self.alloc_expr(Expr::InlineAsm(InlineAsm { e }), syntax_ptr)
let template = e.template().map(|it| self.collect_expr(it)).collect();
self.alloc_expr(
Expr::InlineAsm(InlineAsm { template, operands: Box::default() }),
syntax_ptr,
)
}
ast::Expr::OffsetOfExpr(e) => {
let container = Interned::new(TypeRef::from_ast_opt(&self.ctx(), e.ty()));

View file

@ -307,7 +307,8 @@ pub struct OffsetOf {
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct InlineAsm {
pub e: ExprId,
pub template: Box<[ExprId]>,
pub operands: Box<[()]>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -372,7 +373,7 @@ impl Expr {
match self {
Expr::Missing => {}
Expr::Path(_) | Expr::OffsetOf(_) => {}
Expr::InlineAsm(it) => f(it.e),
Expr::InlineAsm(it) => it.template.iter().copied().for_each(f),
Expr::If { condition, then_branch, else_branch } => {
f(*condition);
f(*then_branch);