Fasta
Fasta is an integral part of Dart's front-end compiler framework. It's designed to parse Dart source code and generate an intermediate representation known as Kernel. This Kernel is a binary format representing Dart programs that is used by the Dart VM and other Dart tools.
The name 'fasta' sounds like "faster".
Fasta is responsible for several stages of the Dart compilation process, including parsing, type inference, and generating Kernel binary files. It is a crucial component in Dart's toolchain, allowing for efficient compilation of Dart code into a format that can be executed by the Dart runtime.
The usage of Fasta inside Dart SDK includes:
dart
command line- Dart Analyzer static analyzer
- dart2js Dart-JavaScript transcompiler
Key Features
- Parsing: Fasta parses Dart source code into an abstract syntax tree (AST), which is a tree representation of the source code's structure.
- Type Inference: Fasta performs type inference on the Dart code. It tries to deduce types where they aren't explicitly mentioned, helping the Dart language support both dynamic and strong typing.
- Error Checking: During the parsing and compiling stages, Fasta also checks for errors in the code, both syntactic and semantic.
- Kernel Generation: Fasta generates Kernel files, which are a lower-level, platform-independent representation of the Dart code. These files are used by the Dart VM and Dart AOT (Ahead-Of-Time) compiler.
Fasta command line
Fasta is also a command line bash script located at pkg\front_end\tool\fasta
。
It has serveral subcommands:
- abcompile: Compare the performance of two different fast implementations.
abcompile.dart
. - compile: compiles Dart source code into a Kernel binary or another intermediate format.
compile.dart
. - compile-platform: compiling the Dart platform itself or parts of it. It might be used to build the Dart runtime or libraries for different platforms.
compile_platform.dart
. - log
- logd
- outline: generate an outline or a summary of the structure of Dart code.
outline.dart
- parser: a script for parsing Dart source code. Parsing is the process of analyzing code to understand its structure and syntax.
parser.dart
- scanner: be responsible for scanning Dart source code. Scanning is the process of breaking down the code into tokens or basic syntax elements.
- dump-ir: might be intended for dumping or displaying the Intermediate Representation (IR) of Dart code. IR is a lower-level representation of the code, used by compilers.
dump.dart
- testing
- generate-messages
- generate-experimental-flags)
Source code
pkg\front_end\lib\src\fasta\
:
- util
- parser_ast.dart
- Dart SDK CompilerContext
Web Resources
本文作者:Maeiee
本文链接:Fasta
版权声明:如无特别声明,本文即为原创文章,版权归 Maeiee 所有,未经允许不得转载!
喜欢我文章的朋友请随缘打赏,鼓励我创作更多更好的作品!