chore: fix some stuff after rebase
This commit is contained in:
parent
6c6aefd1c4
commit
3787cce275
|
@ -105,7 +105,7 @@ pub struct DataType<T> {
|
|||
pub typed_parameters: Vec<T>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Use<PackageName> {
|
||||
pub as_name: Option<String>,
|
||||
pub location: Span,
|
||||
|
@ -141,21 +141,21 @@ pub enum Definition<T, Expr, ConstantRecordTag, PackageName> {
|
|||
impl<A, B, C, E> Definition<A, B, C, E> {
|
||||
pub fn location(&self) -> Span {
|
||||
match self {
|
||||
Definition::Fn { location, .. }
|
||||
| Definition::Use { location, .. }
|
||||
| Definition::TypeAlias { location, .. }
|
||||
| Definition::DataType { location, .. }
|
||||
| Definition::ModuleConstant { location, .. } => *location,
|
||||
Definition::Fn(Function { location, .. })
|
||||
| Definition::Use(Use { location, .. })
|
||||
| Definition::TypeAlias(TypeAlias { location, .. })
|
||||
| Definition::DataType(DataType { location, .. })
|
||||
| Definition::ModuleConstant(ModuleConstant { location, .. }) => *location,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn put_doc(&mut self, new_doc: String) {
|
||||
match self {
|
||||
Definition::Use { .. } => (),
|
||||
Definition::Fn { doc, .. }
|
||||
| Definition::TypeAlias { doc, .. }
|
||||
| Definition::DataType { doc, .. }
|
||||
| Definition::ModuleConstant { doc, .. } => {
|
||||
Definition::Fn(Function { doc, .. })
|
||||
| Definition::TypeAlias(TypeAlias { doc, .. })
|
||||
| Definition::DataType(DataType { doc, .. })
|
||||
| Definition::ModuleConstant(ModuleConstant { doc, .. }) => {
|
||||
let _ = std::mem::replace(doc, Some(new_doc));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,11 @@ use vec1::Vec1;
|
|||
|
||||
use crate::{
|
||||
ast::{
|
||||
Annotation, Arg, ArgName, AssignmentKind, BinOp, CallArg, ClauseGuard, Constant,
|
||||
Definition, Pattern, RecordConstructor, RecordConstructorArg, RecordUpdateSpread, Span,
|
||||
TypedArg, TypedConstant, UnqualifiedImport, UntypedArg, UntypedClause, UntypedClauseGuard,
|
||||
UntypedDefinition, UntypedModule, UntypedPattern, UntypedRecordUpdateArg, CAPTURE_VARIABLE,
|
||||
Annotation, Arg, ArgName, AssignmentKind, BinOp, CallArg, ClauseGuard, Constant, DataType,
|
||||
Definition, Function, ModuleConstant, Pattern, RecordConstructor, RecordConstructorArg,
|
||||
RecordUpdateSpread, Span, TypeAlias, TypedArg, TypedConstant, UnqualifiedImport,
|
||||
UntypedArg, UntypedClause, UntypedClauseGuard, UntypedDefinition, UntypedModule,
|
||||
UntypedPattern, UntypedRecordUpdateArg, Use, CAPTURE_VARIABLE,
|
||||
},
|
||||
docvec,
|
||||
expr::UntypedExpr,
|
||||
|
@ -205,7 +206,7 @@ impl<'comments> Formatter<'comments> {
|
|||
|
||||
fn definition<'a>(&mut self, definition: &'a UntypedDefinition) -> Document<'a> {
|
||||
match definition {
|
||||
Definition::Fn {
|
||||
Definition::Fn(Function {
|
||||
name,
|
||||
arguments: args,
|
||||
body,
|
||||
|
@ -213,17 +214,17 @@ impl<'comments> Formatter<'comments> {
|
|||
return_annotation,
|
||||
end_position,
|
||||
..
|
||||
} => self.definition_fn(public, name, args, return_annotation, body, *end_position),
|
||||
}) => self.definition_fn(public, name, args, return_annotation, body, *end_position),
|
||||
|
||||
Definition::TypeAlias {
|
||||
Definition::TypeAlias(TypeAlias {
|
||||
alias,
|
||||
parameters: args,
|
||||
annotation: resolved_type,
|
||||
public,
|
||||
..
|
||||
} => self.type_alias(*public, alias, args, resolved_type),
|
||||
}) => self.type_alias(*public, alias, args, resolved_type),
|
||||
|
||||
Definition::DataType {
|
||||
Definition::DataType(DataType {
|
||||
name,
|
||||
parameters,
|
||||
public,
|
||||
|
@ -231,14 +232,14 @@ impl<'comments> Formatter<'comments> {
|
|||
location,
|
||||
opaque,
|
||||
..
|
||||
} => self.data_type(*public, *opaque, name, parameters, constructors, location),
|
||||
}) => self.data_type(*public, *opaque, name, parameters, constructors, location),
|
||||
|
||||
Definition::Use {
|
||||
Definition::Use(Use {
|
||||
module,
|
||||
as_name,
|
||||
unqualified,
|
||||
..
|
||||
} => "use "
|
||||
}) => "use "
|
||||
.to_doc()
|
||||
.append(Document::String(module.join("/")))
|
||||
.append(if unqualified.is_empty() {
|
||||
|
@ -264,13 +265,13 @@ impl<'comments> Formatter<'comments> {
|
|||
nil()
|
||||
}),
|
||||
|
||||
Definition::ModuleConstant {
|
||||
Definition::ModuleConstant(ModuleConstant {
|
||||
public,
|
||||
name,
|
||||
annotation,
|
||||
value,
|
||||
..
|
||||
} => {
|
||||
}) => {
|
||||
let head = pub_(*public).append("const ").append(name.as_str());
|
||||
let head = match annotation {
|
||||
None => head,
|
||||
|
|
|
@ -10,7 +10,6 @@ pub mod format;
|
|||
pub mod parser;
|
||||
pub mod pretty;
|
||||
pub mod tipo;
|
||||
pub mod token;
|
||||
pub mod uplc;
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
|
|
|
@ -3,8 +3,7 @@ use pretty_assertions::assert_eq;
|
|||
|
||||
use crate::{
|
||||
ast::{self, DataType, Function, Span, TypeAlias, Use},
|
||||
expr, lexer,
|
||||
parser::module_parser,
|
||||
expr, parser,
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -469,7 +469,7 @@ pub struct RecordAccessor {
|
|||
pub tipo: Arc<Type>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum PatternConstructor {
|
||||
Record {
|
||||
name: String,
|
||||
|
|
|
@ -9,9 +9,7 @@ use uplc::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
ast::{
|
||||
BinOp, DataType, Function, ModuleConstant, Pattern, TypeAlias, TypedArg, TypedPattern, Use,
|
||||
},
|
||||
ast::{BinOp, DataType, Function, Pattern, TypedArg, TypedPattern},
|
||||
expr::TypedExpr,
|
||||
tipo::{self, ModuleValueConstructor, Type, ValueConstructorVariant},
|
||||
};
|
||||
|
@ -91,19 +89,19 @@ pub struct CodeGenerator<'a> {
|
|||
uplc_data_constr_lookup: IndexMap<(String, String), ScopeLevels>,
|
||||
uplc_data_usage_holder_lookup: IndexMap<(String, String), ScopeLevels>,
|
||||
functions: &'a HashMap<(String, String), &'a Function<Arc<tipo::Type>, TypedExpr>>,
|
||||
type_aliases: &'a HashMap<(String, String), &'a TypeAlias<Arc<tipo::Type>>>,
|
||||
// type_aliases: &'a HashMap<(String, String), &'a TypeAlias<Arc<tipo::Type>>>,
|
||||
data_types: &'a HashMap<(String, String), &'a DataType<Arc<tipo::Type>>>,
|
||||
imports: &'a HashMap<(String, String), &'a Use<String>>,
|
||||
constants: &'a HashMap<(String, String), &'a ModuleConstant<Arc<tipo::Type>, String>>,
|
||||
// imports: &'a HashMap<(String, String), &'a Use<String>>,
|
||||
// constants: &'a HashMap<(String, String), &'a ModuleConstant<Arc<tipo::Type>, String>>,
|
||||
}
|
||||
|
||||
impl<'a> CodeGenerator<'a> {
|
||||
pub fn new(
|
||||
functions: &'a HashMap<(String, String), &'a Function<Arc<tipo::Type>, TypedExpr>>,
|
||||
type_aliases: &'a HashMap<(String, String), &'a TypeAlias<Arc<tipo::Type>>>,
|
||||
// type_aliases: &'a HashMap<(String, String), &'a TypeAlias<Arc<tipo::Type>>>,
|
||||
data_types: &'a HashMap<(String, String), &'a DataType<Arc<tipo::Type>>>,
|
||||
imports: &'a HashMap<(String, String), &'a Use<String>>,
|
||||
constants: &'a HashMap<(String, String), &'a ModuleConstant<Arc<tipo::Type>, String>>,
|
||||
// imports: &'a HashMap<(String, String), &'a Use<String>>,
|
||||
// constants: &'a HashMap<(String, String), &'a ModuleConstant<Arc<tipo::Type>, String>>,
|
||||
) -> Self {
|
||||
CodeGenerator {
|
||||
uplc_function_holder: Vec::new(),
|
||||
|
@ -112,10 +110,10 @@ impl<'a> CodeGenerator<'a> {
|
|||
uplc_data_constr_lookup: IndexMap::new(),
|
||||
uplc_data_usage_holder_lookup: IndexMap::new(),
|
||||
functions,
|
||||
type_aliases,
|
||||
// type_aliases,
|
||||
data_types,
|
||||
imports,
|
||||
constants,
|
||||
// imports,
|
||||
// constants,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::{
|
|||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use aiken_lang::{error::ParseError, parser::ast::Span, tipo};
|
||||
use aiken_lang::{ast::Span, parser::error::ParseError, tipo};
|
||||
use miette::{Diagnostic, EyreContext, LabeledSpan, MietteHandlerOpts, RgbColors, SourceCode};
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
|
|
@ -347,10 +347,10 @@ impl Project {
|
|||
if VALIDATOR_NAMES.contains(&name.as_str()) {
|
||||
let mut generator = CodeGenerator::new(
|
||||
&functions,
|
||||
&type_aliases,
|
||||
// &type_aliases,
|
||||
&data_types,
|
||||
&imports,
|
||||
&constants,
|
||||
// &imports,
|
||||
// &constants,
|
||||
);
|
||||
|
||||
let program = generator.generate(body, arguments);
|
||||
|
|
Loading…
Reference in New Issue