Added comment-emission to the compiler

This commit is contained in:
2024-05-03 21:04:57 -05:00
parent 72e980a2db
commit bde91901e2
8 changed files with 96 additions and 16 deletions
+9
View File
@@ -8,6 +8,8 @@ use crate::compiler::utils::{Label, Scope, Variable};
/// The compiler state:
#[derive(Clone, PartialEq, Debug, Default)]
pub(crate) struct State {
/// Whether to emit documentation comments in the asm listing
pub comments: bool,
/// Used by gensym to generate unique symbols
pub gensym_index: usize,
/// The globally-defined names
@@ -25,6 +27,13 @@ pub(crate) struct State {
}
impl State {
pub(crate) fn with_comments() -> Self {
Self {
comments: true,
..Self::default()
}
}
/// Generate a guaranteed-unique symbolic name
pub(crate) fn gensym(&mut self) -> Label {
self.gensym_index += 1;