Files
sdk/tests/modular/macro/add_function.dart
T
Jake Macdonald f48b8c6908 Support prebuilt macros in the incremental compiler mode for DDC
Also adds support for modular tests with precompiled macros, and one test exercising that.

Change-Id: Ie372ea7fcb270ecd55baa54c4ed1c4ae5a527df4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361261
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-04-09 07:37:26 +00:00

21 lines
696 B
Dart

// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:macros/macros.dart';
/// Adds a function with a specified name to a class, with no body and a void
/// return type.
macro class AddFunction implements ClassDeclarationsMacro {
/// The name of the function to add.
final String name;
const AddFunction(this.name);
@override
void buildDeclarationsForClass(
ClassDeclaration clazz, MemberDeclarationBuilder builder) {
builder.declareInType(DeclarationCode.fromString('void $name() {}'));
}
}