Documentation
¶
Index ¶
- Constants
- Variables
- type BoolConstant
- type Bytecode
- type CharConstant
- type ClassConstant
- type Constant
- type ConstantType
- type ErrInvalidConstantType
- type FloatConstant
- type FunctionConstant
- type Header
- type IntConstant
- type InterfaceConstant
- type LineInfo
- type NilConstant
- type Reader
- type StringConstant
- type Writer
Constants ¶
const ( VersionMajor = 1 VersionMinor = 0 VersionPatch = 0 )
Version represents the bytecode format version
const Magic = 0x4E584230 // "NXB0" in hex
Magic number for Nxlang bytecode files
Variables ¶
var FullVersion = uint32(VersionMajor<<16 | VersionMinor<<8 | VersionPatch)
FullVersion combines version numbers into a single uint32
Functions ¶
This section is empty.
Types ¶
type BoolConstant ¶
type BoolConstant struct {
Value bool
}
BoolConstant represents a boolean value
func (*BoolConstant) Type ¶
func (c *BoolConstant) Type() ConstantType
type Bytecode ¶
type Bytecode struct {
Constants []Constant
MainFunc int // Index of main function in constant pool
SourceFile string
LineNumberTable []LineInfo // Maps instruction positions to line numbers
}
Bytecode represents a complete compiled program
type CharConstant ¶
type CharConstant struct {
Value rune
}
CharConstant represents a Unicode character value
func (*CharConstant) Type ¶
func (c *CharConstant) Type() ConstantType
type ClassConstant ¶
type ClassConstant struct {
Name string
SuperClass string // Name of superclass
Interfaces []string // List of interface names this class implements
Methods map[string]int // Map of method name to function constant index
StaticMethods map[string]int // Map of static method name to function constant index
}
ClassConstant represents a compiled class
func (*ClassConstant) Type ¶
func (c *ClassConstant) Type() ConstantType
type Constant ¶
type Constant interface {
Type() ConstantType
}
Constant represents an entry in the constant pool
type ConstantType ¶
type ConstantType byte
ConstantType identifies the type of constant in the constant pool
const ( ConstNil ConstantType = 0x00 ConstBool ConstantType = 0x01 ConstInt ConstantType = 0x02 ConstFloat ConstantType = 0x03 ConstString ConstantType = 0x04 ConstFunction ConstantType = 0x05 ConstClass ConstantType = 0x06 ConstChar ConstantType = 0x07 ConstInterface ConstantType = 0x08 )
type ErrInvalidConstantType ¶
type ErrInvalidConstantType struct {
Type ConstantType
}
ErrInvalidConstantType is returned when an unknown constant type is encountered
func (*ErrInvalidConstantType) Error ¶
func (e *ErrInvalidConstantType) Error() string
type FloatConstant ¶
type FloatConstant struct {
Value float64
}
FloatConstant represents a floating point value
func (*FloatConstant) Type ¶
func (c *FloatConstant) Type() ConstantType
type FunctionConstant ¶
type FunctionConstant struct {
Name string
Instructions []byte
NumLocals int
NumParameters int
IsVariadic bool
IsStatic bool // Whether this is a static method
AccessModifier uint8 // 0=public, 1=private, 2=protected
Flags uint8 // Bit flags: bit 0=isGetter, bit 1=isSetter
DefaultValues []int // Indices of default values in constant pool
}
FunctionConstant represents a compiled function
func (*FunctionConstant) Type ¶
func (c *FunctionConstant) Type() ConstantType
type Header ¶
type Header struct {
Magic uint32
Version uint32
Flags uint32
ConstCount uint32
CodeSize uint32
LineCount uint32
Reserved [16]byte
}
Header represents the header of a .nxb bytecode file
type IntConstant ¶
type IntConstant struct {
Value int64
}
IntConstant represents an integer value
func (*IntConstant) Type ¶
func (c *IntConstant) Type() ConstantType
type InterfaceConstant ¶
type InterfaceConstant struct {
Name string
Methods map[string][]string // Method name -> list of parameter names (for signature matching)
}
InterfaceConstant represents a compiled interface
func (*InterfaceConstant) Type ¶
func (c *InterfaceConstant) Type() ConstantType
type NilConstant ¶
type NilConstant struct{}
NilConstant represents a nil value
func (*NilConstant) Type ¶
func (c *NilConstant) Type() ConstantType
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader deserializes binary .nxb files into Bytecode structure
func NewReaderFromBytes ¶
NewReaderFromBytes creates a new bytecode reader from a byte slice
type StringConstant ¶
type StringConstant struct {
Value string
}
StringConstant represents a string value
func (*StringConstant) Type ¶
func (c *StringConstant) Type() ConstantType