summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/stages/bytecode.rs10
-rw-r--r--src/stages/semantic.rs6
-rw-r--r--src/stages/semantic_tokens.rs6
3 files changed, 11 insertions, 11 deletions
diff --git a/src/stages/bytecode.rs b/src/stages/bytecode.rs
index f0b99df..02cc739 100644
--- a/src/stages/bytecode.rs
+++ b/src/stages/bytecode.rs
@@ -1,6 +1,6 @@
use crate::*;
-use std::collections::HashMap;
+use indexmap::IndexMap;
/// Doesn't truncate trailing null bytes.
@@ -22,8 +22,8 @@ pub fn generate_bytecode(semantic: &Program) -> Result<AssembledProgram, Vec<Tra
pub struct BytecodeGenerator<'a> {
- definitions: &'a HashMap<String, Tracked<Definition>>,
- labels: HashMap<String, LabelInformation>,
+ definitions: &'a IndexMap<String, Tracked<Definition>>,
+ labels: IndexMap<String, LabelInformation>,
stack: Vec<usize>,
bytecode: Vec<u8>,
errors: Vec<Tracked<BytecodeError>>,
@@ -35,8 +35,8 @@ struct LabelInformation {
}
impl<'a> BytecodeGenerator<'a> {
- pub fn new(definitions: &'a HashMap<String, Tracked<Definition>>) -> Self {
- let mut labels = HashMap::new();
+ pub fn new(definitions: &'a IndexMap<String, Tracked<Definition>>) -> Self {
+ let mut labels = IndexMap::new();
for (name, definition) in definitions {
if let DefinitionVariant::LabelDefinition = definition.variant {
// Use fake address for now.
diff --git a/src/stages/semantic.rs b/src/stages/semantic.rs
index f2774a4..909659d 100644
--- a/src/stages/semantic.rs
+++ b/src/stages/semantic.rs
@@ -1,12 +1,12 @@
use crate::*;
-use std::collections::{HashMap, HashSet};
+use indexmap::{IndexMap, IndexSet};
pub fn parse_semantic(syntactic: Vec<Tracked<SyntacticToken>>) -> Result<Program, Vec<Tracked<SemanticError>>> {
// Record all label definitions and macro names up front.
- let mut definitions = HashMap::new();
- let mut macro_names = HashSet::new();
+ let mut definitions = IndexMap::new();
+ let mut macro_names = IndexSet::new();
for token in &syntactic {
match &token.value {
SyntacticToken::LabelDefinition(name) => {
diff --git a/src/stages/semantic_tokens.rs b/src/stages/semantic_tokens.rs
index fe49c26..fc454be 100644
--- a/src/stages/semantic_tokens.rs
+++ b/src/stages/semantic_tokens.rs
@@ -1,10 +1,10 @@
use crate::*;
-use std::collections::HashMap;
+use indexmap::IndexMap;
pub struct Program {
- pub definitions: HashMap<String, Tracked<Definition>>,
+ pub definitions: IndexMap<String, Tracked<Definition>>,
pub tokens: Vec<Tracked<SemanticToken>>,
}
@@ -69,7 +69,7 @@ fn report_semantic_error(error: &Tracked<SemanticError>, source_code: &str) {
}
-pub fn print_semantic_token(i: usize, token: &SemanticToken, definitions: &HashMap<String, Tracked<Definition>>) {
+pub fn print_semantic_token(i: usize, token: &SemanticToken, definitions: &IndexMap<String, Tracked<Definition>>) {
match token {
SemanticToken::Literal(value) => indent!(i, "Literal({value})"),
SemanticToken::Pad(value) => indent!(i, "Pad({value})"),