Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidArg = errors.New("invalid argument")
ErrInvalidArg is returned when an argument is not of the expected type or size.
var ErrUnknownReference = errors.New("unknown reference")
ErrUnknownReference is returned when a reference to an unknown instruction is encountered.
Functions ¶
func Decode ¶ added in v0.19.0
Decode decodes a T3XF instruction from a byte slice. It returns the number of bytes read, the opcode and its argument.
The type of the argument depends on the opcode:
- LINE, NATLONG, SCAN, IFIELD, IGET and IDEF: the argument is an int.
- IEEE754DP: the argument is a float64.
- BITS, NIBBLES and OCTETS: the argument is a *t3xf.String. The underlying byte slice is the given byte slice b. Note, that the number of bytes read and the number of bytes in the String slice may differ, because T3XF instructions are 4-byte aligned.
- NAME, UTF8, ISTR and FSTR: the argument is a string.
- REF, GOTO and FROZEN_REF: the argument is a t3xf.Reference.
Types ¶
type Compiler ¶ added in v0.19.0
type Compiler struct {
// contains filtered or unexported fields
}
func NewCompiler ¶ added in v0.19.0
func NewCompiler() *Compiler
type Encoder ¶ added in v0.19.0
type Encoder struct {
// contains filtered or unexported fields
}
func NewEncoder ¶ added in v0.19.0
func NewEncoder() *Encoder
func (*Encoder) Assemble ¶ added in v0.19.0
Assemble returns the assembled T3XF byte code. References are resolved when possible, otherwise they are left unresolved and an error is returned.
It is safe to call Assemble multiple times during the lifetime of an Encoder.
func (*Encoder) Encode ¶ added in v0.19.0
Encode the given opcode and argument. If an argument is not of the expected type or size, an error is returned.
- References are given as the index of the Encode call that will be referenced.
- String arguments are expected to implement the Len() and Bytes() methods.
- Integer arguments are expected to be of type int.
- Float arguments are expected to be of type float64.
type EncoderError ¶ added in v0.19.0
type EncoderError struct { Err error // Underlying error I int // Instruction index Op opcode.Opcode // Current Opcode }
func (*EncoderError) Error ¶ added in v0.19.0
func (e *EncoderError) Error() string
func (*EncoderError) Unwrap ¶ added in v0.19.0
func (e *EncoderError) Unwrap() error
Directories ¶
Path | Synopsis |
---|---|
Package opcode defines the opcodes used in T3XF.
|
Package opcode defines the opcodes used in T3XF. |