Posts

Adding a New Keyword to the Dart Language

Image
 I'm attempting to add the keyword: foobar which will translate to a literal int 5. Steps: Modified lib/src/scanner/token.dart to add "foobar" keyword Looking at where the Keyword TRUE is used parser_impl.dart keyword_contributor.dart ast_test_factory.dart tokens_context.dart tokens_writer.dart unlinked_token_type.dart lax_json.dart <various tests> Likely need to update:  https://github.com/dart-lang/sdk/blob/master/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart#L5362  in order to produce correct AST. Compiling dart program with "foobar" expecting error... SDK diff: # compiling sdk ninja -C out/ios_debug_sim_unopt                                                        ninja: Entering directory `out/ios_debug_sim_unopt' [1/1] Regenerating ninja files [50/50] STAMP obj/default.stamp # running on simulator flutter run --local-engine-src-path='../flojure-engine/src'  --local-engine=ios_debug_sim_unopt It did not throw an error compiling i

Discovering How to Extend the Dart Language

 I am able to load the flutter_frontend_server  using: dart bin/starter.dart compile tmp/hello.dart I'm seeing the error:  Error: SDK root directory not found: ../../out/android_debug/flutter_patched_sdk/ Suspect I either need to compile the sdk or provide an environment variable. It looks like I can configure the SDK here:  https://github.com/flutter/engine/blob/f3ca5fd71537181f7d97a3bb0e6fc4b3482af1e3/flutter_frontend_server/lib/server.dart#L52 There is now a new error, after running:  dart bin/starter.dart --sdk-root='/usr/local/Caskroom/flutter/2.0.5/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk' compile tmp/hello.dart Bad state: createLibraryBuilder for uri dart:_builtin, fileUri org-dartlang-untranslatable-uri:dart%3A_builtin returned null Success!  dart bin/starter.dart --sdk-root='/usr/local/Caskroom/flutter/2.0.5/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk' --target=flutter tmp/hello.dart result 633ec087-419b-47fd-bb64-1e37

Setting Up Your Own Local Copy of the Flutter Engine

Local Flutter Engine Below are some links which provide an overview of the Dart/Flutter platform and compilation system. Architectural Overview -  https://flutter.dev/docs/resources/architectural-overview FAQ -  https://flutter.dev/docs/resources/faq Dart Overview -  https://dart.dev/overview Optimizing Compiler for Dart -  https://www.youtube.com/watch?v=xdMTNDMQw0A Dart AOT and JIT -  https://www.youtube.com/watch?v=NoVYI94MJio   gclient -  https://www.chromium.org/developers/how-tos/depottools   Compiling the flutter engine -  https://github.com/flutter/flutter/wiki/Compiling-the-engine#compiling-for-macos-or-linux   Dart on LLVM -  https://medium.com/dartlang/dart-on-llvm-b82e83f99a70 Note: dart has an JIT build chain and a AOT build chain. One is targeted for app development and the other is targeted for app release. The frontend language changes will need to be compatible in both. The assumption is that as long as I target existing AST structures/patterns (the dart Kernel), the c