diff options
| author | Manuel Drehwald <git@manuel.drehwald.info> | 2024-10-11 19:13:31 +0200 |
|---|---|---|
| committer | Manuel Drehwald <git@manuel.drehwald.info> | 2024-10-11 19:13:31 +0200 |
| commit | 624c071b997f3bab0ef086af24f59ebc95f37c59 (patch) | |
| tree | 44091cd44e62db9aa4d0f0b6053de7b84769a5cb /compiler/rustc_expand/src/build.rs | |
| parent | 52fd9983996d9fcfb719749838336be66dee68f9 (diff) | |
| download | rust-624c071b997f3bab0ef086af24f59ebc95f37c59.tar.gz rust-624c071b997f3bab0ef086af24f59ebc95f37c59.zip | |
Single commit implementing the enzyme/autodiff frontend
Co-authored-by: Lorenz Schmidt <bytesnake@mailbox.org>
Diffstat (limited to 'compiler/rustc_expand/src/build.rs')
| -rw-r--r-- | compiler/rustc_expand/src/build.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/compiler/rustc_expand/src/build.rs b/compiler/rustc_expand/src/build.rs index b5945759d43..743a9854f79 100644 --- a/compiler/rustc_expand/src/build.rs +++ b/compiler/rustc_expand/src/build.rs @@ -220,6 +220,10 @@ impl<'a> ExtCtxt<'a> { self.stmt_local(local, span) } + pub fn stmt_semi(&self, expr: P<ast::Expr>) -> ast::Stmt { + ast::Stmt { id: ast::DUMMY_NODE_ID, span: expr.span, kind: ast::StmtKind::Semi(expr) } + } + pub fn stmt_local(&self, local: P<ast::Local>, span: Span) -> ast::Stmt { ast::Stmt { id: ast::DUMMY_NODE_ID, kind: ast::StmtKind::Let(local), span } } @@ -287,6 +291,25 @@ impl<'a> ExtCtxt<'a> { self.expr(sp, ast::ExprKind::Paren(e)) } + pub fn expr_method_call( + &self, + span: Span, + expr: P<ast::Expr>, + ident: Ident, + args: ThinVec<P<ast::Expr>>, + ) -> P<ast::Expr> { + let seg = ast::PathSegment::from_ident(ident); + self.expr( + span, + ast::ExprKind::MethodCall(Box::new(ast::MethodCall { + seg, + receiver: expr, + args, + span, + })), + ) + } + pub fn expr_call( &self, span: Span, @@ -295,6 +318,12 @@ impl<'a> ExtCtxt<'a> { ) -> P<ast::Expr> { self.expr(span, ast::ExprKind::Call(expr, args)) } + pub fn expr_loop(&self, sp: Span, block: P<ast::Block>) -> P<ast::Expr> { + self.expr(sp, ast::ExprKind::Loop(block, None, sp)) + } + pub fn expr_asm(&self, sp: Span, expr: P<ast::InlineAsm>) -> P<ast::Expr> { + self.expr(sp, ast::ExprKind::InlineAsm(expr)) + } pub fn expr_call_ident( &self, span: Span, |
