Skip to content

Commit af800ac

Browse files
committed
Remove Array8, Array16 and Array32 types
1 parent 3960a94 commit af800ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+358
-465
lines changed

fathom/src/core.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,7 @@ def_prims! {
333333
OptionType => "Option",
334334
/// Type of dynamically sized arrays.
335335
ArrayType => "Array",
336-
/// Type of arrays, with 8-bit indices.
337-
Array8Type => "Array8",
338-
/// Type of arrays, with 16-bit indices.
339-
Array16Type => "Array16",
340-
/// Type of arrays, with 32-bit indices.
341-
Array32Type => "Array32",
342-
/// Type of arrays, with 64-bit indices.
336+
/// Type of fixed size arrays, with 64-bit indices.
343337
Array64Type => "Array64",
344338
/// Type of stream positions.
345339
PosType => "Pos",
@@ -384,12 +378,6 @@ def_prims! {
384378
FormatF64Be => "f64be",
385379
/// 64-bit, IEEE-754 floating point formats (little-endian).
386380
FormatF64Le => "f64le",
387-
/// Repeat formats up to an unsigned 8-bit length.
388-
FormatRepeatLen8 => "repeat_len8",
389-
/// Repeat formats up to an unsigned 16-bit length.
390-
FormatRepeatLen16 => "repeat_len16",
391-
/// Repeat formats up to an unsigned 32-bit length.
392-
FormatRepeatLen32 => "repeat_len32",
393381
/// Repeat formats up to an unsigned 64-bit length.
394382
FormatRepeatLen64 => "repeat_len64",
395383
/// Repeat a format until the length of the given parse scope is reached.
@@ -444,6 +432,9 @@ def_prims! {
444432
U8And => "u8_and",
445433
U8Or => "u8_or",
446434
U8Xor => "u8_xor",
435+
U8ExtendU16 => "u8_extend_u16",
436+
U8ExtendU32 => "u8_extend_u32",
437+
U8ExtendU64 => "u8_extend_u64",
447438

448439
U16Eq => "u16_eq",
449440
U16Neq => "u16_neq",
@@ -461,6 +452,8 @@ def_prims! {
461452
U16And => "u16_and",
462453
U16Or => "u16_or",
463454
U16Xor => "u16_xor",
455+
U16ExtendU32 => "u16_extend_u32",
456+
U16ExtendU64 => "u16_extend_u64",
464457

465458
U32Eq => "u32_eq",
466459
U32Neq => "u32_neq",
@@ -478,6 +471,7 @@ def_prims! {
478471
U32And => "u32_and",
479472
U32Or => "u32_or",
480473
U32Xor => "u32_xor",
474+
U32ExtendU64 => "u32_extend_u64",
481475

482476
U64Eq => "u64_eq",
483477
U64Neq => "u64_neq",

fathom/src/core/binary.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,6 @@ impl<'arena, 'data> Context<'arena, 'data> {
425425
(Prim::FormatF32Le, []) => read_const(reader, span, read_f32le, Const::F32),
426426
(Prim::FormatF64Be, []) => read_const(reader, span, read_f64be, Const::F64),
427427
(Prim::FormatF64Le, []) => read_const(reader, span, read_f64le, Const::F64),
428-
(Prim::FormatRepeatLen8, [FunApp(_, len), FunApp(_, format)]) => self.read_repeat_len(reader, span, len, format),
429-
(Prim::FormatRepeatLen16, [FunApp(_, len), FunApp(_, format)]) => self.read_repeat_len(reader, span, len, format),
430-
(Prim::FormatRepeatLen32, [FunApp(_, len), FunApp(_, format)]) => self.read_repeat_len(reader, span, len, format),
431428
(Prim::FormatRepeatLen64, [FunApp(_, len), FunApp(_, format)]) => self.read_repeat_len(reader, span, len, format),
432429
(Prim::FormatRepeatUntilEnd, [FunApp(_,format)]) => self.read_repeat_until_end(reader, format),
433430
(Prim::FormatLimit8, [FunApp(_, limit), FunApp(_, format)]) => self.read_limit(reader, limit, format),

fathom/src/core/prim.rs

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ impl<'arena> Env<'arena> {
4646
const S16_TYPE: Term<'_> = Term::Prim(Span::Empty, S16Type);
4747
const S32_TYPE: Term<'_> = Term::Prim(Span::Empty, S32Type);
4848
const S64_TYPE: Term<'_> = Term::Prim(Span::Empty, S64Type);
49-
const ARRAY8_TYPE: Term<'_> = Term::Prim(Span::Empty, Array8Type);
50-
const ARRAY16_TYPE: Term<'_> = Term::Prim(Span::Empty, Array16Type);
51-
const ARRAY32_TYPE: Term<'_> = Term::Prim(Span::Empty, Array32Type);
5249
const ARRAY64_TYPE: Term<'_> = Term::Prim(Span::Empty, Array64Type);
5350
const POS_TYPE: Term<'_> = Term::Prim(Span::Empty, PosType);
5451

@@ -68,9 +65,6 @@ impl<'arena> Env<'arena> {
6865
env.define_prim(F64Type, &UNIVERSE);
6966
env.define_prim_fun(OptionType, [&UNIVERSE], &UNIVERSE);
7067
env.define_prim_fun(ArrayType, [&UNIVERSE], &UNIVERSE);
71-
env.define_prim_fun(Array8Type, [&U8_TYPE, &UNIVERSE], &UNIVERSE);
72-
env.define_prim_fun(Array16Type, [&U16_TYPE, &UNIVERSE], &UNIVERSE);
73-
env.define_prim_fun(Array32Type, [&U32_TYPE, &UNIVERSE], &UNIVERSE);
7468
env.define_prim_fun(Array64Type, [&U64_TYPE, &UNIVERSE], &UNIVERSE);
7569
env.define_prim(PosType, &UNIVERSE);
7670
env.define_prim_fun(RefType, [&FORMAT_TYPE], &UNIVERSE);
@@ -94,9 +88,6 @@ impl<'arena> Env<'arena> {
9488
env.define_prim(FormatF32Le, &FORMAT_TYPE);
9589
env.define_prim(FormatF64Be, &FORMAT_TYPE);
9690
env.define_prim(FormatF64Le, &FORMAT_TYPE);
97-
env.define_prim_fun(FormatRepeatLen8, [&U8_TYPE, &FORMAT_TYPE], &FORMAT_TYPE);
98-
env.define_prim_fun(FormatRepeatLen16, [&U16_TYPE, &FORMAT_TYPE], &FORMAT_TYPE);
99-
env.define_prim_fun(FormatRepeatLen32, [&U32_TYPE, &FORMAT_TYPE], &FORMAT_TYPE);
10091
env.define_prim_fun(FormatRepeatLen64, [&U64_TYPE, &FORMAT_TYPE], &FORMAT_TYPE);
10192
env.define_prim_fun(FormatRepeatUntilEnd, [&FORMAT_TYPE], &FORMAT_TYPE);
10293
env.define_prim_fun(FormatLimit8, [&U8_TYPE, &FORMAT_TYPE], &FORMAT_TYPE);
@@ -197,6 +188,9 @@ impl<'arena> Env<'arena> {
197188
env.define_prim_fun(U8And, [&U8_TYPE, &U8_TYPE], &U8_TYPE);
198189
env.define_prim_fun(U8Or, [&U8_TYPE, &U8_TYPE], &U8_TYPE);
199190
env.define_prim_fun(U8Xor, [&U8_TYPE, &U8_TYPE], &U8_TYPE);
191+
env.define_prim_fun(U8ExtendU16, [&U8_TYPE], &U16_TYPE);
192+
env.define_prim_fun(U8ExtendU32, [&U8_TYPE], &U32_TYPE);
193+
env.define_prim_fun(U8ExtendU64, [&U8_TYPE], &U64_TYPE);
200194

201195
env.define_prim_fun(U16Eq, [&U16_TYPE, &U16_TYPE], &BOOL_TYPE);
202196
env.define_prim_fun(U16Neq, [&U16_TYPE, &U16_TYPE], &BOOL_TYPE);
@@ -214,6 +208,8 @@ impl<'arena> Env<'arena> {
214208
env.define_prim_fun(U16And, [&U16_TYPE, &U16_TYPE], &U16_TYPE);
215209
env.define_prim_fun(U16Or, [&U16_TYPE, &U16_TYPE], &U16_TYPE);
216210
env.define_prim_fun(U16Xor, [&U16_TYPE, &U16_TYPE], &U16_TYPE);
211+
env.define_prim_fun(U16ExtendU32, [&U16_TYPE], &U32_TYPE);
212+
env.define_prim_fun(U16ExtendU64, [&U16_TYPE], &U64_TYPE);
217213

218214
env.define_prim_fun(U32Eq, [&U32_TYPE, &U32_TYPE], &BOOL_TYPE);
219215
env.define_prim_fun(U32Neq, [&U32_TYPE, &U32_TYPE], &BOOL_TYPE);
@@ -231,6 +227,7 @@ impl<'arena> Env<'arena> {
231227
env.define_prim_fun(U32And, [&U32_TYPE, &U32_TYPE], &U32_TYPE);
232228
env.define_prim_fun(U32Or, [&U32_TYPE, &U32_TYPE], &U32_TYPE);
233229
env.define_prim_fun(U32Xor, [&U32_TYPE, &U32_TYPE], &U32_TYPE);
230+
env.define_prim_fun(U32ExtendU64, [&U32_TYPE], &U64_TYPE);
234231

235232
env.define_prim_fun(U64Eq, [&U64_TYPE, &U64_TYPE], &BOOL_TYPE);
236233
env.define_prim_fun(U64Neq, [&U64_TYPE, &U64_TYPE], &BOOL_TYPE);
@@ -437,13 +434,7 @@ impl<'arena> Env<'arena> {
437434
)),
438435
))
439436
};
440-
let array8_find_type = find_type(&U8_TYPE, &ARRAY8_TYPE);
441-
let array16_find_type = find_type(&U16_TYPE, &ARRAY16_TYPE);
442-
let array32_find_type = find_type(&U32_TYPE, &ARRAY32_TYPE);
443437
let array64_find_type = find_type(&U64_TYPE, &ARRAY64_TYPE);
444-
env.define_prim(Array8Find, array8_find_type);
445-
env.define_prim(Array16Find, array16_find_type);
446-
env.define_prim(Array32Find, array32_find_type);
447438
env.define_prim(Array64Find, array64_find_type);
448439

449440
// fun (@len : UN) (@A : Type) (index : UN) -> ArrayN len A -> A
@@ -486,13 +477,7 @@ impl<'arena> Env<'arena> {
486477
)),
487478
))
488479
};
489-
let array8_index_type = array_index_type(&U8_TYPE, &ARRAY8_TYPE);
490-
let array16_index_type = array_index_type(&U16_TYPE, &ARRAY16_TYPE);
491-
let array32_index_type = array_index_type(&U32_TYPE, &ARRAY32_TYPE);
492480
let array64_index_type = array_index_type(&U64_TYPE, &ARRAY64_TYPE);
493-
env.define_prim(Array8Index, array8_index_type);
494-
env.define_prim(Array16Index, array16_index_type);
495-
env.define_prim(Array32Index, array32_index_type);
496481
env.define_prim(Array64Index, array64_index_type);
497482

498483
env.define_prim_fun(PosAddU8, [&POS_TYPE, &U8_TYPE], &POS_TYPE);
@@ -611,9 +596,6 @@ pub fn repr(prim: Prim) -> Step {
611596
Prim::FormatF32Le => step!(_, [] => Spanned::empty(Arc::new(Value::prim(Prim::F32Type, [])))),
612597
Prim::FormatF64Be => step!(_, [] => Spanned::empty(Arc::new(Value::prim(Prim::F64Type, [])))),
613598
Prim::FormatF64Le => step!(_, [] => Spanned::empty(Arc::new(Value::prim(Prim::F64Type, [])))),
614-
Prim::FormatRepeatLen8 => step!(env, [len, elem] => Spanned::empty(Arc::new(Value::prim(Prim::Array8Type, [len.clone(), env.format_repr(elem)])))),
615-
Prim::FormatRepeatLen16 => step!(env, [len, elem] => Spanned::empty(Arc::new(Value::prim(Prim::Array16Type, [len.clone(), env.format_repr(elem)])))),
616-
Prim::FormatRepeatLen32 => step!(env, [len, elem] => Spanned::empty(Arc::new(Value::prim(Prim::Array32Type, [len.clone(), env.format_repr(elem)])))),
617599
Prim::FormatRepeatLen64 => step!(env, [len, elem] => Spanned::empty(Arc::new(Value::prim(Prim::Array64Type, [len.clone(), env.format_repr(elem)])))),
618600
Prim::FormatLimit8 => step!(env, [_, elem] => env.format_repr(elem)),
619601
Prim::FormatLimit16 => step!(env, [_, elem] => env.format_repr(elem)),
@@ -666,6 +648,9 @@ pub fn step(prim: Prim) -> Step {
666648
Prim::U8And => const_step!([x, xst: U8, y, yst: U8] => Const::U8(u8::bitand(*x, *y), UIntStyle::merge(*xst, *yst))),
667649
Prim::U8Or => const_step!([x, xst: U8, y, yst: U8] => Const::U8(u8::bitor(*x, *y), UIntStyle::merge(*xst, *yst))),
668650
Prim::U8Xor => const_step!([x, xst: U8, y, yst: U8] => Const::U8(u8::bitxor(*x, *y), UIntStyle::merge(*xst, *yst))),
651+
Prim::U8ExtendU16 => const_step!([x, xst: U8] => Const::U16(u16::from(*x), *xst)),
652+
Prim::U8ExtendU32 => const_step!([x, xst: U8] => Const::U32(u32::from(*x), *xst)),
653+
Prim::U8ExtendU64 => const_step!([x, xst: U8] => Const::U64(u64::from(*x), *xst)),
669654

670655
Prim::U16Eq => const_step!([x: U16, y: U16] => Const::Bool(x == y)),
671656
Prim::U16Neq => const_step!([x: U16, y: U16] => Const::Bool(x != y)),
@@ -683,6 +668,8 @@ pub fn step(prim: Prim) -> Step {
683668
Prim::U16And => const_step!([x, xst: U16, y, yst: U16] => Const::U16(u16::bitand(*x, *y), UIntStyle::merge(*xst, *yst))),
684669
Prim::U16Or => const_step!([x, xst: U16, y, yst: U16] => Const::U16(u16::bitor(*x, *y), UIntStyle::merge(*xst, *yst))),
685670
Prim::U16Xor => const_step!([x, xst: U16, y, yst: U16] => Const::U16(u16::bitxor(*x, *y), UIntStyle::merge(*xst, *yst))),
671+
Prim::U16ExtendU32 => const_step!([x, xst: U16] => Const::U32(u32::from(*x), *xst)),
672+
Prim::U16ExtendU64 => const_step!([x, xst: U16] => Const::U64(u64::from(*x), *xst)),
686673

687674
Prim::U32Eq => const_step!([x: U32, y: U32] => Const::Bool(x == y)),
688675
Prim::U32Neq => const_step!([x: U32, y: U32] => Const::Bool(x != y)),
@@ -700,6 +687,7 @@ pub fn step(prim: Prim) -> Step {
700687
Prim::U32And => const_step!([x, xst: U32, y, yst: U32] => Const::U32(u32::bitand(*x, *y), UIntStyle::merge(*xst, *yst))),
701688
Prim::U32Or => const_step!([x, xst: U32, y, yst: U32] => Const::U32(u32::bitor(*x, *y), UIntStyle::merge(*xst, *yst))),
702689
Prim::U32Xor => const_step!([x, xst: U32, y, yst: U32] => Const::U32(u32::bitxor(*x, *y), UIntStyle::merge(*xst, *yst))),
690+
Prim::U32ExtendU64 => const_step!([x, xst: U32] => Const::U64(u64::from(*x), *xst)),
703691

704692
Prim::U64Eq => const_step!([x: U64, y: U64] => Const::Bool(x == y)),
705693
Prim::U64Neq => const_step!([x: U64, y: U64] => Const::Bool(x != y)),

fathom/src/surface/elaboration.rs

Lines changed: 55 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -597,28 +597,62 @@ impl<'arena> Context<'arena> {
597597
)
598598
}
599599

600-
// Otherwise, unify the types
601-
(_, _) => match self.unification_context().unify(&from, &to) {
602-
Ok(()) => expr,
603-
Err(error) => {
604-
let range = match span {
605-
Span::Range(range) => range,
606-
Span::Empty => {
607-
let range = self.file_range(surface_range);
608-
self.push_message(Message::MissingSpan { range });
609-
range
610-
}
611-
};
600+
(_, _) => {
601+
// Implictly extend unsigned integer types
602+
let extend_prim = match Option::zip(from.match_prim_spine(), to.match_prim_spine())
603+
{
604+
Some(((Prim::U8Type, []), (Prim::U16Type, []))) => Prim::U8ExtendU16,
605+
Some(((Prim::U8Type, []), (Prim::U32Type, []))) => Prim::U8ExtendU32,
606+
Some(((Prim::U8Type, []), (Prim::U64Type, []))) => Prim::U8ExtendU64,
612607

613-
self.push_message(Message::FailedToUnify {
614-
range,
615-
found: self.pretty_value(&from),
616-
expected: self.pretty_value(&to),
617-
error,
618-
});
619-
core::Term::Prim(span, Prim::ReportedError)
620-
}
621-
},
608+
Some(((Prim::U16Type, []), (Prim::U32Type, []))) => Prim::U16ExtendU32,
609+
Some(((Prim::U16Type, []), (Prim::U64Type, []))) => Prim::U16ExtendU64,
610+
611+
Some(((Prim::U32Type, []), (Prim::U64Type, []))) => Prim::U32ExtendU64,
612+
613+
// Otherwise, unify the types
614+
_ => return self.convert(surface_range, expr, &from, &to),
615+
};
616+
617+
core::Term::FunApp(
618+
span,
619+
Plicity::Explicit,
620+
self.scope.to_scope(core::Term::Prim(span, extend_prim)),
621+
self.scope.to_scope(expr),
622+
)
623+
}
624+
}
625+
}
626+
627+
fn convert(
628+
&mut self,
629+
surface_range: ByteRange, /* TODO: could be removed if we never encounter empty spans in
630+
* the core term */
631+
expr: core::Term<'arena>,
632+
from: &ArcValue<'arena>,
633+
to: &ArcValue<'arena>,
634+
) -> core::Term<'arena> {
635+
let span = expr.span();
636+
match self.unification_context().unify(&from, &to) {
637+
Ok(()) => expr,
638+
Err(error) => {
639+
let range = match span {
640+
Span::Range(range) => range,
641+
Span::Empty => {
642+
let range = self.file_range(surface_range);
643+
self.push_message(Message::MissingSpan { range });
644+
range
645+
}
646+
};
647+
648+
self.push_message(Message::FailedToUnify {
649+
range,
650+
found: self.pretty_value(&from),
651+
expected: self.pretty_value(&to),
652+
error,
653+
});
654+
core::Term::Prim(span, Prim::ReportedError)
655+
}
622656
}
623657
}
624658

@@ -734,9 +768,6 @@ impl<'arena> Context<'arena> {
734768
Some((Prim::U16Type, [])) => self.parse_ascii(*range, *lit, Const::U16),
735769
Some((Prim::U32Type, [])) => self.parse_ascii(*range, *lit, Const::U32),
736770
Some((Prim::U64Type, [])) => self.parse_ascii(*range, *lit, Const::U64),
737-
// Some((Prim::Array8Type, [len, _])) => todo!(),
738-
// Some((Prim::Array16Type, [len, _])) => todo!(),
739-
// Some((Prim::Array32Type, [len, _])) => todo!(),
740771
// Some((Prim::Array64Type, [len, _])) => todo!(),
741772
Some((Prim::ReportedError, _)) => None,
742773
_ => {
@@ -1141,15 +1172,6 @@ impl<'arena> Context<'arena> {
11411172

11421173
let (len_value, elem_type) = match expected_type.match_prim_spine() {
11431174
Some((Prim::ArrayType, [App(_, elem_type)])) => (None, elem_type),
1144-
Some((Prim::Array8Type, [App(_, len), App(_, elem_type)])) => {
1145-
(Some(len), elem_type)
1146-
}
1147-
Some((Prim::Array16Type, [App(_, len), App(_, elem_type)])) => {
1148-
(Some(len), elem_type)
1149-
}
1150-
Some((Prim::Array32Type, [App(_, len), App(_, elem_type)])) => {
1151-
(Some(len), elem_type)
1152-
}
11531175
Some((Prim::Array64Type, [App(_, len), App(_, elem_type)])) => {
11541176
(Some(len), elem_type)
11551177
}
@@ -1167,9 +1189,6 @@ impl<'arena> Context<'arena> {
11671189

11681190
let len = match len_value.map(|val| val.as_ref()) {
11691191
None => Some(elem_exprs.len() as u64),
1170-
Some(Value::ConstLit(Const::U8(len, _))) => Some(*len as u64),
1171-
Some(Value::ConstLit(Const::U16(len, _))) => Some(*len as u64),
1172-
Some(Value::ConstLit(Const::U32(len, _))) => Some(*len as u64),
11731192
Some(Value::ConstLit(Const::U64(len, _))) => Some(*len),
11741193
Some(Value::Stuck(Head::Prim(Prim::ReportedError), _)) => {
11751194
return core::Term::Prim(file_range.into(), Prim::ReportedError);
@@ -1207,9 +1226,6 @@ impl<'arena> Context<'arena> {
12071226
Some((Prim::U16Type, [])) => self.parse_ascii(*range, *lit, Const::U16),
12081227
Some((Prim::U32Type, [])) => self.parse_ascii(*range, *lit, Const::U32),
12091228
Some((Prim::U64Type, [])) => self.parse_ascii(*range, *lit, Const::U64),
1210-
// Some((Prim::Array8Type, [len, _])) => todo!(),
1211-
// Some((Prim::Array16Type, [len, _])) => todo!(),
1212-
// Some((Prim::Array32Type, [len, _])) => todo!(),
12131229
// Some((Prim::Array64Type, [len, _])) => todo!(),
12141230
Some((Prim::ReportedError, _)) => None,
12151231
_ => {

formats/edid.fathom

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def chromacity_coordinates = {
4747
};
4848

4949
def established_timing = {
50-
mode_bitmap <- repeat_len8 3 u8, // TODO: bit patterns
50+
mode_bitmap <- repeat_len64 3 u8, // TODO: bit patterns
5151
};
5252

5353
def standard_timing_information : Format = {

formats/edid.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def chromacity_coordinates : Format = {
2828
white_x_msb <- u8,
2929
white_y_msb <- u8,
3030
};
31-
def established_timing : Format = { mode_bitmap <- repeat_len8 3 u8 };
31+
def established_timing : Format = { mode_bitmap <- repeat_len64 3 u8 };
3232
def standard_timing_information : Format = ();
3333
def main : Format = {
3434
header <- header,

formats/gif.fathom

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def logical_screen_descriptor = {
2929
///
3030
/// - [GIF89a Specification: Section 17](https://www.w3.org/Graphics/GIF/spec-gif89a.txt)
3131
def header = {
32-
magic <- repeat_len8 3 u8, // TODO: where magic == ascii "GIF"`,
33-
version <- repeat_len8 3 u8,
32+
magic <- repeat_len64 3 u8, // TODO: where magic == ascii "GIF"`,
33+
version <- repeat_len64 3 u8,
3434
};
3535

3636
/// # Global Color Table Entry
@@ -50,7 +50,7 @@ def color_table_entry = {
5050
///
5151
/// - [GIF89a Specification: Section 19](https://www.w3.org/Graphics/GIF/spec-gif89a.txt)
5252
def global_color_table (len : U16) = {
53-
entries <- repeat_len16 len color_table_entry,
53+
entries <- repeat_len64 len color_table_entry,
5454
};
5555

5656
def main = {

formats/gif.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ def logical_screen_descriptor : Format = {
77
pixel_aspect_ratio <- u8,
88
};
99
def header : Format = {
10-
magic <- repeat_len8 3 u8,
11-
version <- repeat_len8 3 u8,
10+
magic <- repeat_len64 3 u8,
11+
version <- repeat_len64 3 u8,
1212
};
1313
def color_table_entry : Format = { red <- u8, green <- u8, blue <- u8 };
1414
def global_color_table : U16 -> Format = fun len => {
15-
entries <- repeat_len16 len color_table_entry,
15+
entries <- repeat_len64 (u16_extend_u64 len) color_table_entry,
1616
};
1717
def main : Format = { header <- header, screen <- logical_screen_descriptor };
1818
'''

formats/ideas/ico.fathom

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def image = {
2424

2525
def main = {
2626
// NOTE: Could be useful to have invertible patterns here?
27-
magic <- repeat_len8 4 u8 match {
27+
magic <- repeat_len64 4 u8 match {
2828
[0, 0, 1, 0] => icon, // TODO
2929
[0, 0, 2, 0] => cursor, // TODO
3030
},

formats/image.fathom

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ def main = {
1515
/// The height of the image, in pixels.
1616
height <- u32be,
1717
/// The pixel data.
18-
pixels <- repeat_len32 (width * height) pixel,
18+
pixels <- repeat_len64 (width * height) pixel,
1919
};

0 commit comments

Comments
 (0)