Allow any expression as constants

This is only a start. It compiles, but with a few TODOs left open. In particular, it doesn't currently handle constants depending on other constants or functions; nor does it hoist constants.
This commit is contained in:
KtorZ
2024-08-02 17:23:14 +02:00
parent 79cf0b8d97
commit cd0a9440e8
17 changed files with 192 additions and 282 deletions

View File

@@ -4,8 +4,8 @@ use super::{
};
use crate::{
ast::{
Constant, DataTypeKey, FunctionAccessKey, Pattern, Span, TraceLevel, TypedArg,
TypedAssignmentKind, TypedClause, TypedDataType, TypedPattern,
DataTypeKey, FunctionAccessKey, Pattern, Span, TraceLevel, TypedArg, TypedAssignmentKind,
TypedClause, TypedDataType, TypedPattern,
},
expr::TypedExpr,
line_numbers::{LineColumn, LineNumbers},
@@ -287,15 +287,6 @@ impl Default for CodeGenSpecialFuncs {
}
}
pub fn constants_ir(literal: &Constant) -> AirTree {
match literal {
Constant::Int { value, .. } => AirTree::int(value),
Constant::String { value, .. } => AirTree::string(value),
Constant::ByteArray { bytes, .. } => AirTree::byte_array(bytes.clone()),
Constant::CurvePoint { point, .. } => AirTree::curve(*point.as_ref()),
}
}
pub fn get_generic_variant_name(t: &Rc<Type>) -> String {
let uplc_type = t.get_uplc_type();