Previously, this field existed as a sanity check to help ensure that
the client didn't accidentally call `functionExpression_end` more
often than `functionExpression_begin`. However now that flow analysis
maintains an explicit stack of what constructs have been begun and not
ended, the check is redundant, because trying to pop from an empty
stack would cause a runtime failure anyway.
Change-Id: I4a56c66169a6de6b4c19d67800d8d0083e7bd59f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237382
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This implements TypeDeclarationResolver for the CFE. Adds a test to
the macro api test, which includes support for throwing and catching
the ArgumentError required by the api.
Change-Id: I5bb7948064ba5a2c215289915fc10314fd28aa1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237020
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
The old code tries to determine something by using a forwarding listener
without forwarding to anything. It leaked a rewrite though, meaning that
the rewrite stayed, but the error given when rewriting wasn't passed on.
When then parsing it with the real listener, the rewrite was in effect
and there was no error to report. In total no errors were reported.
This fixes the issue by undoing any rewrites in this situation.
Fixes https://github.com/dart-lang/sdk/issues/47020
Change-Id: I5342ae6969f00dea830fb7abb30f21932907b8bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236540
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This adds direct support for class member augmentation, including checks
that the 'augment' modifier is used correctly. Different from the patch
member support, non-augment members added in augment classes are now
part of the interface of the class and can therefore be used outside
the augmentation library.
The CL includes support for using the 'import augment' syntax to import
libraries as augmentation libraries. The enable direct testing of the
augmentation features in expectation tests.
Change-Id: I9961e15862dba827050bec4aceb7dfc45e053d7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234520
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This adds support for the `import augment <uri>` import syntax when
the 'macros' experiment is enabled.
The CL also include propagation of the augment modifier on class methods
which was missed in a previous CL.
Change-Id: Ic843e7e34559bcac728c810590f34b727b5f7090
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234401
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This changes the way the 'augment' modifier is handled in the parser.
Instead of being special cased for class declarations, it is now a
built-in identifier recognized only when the scanner is configured to
support augmentation libraries.
The change supports the used of the 'augment' modifier on not only
class declarations but also mixin and member declarations, as needed
for supporting macros.
Change-Id: I2679d198dea360900cfc478fae9c1660702a8a02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233887
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Results of Phase 2 macros are now applied. The macro application code
has been refactored to support that Phase 1 can apply all macro
applications within a library in bulk, but Phase 2 can apply each
macro application in sequence.
The later is to prepare for making added member visible to subsequent
macro applications within Phase 2. This functionality has not been
completed yet.
Change-Id: Idaf2702e21bde75aedb1509d88e02f270196af5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233380
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This also:
- Adds support to the bootstrap code to handle communicating via sendPort or stdio
- Refactors pretty heavily the isolate executor code such that it can be reused.
- Refactors the isolated executor test into a shared test for all executors
- Removes the mirror based executor entirely - I don't see a path forward with this one.
- Reorganizes all executor based files under macros/executor
Change-Id: I2fc6bb3e6ce56c8b331719f4dc08617b3a521398
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233200
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
This adds support for the generating a synthesized augmentation
library for each library in which phase 1 macros were applied.
Current implementation piggybacks on the patch library support. The
intension is that both patches and augmentations are handled through
the same general mechanism. For now, the wording refers to augmentation
libraries as patch libraries where the implementation is shared.
Testing is extended to verify that the generated classes are
included in the resulting AST.
Change-Id: Ie0d4cfdc84b55ca87e0014794f14b38e442f08eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233101
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
- Support TransferableTypedData in the bootstrap code and IsolatedExecutor.
- Also removed the fake executor and conditional import. Mode will likely be chosen based on factors other than just the availability of `dart:isolate`.
- Run the tests in both serialization modes.
Change-Id: I5c731d192c0d3a8cdc5f7fb900dc07a32f4f4d51
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232981
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
This CL add support for identifier resolution to use the
MacroExecutor.buildAugmentationLibrary for generating the code.
The CL updates the ResolvedIdentifier to have a nullable [uri] in
order to support built in identifiers, such as `void`.
Change-Id: I9436ea77c06cf5618f1977f4c9ac0490ff059587
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232623
Reviewed-by: Jake Macdonald <jakemac@google.com>
Auto-Submit: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
With the optimizations suggested this does now equal or outperform the JSON serializer in all scenarios, the latest numbers from the benchmark are as follows:
Isolate.spawn + SerializationMode.jsonClient: 0:00:00.041666
Isolate.spawnUri + SerializationMode.jsonClient: 0:00:00.069551
Separate process + SerializationMode.jsonClient: 0:00:00.177171
Isolate.spawn + SerializationMode.byteDataClient: 0:00:00.040990
Isolate.spawnUri + SerializationMode.byteDataClient: 0:00:00.059319
Separate process + SerializationMode.byteDataClient: 0:00:00.080008
Change-Id: If5431513c7487d8b7af350381e794cbd61c1be42
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232027
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Use `hasScheme` in place of comparing against the empty string, and
`isScheme` to compare against all other schemes.
TEST=No behavior changes.
Change-Id: Ifc9fd13c6cf37933ebd4a754c4b500dedbcb291b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231185
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
In general this moves in the direction of dealing more with Identifier instances instead of TypeAnnotation instances.
This ended up being a larger refactor than I had hoped, but at a high level it does the following:
- Adds the TypeAnnotationCode/NamedTypeAnnotationCode/FunctionTypeAnnotationCode classes
- Change the TypeResolver api to have a single 'resolve' method, which takes a TypeAnnotationCode argument
- Makes ParameterCode/TypeParameterCode take more structured arguments
- Update the CFE code to be able to resolve NamedTypeAnnotationCode instances instead of TypeAnnotation instances
- Also deletes some unnecessary Code classes.
Note that supporting FunctionTypeAnnotationCode instances looks like it will be some more work in the CFE.
Change-Id: I84712aa1c29634cd0a93d245171b3591f69be927
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231327
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Additionaly this CL moves the arguments checks for redirecting and
super initializer invocations from the early stage of their creation
to a later stage of their addition to the list of constructor
initializers, after the possible modifications to the arguments of the
invocation are performed.
Change-Id: I87a3710c885926a74c844288bdf266e7127a9c40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229967
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Removes the `imports` field from MacroExecutionResult (we don't know them since identifiers arent resolved yet).
Adds a callback function when creating the library to convert an identifier to its library import Uri.
Change-Id: I7f4345f41aa24d18aa7872a226fcfce32166ea6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230400
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
- The only public member on Identifier is `String get name`, but implementations should tie these back to the original AST nodes they came from. These can't be created by users, only given to them.
- Replaces most name getters with Identifier identifier getters.
- Updates many apis to take an Identifier instead of a TypeAnnotation. This definitely cleans things up some as TypeAnnotation was weird for a lot of these apis that don't care about type arguments etc, only the name of the type.
- Replaces the instantiate API on TypeDeclaration with two new apis on TypeResolver:
- `Future<StaticType> instantiateType(TypeAnnotation typeAnnotation);`
- `Future<StaticType> instantiateCode(ExpressionCode code);`
- This one might be a bit weird, but it allows for a fairly intuitive way of constructing any arbitrary type (like function types with required params, etc).
- Removes the ability to pass TypeAnnotations to Code objects, now you can pass Identifiers instead. You can however call the convenience `Code get code` getter on TypeAnnotation, and pass that to a Code object. We could implicitly invoke this if wanted to, and allow passing TypeAnnotations directly again, 🤷♂️ .
- Removes the IdentifierCode class, it is confusing to have both. We already have ExpressionCode which can be used instead.
- We no longer expect setters to have a trailing = on the name - since names are no longer used to disambiguate, it is OK for two identifiers to have the same name they can be disambiguated by the AST node the originated from.
Bug: https://github.com/dart-lang/language/issues/2072
Change-Id: Ibb012d91de3da9a699b7d22fbe2bae00be9b023e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230180
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
- Added the ClassMemberDeclaration interface to simplify some things and unify builder implementations.
- Adds tests for running macros on top level declarations
- Update the code for executing macros to allow function/variable macros to be ran on methods and fields.
- Other general cleanup and some minor bug fixes
Change-Id: I9bc60740c1b583e39179238cdcd68a78c110c3dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229621
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>