munificent / dep-external-libraries

Proposal for handling platform-specific code in Dart

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fyi: prototype for patch/external

jmesserly opened this issue · comments

https://github.com/dart-lang/dev_compiler/blob/8a86ca7bc16f987dbb0750c2581adcc967482672/tool/patch_sdk.dart

It uses @patch to validate that the member matches up with an external one, because that's the convention in core libraries. We use this in DDC for transforming @patch/external into something that's valid Dart code. Linking here, in case it helps you with the transformer version.

Oh, caveat, it doesn't implement separate private namespace. That could be done with name mangling, I suppose.

Oh, and I used a string edit buffer technique rather than AST pretty printing to preserve human readability/formatting to maximum extent possible. (also hit some issues with analyzer's AST printer)