Closed dogamak closed 4 years ago
The API was changed in 4cc7f9d so that SourceMap<T> where T: CompileTarget
itself implements the CompileTarget
trait. The SourceMap
struct contains both the compiled program and the generated sourcemap. Example below:
let program = Program::parse(source)?;
let result: SourceMap<bytecode::Program> = compile(program);
let program = result.program;
let source_map = result.source_map;
This PR adds a
Program::compile_with_sourcemap
method which in addition to creating the bytecode program generates a source map. This source map contains mappings from memory locations to assembly lines for instructions and variables.Source map generation works as of now, but the API is ugly at best. Documentation is also missing.
This feature required an additional dependency
nom_locate
which keeps track of the input line numbers. Line numbers are stored insymbolic::Program::instructions
at the time of parsing. It would be nice to have a way of disabling this for additional performance.A new abstraction was created for compilation targets, the
CompilationTarget
trait. It is currently implemented forbytecode::Program
and(T, SourceMap<T::Location>)
whereT
is any type implementingCompilationTarget
. Additional targets could includeVec<u32>
.