Use IndexMap throughout
In an ideal world, I should have handlded that directly at the conflicting commit in the rebase, but this would have bubbled up through all commits... which I wasn't really quite keen on going through. So here's an extra ugly commit that comes and 'fix the rebase'.
This commit is contained in:
parent
90ee86d14e
commit
22a1c1dfb4
|
@ -1,9 +1,3 @@
|
|||
use std::{cell::RefCell, collections::HashMap, sync::Arc};
|
||||
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use uplc::builtins::DefaultFunction;
|
||||
|
||||
use crate::{
|
||||
ast::{Arg, ArgName, CallArg, Function, ModuleKind, Span, TypedDataType, TypedFunction, UnOp},
|
||||
builder::{DataTypeKey, FunctionAccessKey},
|
||||
|
@ -14,6 +8,10 @@ use crate::{
|
|||
},
|
||||
IdGenerator,
|
||||
};
|
||||
use indexmap::IndexMap;
|
||||
use std::{cell::RefCell, collections::HashMap, sync::Arc};
|
||||
use strum::IntoEnumIterator;
|
||||
use uplc::builtins::DefaultFunction;
|
||||
|
||||
pub const BYTE_ARRAY: &str = "ByteArray";
|
||||
pub const BOOL: &str = "Bool";
|
||||
|
@ -533,8 +531,8 @@ pub fn from_default_function(
|
|||
})
|
||||
}
|
||||
|
||||
pub fn prelude_functions(id_gen: &IdGenerator) -> HashMap<FunctionAccessKey, TypedFunction> {
|
||||
let mut functions = HashMap::new();
|
||||
pub fn prelude_functions(id_gen: &IdGenerator) -> IndexMap<FunctionAccessKey, TypedFunction> {
|
||||
let mut functions = IndexMap::new();
|
||||
|
||||
// /// Negate the argument. Useful for map/fold and pipelines.
|
||||
// pub fn not(self: Bool) -> Bool {
|
||||
|
@ -800,8 +798,8 @@ pub fn prelude_functions(id_gen: &IdGenerator) -> HashMap<FunctionAccessKey, Typ
|
|||
functions
|
||||
}
|
||||
|
||||
pub fn prelude_data_types(id_gen: &IdGenerator) -> HashMap<DataTypeKey, TypedDataType> {
|
||||
let mut data_types = HashMap::new();
|
||||
pub fn prelude_data_types(id_gen: &IdGenerator) -> IndexMap<DataTypeKey, TypedDataType> {
|
||||
let mut data_types = IndexMap::new();
|
||||
|
||||
// Option
|
||||
let option_data_type = TypedDataType::option(generic_var(id_gen.next()));
|
||||
|
|
|
@ -44,7 +44,7 @@ pub struct CodeGenerator<'a> {
|
|||
defined_functions: IndexMap<FunctionAccessKey, ()>,
|
||||
functions: IndexMap<FunctionAccessKey, &'a TypedFunction>,
|
||||
data_types: IndexMap<DataTypeKey, &'a TypedDataType>,
|
||||
module_types: &'a IndexMap<String, TypeInfo>,
|
||||
module_types: IndexMap<&'a String, &'a TypeInfo>,
|
||||
id_gen: IdGenerator,
|
||||
needs_field_access: bool,
|
||||
used_data_assert_on_list: bool,
|
||||
|
@ -55,7 +55,7 @@ impl<'a> CodeGenerator<'a> {
|
|||
pub fn new(
|
||||
functions: IndexMap<FunctionAccessKey, &'a TypedFunction>,
|
||||
data_types: IndexMap<DataTypeKey, &'a TypedDataType>,
|
||||
module_types: &'a IndexMap<String, TypeInfo>,
|
||||
module_types: IndexMap<&'a String, &'a TypeInfo>,
|
||||
) -> Self {
|
||||
CodeGenerator {
|
||||
defined_functions: IndexMap::new(),
|
||||
|
|
|
@ -166,6 +166,7 @@ mod test {
|
|||
IdGenerator,
|
||||
};
|
||||
use assert_json_diff::assert_json_eq;
|
||||
use indexmap::IndexMap;
|
||||
use serde_json::{self, json};
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
|
||||
|
@ -176,8 +177,8 @@ mod test {
|
|||
package: PackageName,
|
||||
id_gen: IdGenerator,
|
||||
module_types: HashMap<String, TypeInfo>,
|
||||
functions: HashMap<FunctionAccessKey, TypedFunction>,
|
||||
data_types: HashMap<DataTypeKey, TypedDataType>,
|
||||
functions: IndexMap<FunctionAccessKey, TypedFunction>,
|
||||
data_types: IndexMap<DataTypeKey, TypedDataType>,
|
||||
}
|
||||
|
||||
impl TestProject {
|
||||
|
|
|
@ -65,8 +65,8 @@ where
|
|||
sources: Vec<Source>,
|
||||
pub warnings: Vec<Warning>,
|
||||
event_listener: T,
|
||||
functions: HashMap<FunctionAccessKey, TypedFunction>,
|
||||
data_types: HashMap<DataTypeKey, TypedDataType>,
|
||||
functions: IndexMap<FunctionAccessKey, TypedFunction>,
|
||||
data_types: IndexMap<DataTypeKey, TypedDataType>,
|
||||
}
|
||||
|
||||
impl<T> Project<T>
|
||||
|
|
|
@ -9,6 +9,7 @@ use aiken_lang::{
|
|||
uplc::CodeGenerator,
|
||||
VALIDATOR_NAMES,
|
||||
};
|
||||
use indexmap::IndexMap;
|
||||
use petgraph::{algo, graph::NodeIndex, Direction, Graph};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
|
@ -272,16 +273,16 @@ impl CheckedModules {
|
|||
|
||||
pub fn new_generator<'a>(
|
||||
&'a self,
|
||||
builtin_functions: &'a HashMap<FunctionAccessKey, TypedFunction>,
|
||||
builtin_data_types: &'a HashMap<DataTypeKey, TypedDataType>,
|
||||
builtin_functions: &'a IndexMap<FunctionAccessKey, TypedFunction>,
|
||||
builtin_data_types: &'a IndexMap<DataTypeKey, TypedDataType>,
|
||||
module_types: &'a HashMap<String, TypeInfo>,
|
||||
) -> CodeGenerator<'a> {
|
||||
let mut functions = HashMap::new();
|
||||
let mut functions = IndexMap::new();
|
||||
for (k, v) in builtin_functions {
|
||||
functions.insert(k.clone(), v);
|
||||
}
|
||||
|
||||
let mut data_types = HashMap::new();
|
||||
let mut data_types = IndexMap::new();
|
||||
for (k, v) in builtin_data_types {
|
||||
data_types.insert(k.clone(), v);
|
||||
}
|
||||
|
@ -316,7 +317,11 @@ impl CheckedModules {
|
|||
}
|
||||
}
|
||||
}
|
||||
CodeGenerator::new(functions, data_types, module_types)
|
||||
|
||||
let mut module_types_index = IndexMap::new();
|
||||
module_types_index.extend(module_types);
|
||||
|
||||
CodeGenerator::new(functions, data_types, module_types_index)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue