Fix type reification of PRNG.
This commit is contained in:
parent
debbae4fda
commit
4fb13af49f
|
@ -1,6 +1,6 @@
|
|||
# Changelog
|
||||
|
||||
## v1.1.2 - 2024-09-DD
|
||||
## v1.1.2 - UNRELEASED
|
||||
|
||||
### Added
|
||||
|
||||
|
@ -10,8 +10,13 @@
|
|||
|
||||
- **aiken-lang**: Fix issues with static recursive optimization. See [#1009](https://github.com/aiken-lang/aiken/issues/1009) @Microproofs
|
||||
- **aiken-lang**: Aiken IR now interns variables while building up to ensure uniqueness for local vars. @Microproofs
|
||||
- **aiken-lang**: Fix reification of `Data` (failing to reify) & `PRNG` (missing variants' arguments). @KtorZ
|
||||
- **aiken-lang**: Adjust reification of `String` to be shown as plain UTF-8 text strings (instead of hex-encoded byte array). @KtorZ
|
||||
|
||||
|
||||
### Removed
|
||||
|
||||
- N/A
|
||||
|
||||
## v1.1.1 - 2024-09-10
|
||||
|
||||
|
|
|
@ -420,9 +420,13 @@ pub type TypedDataType = DataType<Rc<Type>>;
|
|||
|
||||
impl TypedDataType {
|
||||
pub fn known_enum(name: &str, constructors: &[&str]) -> Self {
|
||||
Self::known_data_type(name, &RecordConstructor::known_enum(constructors))
|
||||
}
|
||||
|
||||
pub fn known_data_type(name: &str, constructors: &[RecordConstructor<Rc<Type>>]) -> Self {
|
||||
Self {
|
||||
name: name.to_string(),
|
||||
constructors: RecordConstructor::known_enum(constructors),
|
||||
constructors: constructors.to_vec(),
|
||||
location: Span::empty(),
|
||||
opaque: false,
|
||||
public: true,
|
||||
|
@ -946,7 +950,10 @@ pub struct RecordConstructor<T> {
|
|||
pub sugar: bool,
|
||||
}
|
||||
|
||||
impl<A> RecordConstructor<A> {
|
||||
impl<A> RecordConstructor<A>
|
||||
where
|
||||
A: Clone,
|
||||
{
|
||||
pub fn put_doc(&mut self, new_doc: String) {
|
||||
self.doc = Some(new_doc);
|
||||
}
|
||||
|
@ -963,6 +970,16 @@ impl<A> RecordConstructor<A> {
|
|||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn known_record(name: &str, args: &[RecordConstructorArg<A>]) -> Self {
|
||||
RecordConstructor {
|
||||
location: Span::empty(),
|
||||
name: name.to_string(),
|
||||
arguments: args.to_vec(),
|
||||
doc: None,
|
||||
sugar: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
|
|
|
@ -1588,7 +1588,35 @@ impl TypedDataType {
|
|||
}
|
||||
|
||||
pub fn prng() -> Self {
|
||||
DataType::known_enum(well_known::PRNG, well_known::PRNG_CONSTRUCTORS)
|
||||
let bytearray_arg = |label: &str| RecordConstructorArg {
|
||||
label: Some(label.to_string()),
|
||||
doc: None,
|
||||
annotation: Annotation::bytearray(Span::empty()),
|
||||
location: Span::empty(),
|
||||
tipo: Type::byte_array(),
|
||||
};
|
||||
|
||||
let int_arg = |label: &str| RecordConstructorArg {
|
||||
label: Some(label.to_string()),
|
||||
doc: None,
|
||||
annotation: Annotation::int(Span::empty()),
|
||||
location: Span::empty(),
|
||||
tipo: Type::int(),
|
||||
};
|
||||
|
||||
DataType::known_data_type(
|
||||
well_known::PRNG,
|
||||
&[
|
||||
RecordConstructor::known_record(
|
||||
well_known::PRNG_CONSTRUCTORS[0],
|
||||
&[bytearray_arg("seed"), bytearray_arg("choices")],
|
||||
),
|
||||
RecordConstructor::known_record(
|
||||
well_known::PRNG_CONSTRUCTORS[1],
|
||||
&[int_arg("cursor"), bytearray_arg("choices")],
|
||||
),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
pub fn ordering() -> Self {
|
||||
|
|
Loading…
Reference in New Issue