change pretty vars and handle larger range of cbor tags
This commit is contained in:
parent
833914c80c
commit
65b133251a
|
@ -663,7 +663,7 @@ impl DefaultFunction {
|
||||||
|
|
||||||
let constr_data = PlutusData::Constr(Constr {
|
let constr_data = PlutusData::Constr(Constr {
|
||||||
// TODO: handle other types of constructor tags
|
// TODO: handle other types of constructor tags
|
||||||
tag: (*i as u64) + 121,
|
tag: convert_constr_to_tag(*i as u64),
|
||||||
any_constructor: None,
|
any_constructor: None,
|
||||||
fields: MaybeIndefArray::Indef(data_list),
|
fields: MaybeIndefArray::Indef(data_list),
|
||||||
});
|
});
|
||||||
|
@ -724,7 +724,7 @@ impl DefaultFunction {
|
||||||
Type::Integer,
|
Type::Integer,
|
||||||
Type::List(Box::new(Type::Data)),
|
Type::List(Box::new(Type::Data)),
|
||||||
// TODO: handle other types of constructor tags
|
// TODO: handle other types of constructor tags
|
||||||
Box::new(Constant::Integer(c.tag as isize - 121)),
|
Box::new(Constant::Integer(convert_tag_to_constr(c.tag as isize))),
|
||||||
Box::new(Constant::ProtoList(
|
Box::new(Constant::ProtoList(
|
||||||
Type::Data,
|
Type::Data,
|
||||||
c.fields
|
c.fields
|
||||||
|
@ -813,3 +813,23 @@ impl DefaultFunction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn convert_tag_to_constr(tag: isize) -> isize {
|
||||||
|
if tag < 128 {
|
||||||
|
tag - 121
|
||||||
|
} else if (1280..1401).contains(&tag) {
|
||||||
|
tag - 1280
|
||||||
|
} else {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn convert_constr_to_tag(constr: u64) -> u64 {
|
||||||
|
if constr < 7 {
|
||||||
|
constr + 121
|
||||||
|
} else if constr < 128 {
|
||||||
|
constr + 1280
|
||||||
|
} else {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -186,13 +186,13 @@ impl Constant {
|
||||||
RcDoc::text(","),
|
RcDoc::text(","),
|
||||||
))
|
))
|
||||||
.append(RcDoc::text("]")),
|
.append(RcDoc::text("]")),
|
||||||
Constant::ProtoPair(r#type1, r#type2, left, right) => RcDoc::text("(")
|
Constant::ProtoPair(type1, type2, left, right) => RcDoc::text("(")
|
||||||
.append(
|
.append(
|
||||||
RcDoc::text("pair")
|
RcDoc::text("pair")
|
||||||
.append(RcDoc::line())
|
.append(RcDoc::line())
|
||||||
.append(r#type1.to_doc())
|
.append(type1.to_doc())
|
||||||
.append(RcDoc::line())
|
.append(RcDoc::line())
|
||||||
.append(r#type2.to_doc()),
|
.append(type2.to_doc()),
|
||||||
)
|
)
|
||||||
.append(RcDoc::line_())
|
.append(RcDoc::line_())
|
||||||
.append(RcDoc::text(")"))
|
.append(RcDoc::text(")"))
|
||||||
|
@ -250,13 +250,13 @@ impl Type {
|
||||||
)
|
)
|
||||||
.append(RcDoc::line_())
|
.append(RcDoc::line_())
|
||||||
.append(RcDoc::text(")")),
|
.append(RcDoc::text(")")),
|
||||||
Type::Pair(r#type1, r#type2) => RcDoc::text("(")
|
Type::Pair(type1, type2) => RcDoc::text("(")
|
||||||
.append(
|
.append(
|
||||||
RcDoc::text("list")
|
RcDoc::text("list")
|
||||||
.append(RcDoc::line())
|
.append(RcDoc::line())
|
||||||
.append(r#type1.to_doc())
|
.append(type1.to_doc())
|
||||||
.append(RcDoc::line())
|
.append(RcDoc::line())
|
||||||
.append(r#type2.to_doc()),
|
.append(type2.to_doc()),
|
||||||
)
|
)
|
||||||
.append(RcDoc::line_())
|
.append(RcDoc::line_())
|
||||||
.append(RcDoc::text(")")),
|
.append(RcDoc::text(")")),
|
||||||
|
|
Loading…
Reference in New Issue