Documentation ¶
Overview ¶
Package bitgen implements a code generator backend for BIT.
Index ¶
- Constants
- Variables
- type Buffer
- type Constant
- type Goto
- type Jump
- type LineNumber
- type Memory
- type Nand
- type Offset
- type Pointer
- type Readable
- type Writable
- type Writer
- func (w *Writer) Close() error
- func (w *Writer) Copy(start LineNumber, end Goto, dest Memory, src Memory, count uint64, ...)
- func (w *Writer) NewBuffer() Buffer
- func (w *Writer) NewPointer() Pointer
- func (w *Writer) Print(start LineNumber, end Goto, value Constant)
- func (w *Writer) Read(start LineNumber, end Goto)
- func (w *Writer) ReserveLine() LineNumber
- func (w *Writer) SetPtr(start LineNumber, end Goto, dest Pointer, src Memory)
- func (w *Writer) SetVal(start LineNumber, end Goto, dest Writable, src Readable)
Constants ¶
const Exit = LineNumber(0)
Exit is a reserved line number for exiting the program.
Variables ¶
var JumpRegister jumpReg
JumpRegister is the jump register. Its value decides which path is taken when using Jump as a line ending.
JumpRegister is Writable. To read from JumpRegister, use a Jump line ending.
Functions ¶
This section is empty.
Types ¶
type Goto ¶
type Goto interface {
// contains filtered or unexported methods
}
Goto is either a LineNumber or a Jump.
type Jump ¶
type Jump struct { Zero LineNumber One LineNumber }
Jump goes to a line number depending on the current value of the jump register.
type Memory ¶
Memory values can be read as pointers.
All Memory values are also Readable and Writable as bits.
type Nand ¶
Nand represents the NAND binary operator. It is equivalent to ZERO if both Left and Right are ONE, and equivalent to ONE in any other case.
Nand is Readable.
type Readable ¶
type Readable interface {
// contains filtered or unexported methods
}
Readable values can be read as bits.
type Writable ¶
type Writable interface {
// contains filtered or unexported methods
}
Writable values can be written as bits.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer implements the BIT code generator.
func (*Writer) Close ¶
Close returns the first error encountered while writing. If no write error occurred but a line number has been referenced without being written, the returned error will be non-nil. If no lines have been written, the error will be non-nil. In any other case, the error is nil.
Close does not invalidate the Writer. However, if Close returns nil, additional lines added to the program are guaranteed to be dead code.
func (*Writer) Copy ¶
func (w *Writer) Copy(start LineNumber, end Goto, dest Memory, src Memory, count uint64, srcAfterDest bool)
Copy copies a sequence of count bits from src to dest.
If src is after dest in the same buffer, set srcAfterDest to true. If dest is after src in the same buffer, set srcAfterDest to false. If src and dest are not the same buffer, srcAfterDest may have any value.
func (*Writer) NewPointer ¶
NewPointer returns a new Pointer unique within this Writer.
func (*Writer) Print ¶
func (w *Writer) Print(start LineNumber, end Goto, value Constant)
Print writes a single bit value to the standard output.
func (*Writer) Read ¶
func (w *Writer) Read(start LineNumber, end Goto)
Read reads a bit value from the standard input into the jump register.
func (*Writer) ReserveLine ¶
func (w *Writer) ReserveLine() LineNumber
ReserveLine returns a new LineNumber unique within this Writer.