bitgen

package
v0.0.0-...-747230a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package bitgen implements a code generator backend for BIT.

Index

Constants

View Source
const Exit = LineNumber(0)

Exit is a reserved line number for exiting the program.

Variables

View Source
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 Buffer

type Buffer uint64

Buffer is a bit variable.

Buffer is Memory.

type Constant

type Constant bool

Constant is a BIT value.

Constant is Readable.

const (
	// Zero is the Constant ZERO.
	Zero Constant = false
	// One is the Constant ONE.
	One Constant = true
)

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 LineNumber

type LineNumber uint64

LineNumber is a line number in a BIT program.

type Memory

type Memory interface {
	Readable
	Writable
	// contains filtered or unexported methods
}

Memory values can be read as pointers.

All Memory values are also Readable and Writable as bits.

type Nand

type Nand struct {
	Left  Readable
	Right Readable
}

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 Offset

type Offset struct {
	Base Memory
	Off  uint64
}

Offset is a pointer to the bit Off bits after Base.

Offset is Memory.

type Pointer

type Pointer uint64

Pointer is a pointer variable.

Pointer is Memory.

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 NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter returns a new Writer.

func (*Writer) Close

func (w *Writer) Close() error

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) NewBuffer

func (w *Writer) NewBuffer() Buffer

NewBuffer returns a new Buffer unique within this Writer.

func (*Writer) NewPointer

func (w *Writer) NewPointer() Pointer

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.

func (*Writer) SetPtr

func (w *Writer) SetPtr(start LineNumber, end Goto, dest Pointer, src Memory)

SetPtr stores a memory address in a pointer variable.

func (*Writer) SetVal

func (w *Writer) SetVal(start LineNumber, end Goto, dest Writable, src Readable)

SetVal stores a bit in a Writable destination.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL