Skip to content

Commit e1aa0fd

Browse files
krame505quark17
authored andcommitted
Update example of how data constructors are translated
1 parent 62ea8c3 commit e1aa0fd

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

doc/BH_ref_guide/BH_lang.tex

+10-13
Original file line numberDiff line numberDiff line change
@@ -1017,25 +1017,22 @@ \subsection{\te{data}}
10171017
Error messages involving data type definitions sometimes show traces
10181018
of how they are handled internally. Data type definitions are
10191019
translated into a data type where each constructor has exactly one
1020-
argument. Each argument is a struct type. The types above translate
1020+
argument. The types above translate
10211021
to:
10221022
\begin{verbatim}
10231023
data Bool = False PrimUnit | True PrimUnit
10241024
1025-
data Operand = Register Operand.Register
1026-
| Operand.Literal
1027-
| Operand.Indexed
1028-
struct Operand°Register = { _1 :: Bit 5 }
1029-
struct Operand°Literal = { _1 :: Bit 22 }
1030-
struct Operand°Indexed = { _1 :: Reg 5; _2 :: Reg 5 }
1025+
data Operand = Register (Bit 5)
1026+
| Literal (Bit 22)
1027+
| Indexed Operand_$Indexed
1028+
struct Operand_$Indexed = { _1 :: Reg 5; _2 :: Reg 5 }
10311029
1032-
data Maybe a = Nothing PrimUnit | Maybe.Just a
1033-
struct Maybe.Just a = { _1 :: a }
1030+
data Maybe a = Nothing PrimUnit | Just a
10341031
1035-
data Instruction = Immediate Instruction°Immediate |
1036-
Register Instruction°Register
1037-
struct Instruction°Immediate = { op::Op; rs::Reg; rt::CPUReg; imm::UInt16; }
1038-
struct Instruction°Register = { op::Op; target::UInt26; }
1032+
data Instruction = Immediate Instruction_$Immediate
1033+
| Register Instruction_$Register
1034+
struct Instruction_$Immediate = { op::Op; rs::Reg; rt::CPUReg; imm::UInt16; }
1035+
struct Instruction_$Register = { op::Op; target::UInt26; }
10391036
\end{verbatim}
10401037
\end{NOTE}
10411038

0 commit comments

Comments
 (0)