t3xf

package
v0.20.5 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidArg = errors.New("invalid argument")

ErrInvalidArg is returned when an argument is not of the expected type or size.

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

func Decode(b []byte) (n int, op opcode.Opcode, arg interface{})

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 AltstepEntry added in v0.20.0

type AltstepEntry struct {
	NameStringId     uint32
	ModuleId         uint16
	RunsOnFileOffset uint32
	BodyBlockId      uint32
	ParamsBlockId    uint32
	AssetOffset      uint32
	LineNumber       uint32
}

type ArrayTypeEntry added in v0.20.0

type ArrayTypeEntry struct {
	AssetOffset           uint32
	ModuleId              uint16
	NameStringId          uint32
	ElementTypeFileOffset uint32
	DimensionBlockId      uint32
	WithBlockId           uint32
	LineNumber            uint32
}

type BlockEntry added in v0.20.0

type BlockEntry struct {
	AssetOffset uint32
	TextOffset  uint32
	Length      uint32
}

type ClosureTypeEntry added in v0.20.0

type ClosureTypeEntry struct {
	NameStringId uint32
	ModuleId     uint16
	AssetOffset  uint32
	WithBlockId  uint32
	LineNumber   uint32
}

type CollectionEntry added in v0.20.0

type CollectionEntry struct {
	DataOffset uint32
	Length     uint32
}

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

func (*Compiler) Assemble added in v0.19.0

func (c *Compiler) Assemble() ([]byte, error)

func (*Compiler) Compile added in v0.19.0

func (c *Compiler) Compile(n syntax.Node) error

func (*Compiler) Err added in v0.19.0

func (c *Compiler) Err() error

type ComponentTypeEntry added in v0.20.0

type ComponentTypeEntry struct {
	AssetOffset                uint32
	ModuleId                   uint16
	NameStringId               uint32
	ExtendingComponentsBlockId uint32
	InitialisationBlockId      uint32
	WithBlockId                uint32
	LineNumber                 uint32
}

type ConstEntry added in v0.20.0

type ConstEntry struct {
	AssetOffset           uint32
	ModuleId              uint16
	NameStringId          uint32
	TypeFileOffset        uint32
	InitialisationBlockId uint32
	WithBlockId           uint32
	LineNumber            uint32
}

type ControlEntry added in v0.20.0

type ControlEntry struct {
	AssetOffset uint32
	ModuleId    uint16
	BlockId     uint32
	Length      uint32
	LineNumber  uint32
}

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

func (e *Encoder) Assemble() ([]byte, error)

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

func (e *Encoder) Encode(op opcode.Opcode, arg any) error

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.

func (*Encoder) Len added in v0.19.0

func (e *Encoder) Len() int

func (*Encoder) Reset added in v0.19.0

func (e *Encoder) Reset()

Reset resets the encoder to its initial state.

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

type EnumeratedTypeEntry added in v0.20.0

type EnumeratedTypeEntry struct {
	AssetOffset       uint32
	ModuleId          uint16
	NameStringId      uint32
	DefinitionBlockId uint32
	WithBlockId       uint32
	ConstraintBlockId uint32
	LineNumber        uint32
}

type ExtFunctionEntry added in v0.20.0

type ExtFunctionEntry struct {
	NameStringId         uint32
	ModuleId             uint16
	ReturnTypeFileOffset uint32
	ReturnTypeFlags      uint16
	ParamsBlockId        uint32
	AssetOffset          uint32
	WithBlockId          uint32
	LineNumber           uint32
}

type File

type File struct {
	T3xf             []byte
	Text             []byte
	Int32s           []Int32Entry
	Names            []NameEntry
	Modules          []ModuleEntry
	TypeAliass       []TypeAliasEntry
	RecordTypes      []RecordTypeEntry
	SetTypes         []SetTypeEntry
	RecordOfTypes    []RecordOfTypeEntry
	SetOfTypes       []SetOfTypeEntry
	UnionTypes       []UnionTypeEntry
	EnumeratedTypes  []EnumeratedTypeEntry
	ArrayTypes       []ArrayTypeEntry
	ClosureTypes     []ClosureTypeEntry
	MessagePortTypes []MessagePortTypeEntry
	ComponentTypes   []ComponentTypeEntry
	Consts           []ConstEntry
	ModulePars       []ModuleParEntry
	Templates        []TemplateEntry
	Testcases        []TestcaseEntry
	Functions        []FunctionEntry
	ExtFunctions     []ExtFunctionEntry
	Altsteps         []AltstepEntry
	Blocks           []BlockEntry
	Controls         []ControlEntry
	Strings          []StringEntry
	Collections      []CollectionEntry
	Data             []byte
}

func Open added in v0.20.0

func Open(path string) (*File, error)

func Read added in v0.20.0

func Read(r io.Reader) (*File, error)

type FunctionEntry added in v0.20.0

type FunctionEntry struct {
	NameStringId         uint32
	ModuleId             uint16
	RunsOnFileOffset     uint32
	ReturnTypeFileOffset uint32
	ReturnTypeFlags      uint16
	BodyBlockId          uint32
	ParamsBlockId        uint32
	AssetOffset          uint32
	LineNumber           uint32
}

type Int32Entry added in v0.20.0

type Int32Entry struct {
	AssetOffset uint32
	Value       int32
}

type MessagePortTypeEntry added in v0.20.0

type MessagePortTypeEntry struct {
	AssetOffset                  uint32
	ModuleId                     uint16
	NameStringId                 uint32
	InDefinitionBlockId          uint32
	OutDefinitionBlockId         uint32
	MapParamsDefinitionBlockId   uint32
	UnmapParamsDefinitionBlockId uint32
	AddressType                  uint32
	WithBlockId                  uint32
	LineNumber                   uint32
}

type ModuleEntry added in v0.20.0

type ModuleEntry struct {
	ModuleStringId    uint32
	SourceStringId    uint32
	BlockId           uint32
	HasControlSection uint16
}

type ModuleParEntry added in v0.20.0

type ModuleParEntry struct {
	AssetOffset           uint32
	ModuleId              uint16
	NameStringId          uint32
	TypeFileOffset        uint32
	InitialisationBlockId uint32
	WithBlockId           uint32
	LineNumber            uint32
}

type NameEntry added in v0.20.0

type NameEntry struct {
	AssetOffset uint32
	StringId    uint32
}

type RecordOfTypeEntry added in v0.20.0

type RecordOfTypeEntry struct {
	AssetOffset       uint32
	ModuleId          uint16
	NameStringId      uint32
	DefinitionBlockId uint32
	ConstraintBlockId uint32
	WithBlockId       uint32
	LineNumber        uint32
}

type RecordTypeEntry added in v0.20.0

type RecordTypeEntry struct {
	AssetOffset       uint32
	ModuleId          uint16
	NameStringId      uint32
	DefinitionBlockId uint32
	WithBlockId       uint32
	ConstraintBlockId uint32
	LineNumber        uint32
}

type Reference added in v0.19.0

type Reference int

Reference is a T3XF offset.

type SetOfTypeEntry added in v0.20.0

type SetOfTypeEntry struct {
	AssetOffset           uint32
	ModuleId              uint16
	NameStringId          uint32
	ElementTypeFileOffset uint32
	ConstraintBlockId     uint32
	WithBlockId           uint32
	LineNumber            uint32
}

type SetTypeEntry added in v0.20.0

type SetTypeEntry struct {
	AssetOffset       uint32
	ModuleId          uint16
	NameStringId      uint32
	DefinitionBlockId uint32
	ConstraintBlockId uint32
	WithBlockId       uint32
	LineNumber        uint32
}

type String added in v0.19.0

type String struct {
	// contains filtered or unexported fields
}

String is a T3XF string.

func NewString added in v0.19.0

func NewString(l int, b []byte) *String

func (*String) Bytes added in v0.19.0

func (s *String) Bytes() []byte

Bytes returns the byte slice for the string.

func (*String) Len added in v0.19.0

func (s *String) Len() int

Len returns the number of elements in the string. For a bitstring, this is the number of bits, for a charstring the number of characters.

type StringEntry added in v0.20.0

type StringEntry struct {
	DataOffset uint32
	Length     uint32
}

type TemplateEntry added in v0.20.0

type TemplateEntry struct {
	AssetOffset           uint32
	ModuleId              uint16
	NameStringId          uint32
	TypeFileOffset        uint32
	ParamsBlockId         uint32
	InitialisationBlockId uint32
	LineNumber            uint32
}

type TestcaseEntry added in v0.20.0

type TestcaseEntry struct {
	NameStringId     uint32
	ModuleId         uint16
	RunsOnFileOffset uint32
	SystemFileOffset uint32
	BodyBlockId      uint32
	ParamsBlockId    uint32
	AssetOffset      uint32
	LineNumber       uint32
}

type TypeAliasEntry added in v0.20.0

type TypeAliasEntry struct {
	AssetOffset        uint32
	ModuleId           uint16
	NameStringId       uint32
	RootTypeFileOffset uint32
	WithBlockId        uint32
	ConstraintBlockId  uint32
	LineNumber         uint32
}

type UnionTypeEntry added in v0.20.0

type UnionTypeEntry struct {
	AssetOffset       uint32
	ModuleId          uint16
	NameStringId      uint32
	DefinitionBlockId uint32
	WithBlockId       uint32
	ConstraintBlockId uint32
	LineNumber        uint32
}

Directories

Path Synopsis
Package opcode defines the opcodes used in T3XF.
Package opcode defines the opcodes used in T3XF.

Jump to

Keyboard shortcuts

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