Overview
TheKernelIO interface provides an abstraction for loading and writing Dart kernel Component objects from and to .dill files.
The
KernelIO interface is defined in the pure engine layer without dart:io dependencies, allowing RefractorEngine to use it without platform constraints.KernelIO Interface
load()
Load a kernelComponent from a .dill file at the specified path.
Path to the
.dill file to loadA kernel
Component object from the package:kernel/kernel.dart librarywrite()
Write a kernelComponent to a .dill file at the specified path.
The kernel
Component to serialize and writePath where the
.dill file will be writtenThe parent directory will be created automatically if it doesn’t exist.
FileKernelIO Implementation
FileKernelIO is the concrete file-based implementation of KernelIO.
Implementation Details
- load(): Uses
loadComponentFromBinary()frompackage:kernel/kernel.dart - write(): Uses
BinaryPrinterfrompackage:kernel/binary/ast_to_binary.dartto serialize the component - Creates parent directories recursively when writing
- Throws
FileIoExceptionif the input file doesn’t exist during load
Component Class
TheComponent class is from the Dart kernel package (package:kernel/kernel.dart). It represents the entire program as an abstract syntax tree (AST).
A
Component contains libraries, classes, procedures, and all other program elements in their kernel representation.Usage Example
Integration with RefractorEngine
KernelIO is used by RefractorEngine to load and save kernel components during the obfuscation pipeline:
Binary Format
The.dill format is a binary serialization of the Dart kernel AST:
Compact
Efficient binary representation of the AST
Portable
Platform-independent bytecode format
Fast Loading
Faster than parsing Dart source code
Complete
Contains all program information
Error Handling
See Also
Compiler
Compile Dart source to kernel format
RefractorEngine
Main obfuscation engine
PassRunner
Execute obfuscation passes on components