Remove unnecessary code_gen patch.

This is a little weird but, prelude functions are handled slightly
  differently.
This commit is contained in:
KtorZ 2024-07-19 09:22:19 +02:00
parent f8236817fe
commit 5afcc9b0c1
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
2 changed files with 18 additions and 30 deletions

View File

@ -748,11 +748,7 @@ impl<'a> CodeGenerator<'a> {
} }
ModuleValueConstructor::Fn { name, module, .. } => { ModuleValueConstructor::Fn { name, module, .. } => {
let func = self.functions.get(&FunctionAccessKey { let func = self.functions.get(&FunctionAccessKey {
module_name: if module_name == "aiken" { module_name: module_name.clone(),
"".to_string()
} else {
module_name.clone()
},
function_name: name.clone(), function_name: name.clone(),
}); });

View File

@ -20,7 +20,7 @@ use crate::{
}, },
builtins::{ builtins::{
bool, byte_array, data, from_default_function, function, g1_element, g2_element, int, list, bool, byte_array, data, from_default_function, function, g1_element, g2_element, int, list,
pair, string, tuple, void, BUILTIN, PRELUDE, pair, string, tuple, void, BUILTIN,
}, },
expr::{FnStyle, TypedExpr, UntypedExpr}, expr::{FnStyle, TypedExpr, UntypedExpr},
format, format,
@ -2827,7 +2827,7 @@ fn diagnose_expr(expr: TypedExpr) -> TypedExpr {
from_default_function(DefaultFunction::DecodeUtf8, &IdGenerator::new()); from_default_function(DefaultFunction::DecodeUtf8, &IdGenerator::new());
let decode_utf8 = TypedExpr::ModuleSelect { let decode_utf8 = TypedExpr::ModuleSelect {
location: Span::empty(), location: expr.location(),
tipo: decode_utf8_constructor.tipo.clone(), tipo: decode_utf8_constructor.tipo.clone(),
label: DefaultFunction::DecodeUtf8.aiken_name(), label: DefaultFunction::DecodeUtf8.aiken_name(),
module_name: BUILTIN.to_string(), module_name: BUILTIN.to_string(),
@ -2839,29 +2839,21 @@ fn diagnose_expr(expr: TypedExpr) -> TypedExpr {
), ),
}; };
let diagnostic_constructor = ValueConstructor::public( let diagnostic = TypedExpr::Var {
function(vec![data(), byte_array()], byte_array()), location: expr.location(),
ValueConstructorVariant::ModuleFn { name: "diagnostic".to_string(),
constructor: ValueConstructor {
public: true,
tipo: function(vec![data(), byte_array()], byte_array()),
variant: ValueConstructorVariant::ModuleFn {
name: "diagnostic".to_string(), name: "diagnostic".to_string(),
field_map: None, field_map: None,
module: PRELUDE.to_string(), module: "".to_string(),
arity: 2, arity: 2,
location: Span::empty(), location: Span::empty(),
builtin: None, builtin: None,
}, },
); },
let diagnostic = TypedExpr::ModuleSelect {
location: Span::empty(),
tipo: diagnostic_constructor.tipo.clone(),
label: "diagnostic".to_string(),
module_name: PRELUDE.to_string(),
module_alias: "".to_string(),
constructor: diagnostic_constructor.variant.to_module_value_constructor(
diagnostic_constructor.tipo,
"",
"diagnostic",
),
}; };
let location = expr.location(); let location = expr.location();
@ -2873,7 +2865,7 @@ fn diagnose_expr(expr: TypedExpr) -> TypedExpr {
label: None, label: None,
location: expr.location(), location: expr.location(),
value: TypedExpr::Call { value: TypedExpr::Call {
tipo: string(), tipo: byte_array(),
fun: Box::new(diagnostic.clone()), fun: Box::new(diagnostic.clone()),
args: vec![ args: vec![
CallArg { CallArg {