definition

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Bool    = BasicType{TypeTypeID: TypeID_Bool, TypeName: "bool", TypeBitSize: 8}
	Uint8   = BasicType{TypeTypeID: TypeID_Uint8, TypeName: "uint8", TypeBitSize: 8}
	Uint16  = BasicType{TypeTypeID: TypeID_Uint16, TypeName: "uint16", TypeBitSize: 16}
	Uint32  = BasicType{TypeTypeID: TypeID_Uint32, TypeName: "uint32", TypeBitSize: 32}
	Uint64  = BasicType{TypeTypeID: TypeID_Uint64, TypeName: "uint64", TypeBitSize: 64}
	Int8    = BasicType{TypeTypeID: TypeID_Int8, TypeName: "int8", TypeBitSize: 8}
	Int16   = BasicType{TypeTypeID: TypeID_Int16, TypeName: "int16", TypeBitSize: 16}
	Int32   = BasicType{TypeTypeID: TypeID_Int32, TypeName: "int32", TypeBitSize: 32}
	Int64   = BasicType{TypeTypeID: TypeID_Int64, TypeName: "int64", TypeBitSize: 64}
	Float32 = BasicType{TypeTypeID: TypeID_Float32, TypeName: "float32", TypeBitSize: 32}
	Float64 = BasicType{TypeTypeID: TypeID_Float64, TypeName: "float64", TypeBitSize: 64}
)
View Source
var EmptyPackage = &Package{}
View Source
var FieldKindIDStringsMap = map[FieldKindID]string{
	FieldKindID_Normal:   "NormalField",
	FieldKindID_Void:     "VoidField",
	FieldKindID_Embedded: "EmbeddedField",
	FieldKindID_Constant: "ConstantField",
}

Functions

This section is empty.

Types

type ArithOverflowWarning

type ArithOverflowWarning struct {
	Expr string
	From string
	To   string
}

func (ArithOverflowWarning) Error

func (w ArithOverflowWarning) Error() string

func (ArithOverflowWarning) String

func (w ArithOverflowWarning) String() string

type ArithSignToUnsignWarning

type ArithSignToUnsignWarning struct {
	Expr string
	From string
	To   string
}

func (ArithSignToUnsignWarning) Error

func (w ArithSignToUnsignWarning) Error() string

func (ArithSignToUnsignWarning) String

func (w ArithSignToUnsignWarning) String() string

type ArithTruncationWarning

type ArithTruncationWarning struct {
	Expr string
	From string
	To   string
}

func (ArithTruncationWarning) Error

func (w ArithTruncationWarning) Error() string

func (ArithTruncationWarning) String

func (w ArithTruncationWarning) String() string

type Array

type Array struct {
	ElementType Type
	Length      int64
}

func (Array) GetTypeBitSize

func (t Array) GetTypeBitSize() int64

func (Array) GetTypeID

func (t Array) GetTypeID() TypeID

func (Array) GetTypeName

func (t Array) GetTypeName() string

func (Array) String

func (t Array) String() string

type BasePosition

type BasePosition struct {
	File   string
	Line   int
	Column int
}

func (BasePosition) GetColumn

func (p BasePosition) GetColumn() int

func (BasePosition) GetFile

func (p BasePosition) GetFile() string

func (BasePosition) GetLine

func (p BasePosition) GetLine() int

func (BasePosition) GetPositionString

func (p BasePosition) GetPositionString() string

func (BasePosition) PositionEquals added in v0.4.0

func (p BasePosition) PositionEquals(pos Position) bool

func (BasePosition) String

func (p BasePosition) String() string

type BasicType

type BasicType struct {
	TypeTypeID  TypeID
	TypeName    string
	TypeBitSize int64
}

func GetBasicType added in v0.4.0

func GetBasicType(typeID TypeID) *BasicType

func (BasicType) GetTypeBitSize

func (t BasicType) GetTypeBitSize() int64

func (BasicType) GetTypeID

func (t BasicType) GetTypeID() TypeID

func (BasicType) GetTypeName

func (t BasicType) GetTypeName() string

func (BasicType) String

func (t BasicType) String() string

type BinopExpr

type BinopExpr struct {
	BasePosition

	ExprType *BasicType
	Op       ExprOp
	Expr1    Expr
	Expr2    Expr
}

func (BinopExpr) GetExprKind

func (b BinopExpr) GetExprKind() ExprKindID

func (BinopExpr) GetExprType

func (b BinopExpr) GetExprType() *BasicType

func (BinopExpr) String

func (b BinopExpr) String() string

type BoolLiteral

type BoolLiteral struct {
	BasePosition
	BoolValue bool
}

func (BoolLiteral) GetLiteralKind

func (l BoolLiteral) GetLiteralKind() LiteralKindID

func (BoolLiteral) GetLiteralValue

func (l BoolLiteral) GetLiteralValue() interface{}

func (BoolLiteral) GetLiteralValueIn

func (l BoolLiteral) GetLiteralValueIn(ty TypeID) interface{}

func (BoolLiteral) GetMinimalTypeID added in v0.4.0

func (l BoolLiteral) GetMinimalTypeID() TypeID

func (BoolLiteral) String

func (l BoolLiteral) String() string

type Bytes

type Bytes struct{}

func (Bytes) GetTypeBitSize

func (t Bytes) GetTypeBitSize() int64

func (Bytes) GetTypeID

func (t Bytes) GetTypeID() TypeID

func (Bytes) GetTypeName

func (t Bytes) GetTypeName() string

func (Bytes) String

func (t Bytes) String() string

type CastExpr

type CastExpr struct {
	BasePosition

	ToType *BasicType
	Expr1  Expr
}

func (CastExpr) GetExprKind

func (c CastExpr) GetExprKind() ExprKindID

func (CastExpr) GetExprType

func (c CastExpr) GetExprType() *BasicType

func (CastExpr) String

func (c CastExpr) String() string

type CompilationUnit

type CompilationUnit struct {
	UnitName *FileIdentifer
	Package  *Package
	Options  *util.OrderedMap[string, *Option]

	GlobalImports *util.OrderedMap[string, *CompilationUnit] // GlobalImports contains all the imports, including indirect imports
	LocalImports  *util.OrderedMap[string, *CompilationUnit] // LocalImports contains direct imports of this unit

	// GlobalTypes and GlobalNames include imported types, representing all the defs visible to this unit
	GlobalTypes *util.OrderedMap[string, CustomType] // GlobalTypes contains all the top-level typedefs (inner typedefs excluded)
	GlobalNames *util.OrderedMap[string, Position]   // GlobalNames contains all the names (inner typedefs' name included)

	// LocalTypes and LocalNames are only contained types and names defined in this unit
	LocalTypes *util.OrderedMap[string, CustomType] // LocalTypes contains all the top-level typedefs (inner typedefs excluded)
	LocalNames *util.OrderedMap[string, Position]   // LocalNames contains all the local names (inner typedefs' name included)
}

func NewCompilationUnit

func NewCompilationUnit(name *FileIdentifer) *CompilationUnit

func (*CompilationUnit) AddGlobalName added in v0.3.0

func (c *CompilationUnit) AddGlobalName(name string, pos Position) error

AddGlobalName adds a name to this unit

returns DefinitionDuplicateError if the name is already defined in global scope

returns nil if found the name of same position

func (*CompilationUnit) AddGlobalType added in v0.3.0

func (c *CompilationUnit) AddGlobalType(ty CustomType) error

AddGlobalType adds a typedef to this unit

returns DefinitionDuplicateError if the type name is already defined in global scope

returns nil if found the definition of same position

There's no need to call AddGlobalName again for the same type

func (*CompilationUnit) AddImport

func (c *CompilationUnit) AddImport(other *CompilationUnit) error

AddImport adds a compilation unit to this unit

func (*CompilationUnit) AddLocalName added in v0.3.0

func (c *CompilationUnit) AddLocalName(name string, pos Position) error

AddLocalName adds a name to this unit (for embedded structs or enum values)

returns DefinitionDuplicateError if the name is already defined in global scope

func (*CompilationUnit) AddLocalType added in v0.3.0

func (c *CompilationUnit) AddLocalType(ty CustomType) error

AddLocalType adds a typedef to this unit

returns DefinitionDuplicateError if the type name is already defined in global scope

There's no need to call AddLocalName again for the same type

func (CompilationUnit) String

func (c CompilationUnit) String() string

type CompileError

type CompileError struct {
	TopLevelError
	Position
	Err error
}

func (CompileError) Error

func (e CompileError) Error() string

func (CompileError) String

func (e CompileError) String() string

type CompileWarning

type CompileWarning struct {
	TopLevelWarning
	Position
	Warning error
}

func (CompileWarning) Error

func (w CompileWarning) Error() string

func (CompileWarning) String

func (w CompileWarning) String() string

type ConstantExpr

type ConstantExpr struct {
	BasePosition

	ConstantType  *BasicType
	ConstantValue Literal
}

func (ConstantExpr) GetExprKind

func (c ConstantExpr) GetExprKind() ExprKindID

func (ConstantExpr) GetExprType

func (c ConstantExpr) GetExprType() *BasicType

func (ConstantExpr) String

func (c ConstantExpr) String() string

type ConstantField

type ConstantField struct {
	BasePosition

	FieldName     string // may be empty
	FieldType     *BasicType
	FieldBitSize  int64
	FieldConstant Literal
	FieldOptions  *util.OrderedMap[string, *Option]
	FieldBelongs  *Struct
}

func (ConstantField) Copy

func (f ConstantField) Copy() Field

func (ConstantField) DumpString added in v0.4.0

func (f ConstantField) DumpString() string

func (ConstantField) GetFieldBelongs

func (f ConstantField) GetFieldBelongs() *Struct

func (ConstantField) GetFieldBitSize

func (f ConstantField) GetFieldBitSize() int64

func (ConstantField) GetFieldKind

func (f ConstantField) GetFieldKind() FieldKindID

func (ConstantField) GetFieldUniqueName

func (f ConstantField) GetFieldUniqueName() string

func (*ConstantField) SetFieldBelongs

func (f *ConstantField) SetFieldBelongs(s *Struct)

func (ConstantField) String

func (f ConstantField) String() string

type CustomType

type CustomType interface {
	Position
	Type
}

type DefinitionDuplicateError

type DefinitionDuplicateError struct {
	DefName string // type, field or method name
	PrevDef Position
}

func (DefinitionDuplicateError) Error

func (e DefinitionDuplicateError) Error() string

func (DefinitionDuplicateError) String

func (e DefinitionDuplicateError) String() string

type DefinitionNotFoundError

type DefinitionNotFoundError struct {
	DefName string // type, field or method name
}

func (DefinitionNotFoundError) Error

func (e DefinitionNotFoundError) Error() string

func (DefinitionNotFoundError) String

func (e DefinitionNotFoundError) String() string

type DefinitionTypeConflictError

type DefinitionTypeConflictError struct {
	DefName string
	Expect  string
	Got     string
}

func (DefinitionTypeConflictError) Error

func (DefinitionTypeConflictError) String

type EmbeddedField

type EmbeddedField struct {
	BasePosition

	FieldType    *Struct
	FieldBitSize int64
	FieldOptions *util.OrderedMap[string, *Option]
	FieldBelongs *Struct
}

func (EmbeddedField) Copy

func (f EmbeddedField) Copy() Field

func (EmbeddedField) DumpString added in v0.4.0

func (f EmbeddedField) DumpString() string

func (EmbeddedField) GetFieldBelongs

func (f EmbeddedField) GetFieldBelongs() *Struct

func (EmbeddedField) GetFieldBitSize

func (f EmbeddedField) GetFieldBitSize() int64

func (EmbeddedField) GetFieldKind

func (f EmbeddedField) GetFieldKind() FieldKindID

func (EmbeddedField) GetFieldUniqueName

func (f EmbeddedField) GetFieldUniqueName() string

func (*EmbeddedField) SetFieldBelongs

func (f *EmbeddedField) SetFieldBelongs(s *Struct)

func (EmbeddedField) String

func (f EmbeddedField) String() string

type EmbeddedFieldError

type EmbeddedFieldError struct {
	DefName string
	Err     error
}

func (EmbeddedFieldError) Error

func (e EmbeddedFieldError) Error() string

func (EmbeddedFieldError) String

func (e EmbeddedFieldError) String() string

type Enum

type Enum struct {
	BasePosition

	EnumName    string
	EnumBitSize int64
	EnumValues  *util.OrderedMap[string, *EnumValue]
}

func (*Enum) GetTypeBitSize

func (e *Enum) GetTypeBitSize() int64

func (*Enum) GetTypeID

func (e *Enum) GetTypeID() TypeID

func (*Enum) GetTypeName

func (e *Enum) GetTypeName() string

func (Enum) ShortString

func (e Enum) ShortString() string

func (Enum) String

func (e Enum) String() string

type EnumConstValueTypeError

type EnumConstValueTypeError struct {
	Constant string
	Got      string
}

func (EnumConstValueTypeError) Error

func (e EnumConstValueTypeError) Error() string

func (EnumConstValueTypeError) String

func (e EnumConstValueTypeError) String() string

type EnumValue

type EnumValue struct {
	BasePosition

	EnumValueName    string
	EnumValue        int64
	EnumValueBelongs *Enum
}

func (EnumValue) String

func (e EnumValue) String() string

type Expr

type Expr interface {
	Position
	GetExprKind() ExprKindID
	GetExprType() *BasicType
}

type ExprKindID

type ExprKindID int
const (
	ExprKindID_UnopExpr ExprKindID = iota
	ExprKindID_BinopExpr
	ExprKindID_CastExpr
	ExprKindID_TenaryExpr
	ExprKindID_ConstantExpr
	ExprKindID_ValueExpr
	ExprKindID_RawExpr
)

func (ExprKindID) IsBinopExpr added in v0.4.0

func (e ExprKindID) IsBinopExpr() bool

func (ExprKindID) IsCastExpr added in v0.4.0

func (e ExprKindID) IsCastExpr() bool

func (ExprKindID) IsConstantExpr added in v0.4.0

func (e ExprKindID) IsConstantExpr() bool

func (ExprKindID) IsRawExpr added in v0.4.0

func (e ExprKindID) IsRawExpr() bool

func (ExprKindID) IsTenaryExpr added in v0.4.0

func (e ExprKindID) IsTenaryExpr() bool

func (ExprKindID) IsUnopExpr added in v0.4.0

func (e ExprKindID) IsUnopExpr() bool

func (ExprKindID) IsValueExpr added in v0.4.0

func (e ExprKindID) IsValueExpr() bool

type ExprOp

type ExprOp int
const (
	ExprOp_ADD    ExprOp = iota // +
	ExprOp_SUB                  // -
	ExprOp_MUL                  // *
	ExprOp_DIV                  // /
	ExprOp_MOD                  // %
	ExprOp_POW                  // **
	ExprOp_SHL                  // <<
	ExprOp_SHR                  // >>
	ExprOp_LT                   // <
	ExprOp_LE                   // <=
	ExprOp_GT                   // >
	ExprOp_GE                   // >=
	ExprOp_EQ                   // ==
	ExprOp_NE                   // !=
	ExprOp_BAND                 // &
	ExprOp_BXOR                 // ^
	ExprOp_BOR                  // |
	ExprOp_AND                  // &&
	ExprOp_OR                   // ||
	ExprOp_NOT                  // !
	ExprOp_BNOT                 // ~
	ExprOp_ASSIGN               // =
)

func (ExprOp) IsAdd added in v0.4.0

func (e ExprOp) IsAdd() bool

func (ExprOp) IsAnd added in v0.4.0

func (e ExprOp) IsAnd() bool

func (ExprOp) IsAssign added in v0.4.0

func (e ExprOp) IsAssign() bool

func (ExprOp) IsBand added in v0.4.0

func (e ExprOp) IsBand() bool

func (ExprOp) IsBnot added in v0.4.0

func (e ExprOp) IsBnot() bool

func (ExprOp) IsBor added in v0.4.0

func (e ExprOp) IsBor() bool

func (ExprOp) IsBxor added in v0.4.0

func (e ExprOp) IsBxor() bool

func (ExprOp) IsDiv added in v0.4.0

func (e ExprOp) IsDiv() bool

func (ExprOp) IsEq added in v0.4.0

func (e ExprOp) IsEq() bool

func (ExprOp) IsGe added in v0.4.0

func (e ExprOp) IsGe() bool

func (ExprOp) IsGt added in v0.4.0

func (e ExprOp) IsGt() bool

func (ExprOp) IsLe added in v0.4.0

func (e ExprOp) IsLe() bool

func (ExprOp) IsLt added in v0.4.0

func (e ExprOp) IsLt() bool

func (ExprOp) IsMod added in v0.4.0

func (e ExprOp) IsMod() bool

func (ExprOp) IsMul added in v0.4.0

func (e ExprOp) IsMul() bool

func (ExprOp) IsNe added in v0.4.0

func (e ExprOp) IsNe() bool

func (ExprOp) IsNot added in v0.4.0

func (e ExprOp) IsNot() bool

func (ExprOp) IsOr added in v0.4.0

func (e ExprOp) IsOr() bool

func (ExprOp) IsPow added in v0.4.0

func (e ExprOp) IsPow() bool

func (ExprOp) IsShl added in v0.4.0

func (e ExprOp) IsShl() bool

func (ExprOp) IsShr added in v0.4.0

func (e ExprOp) IsShr() bool

func (ExprOp) IsSub added in v0.4.0

func (e ExprOp) IsSub() bool

func (ExprOp) String

func (e ExprOp) String() string

type Field

type Field interface {
	Position
	GetFieldKind() FieldKindID
	GetFieldUniqueName() string
	GetFieldBitSize() int64
	GetFieldBelongs() *Struct
	SetFieldBelongs(*Struct)
	Copy() Field
}

type FieldConstValueTypeError

type FieldConstValueTypeError struct {
	Constant string
	Expect   string
	Got      string
}

func (FieldConstValueTypeError) Error

func (e FieldConstValueTypeError) Error() string

func (FieldConstValueTypeError) String

func (e FieldConstValueTypeError) String() string

type FieldKindID

type FieldKindID int
const (
	FieldKindID_Normal FieldKindID = iota
	FieldKindID_Void
	FieldKindID_Embedded
	FieldKindID_Constant
)

func (FieldKindID) IsConstant added in v0.4.0

func (f FieldKindID) IsConstant() bool

func (FieldKindID) IsEmbedded added in v0.4.0

func (f FieldKindID) IsEmbedded() bool

func (FieldKindID) IsNormal added in v0.4.0

func (f FieldKindID) IsNormal() bool

func (FieldKindID) IsVoid added in v0.4.0

func (f FieldKindID) IsVoid() bool

func (FieldKindID) String added in v0.4.0

func (f FieldKindID) String() string

type FieldNotAlignedError added in v0.4.0

type FieldNotAlignedError struct {
	FieldName string
	Start     int64
	Msg       string
}

func (FieldNotAlignedError) Error added in v0.4.0

func (e FieldNotAlignedError) Error() string

func (FieldNotAlignedError) String added in v0.4.0

func (e FieldNotAlignedError) String() string

type FileIdentifer

type FileIdentifer struct {
	Name string // file name written in import statement, can be relative or absolute
	Path string // absolute path
}

func (FileIdentifer) String

func (f FileIdentifer) String() string

type FileNotFoundError

type FileNotFoundError struct {
	File *FileIdentifer
	Err  error
}

func (FileNotFoundError) Error

func (e FileNotFoundError) Error() string

func (FileNotFoundError) String

func (e FileNotFoundError) String() string

type FileReadError

type FileReadError struct {
	File *FileIdentifer
	Err  error
}

func (FileReadError) Error

func (e FileReadError) Error() string

func (FileReadError) String

func (e FileReadError) String() string

type FileWriteError

type FileWriteError struct {
	File *FileIdentifer
	Err  error
}

func (FileWriteError) Error

func (e FileWriteError) Error() string

func (FileWriteError) String

func (e FileWriteError) String() string

type FloatLiteral

type FloatLiteral struct {
	BasePosition
	FloatValue float64
}

func (FloatLiteral) GetLiteralKind

func (l FloatLiteral) GetLiteralKind() LiteralKindID

func (FloatLiteral) GetLiteralValue

func (l FloatLiteral) GetLiteralValue() interface{}

func (FloatLiteral) GetLiteralValueIn

func (l FloatLiteral) GetLiteralValueIn(ty TypeID) interface{}

func (FloatLiteral) GetMinimalTypeID added in v0.4.0

func (l FloatLiteral) GetMinimalTypeID() TypeID

func (FloatLiteral) String

func (l FloatLiteral) String() string

type GeneralError

type GeneralError struct {
	TopLevelError
	Position
	Err error
}

func (GeneralError) Error

func (e GeneralError) Error() string

func (GeneralError) String

func (e GeneralError) String() string

type GeneralWarning

type GeneralWarning struct {
	TopLevelWarning
	Position
	Warning error
}

func (GeneralWarning) Error

func (w GeneralWarning) Error() string

func (GeneralWarning) String

func (w GeneralWarning) String() string

type GenerateError added in v0.4.0

type GenerateError struct {
	TopLevelError
	Err error
}

func (GenerateError) Error added in v0.4.0

func (e GenerateError) Error() string

func (GenerateError) String added in v0.4.0

func (e GenerateError) String() string

type GenerateWarning added in v0.4.0

type GenerateWarning struct {
	TopLevelWarning
	Warning error
}

func (GenerateWarning) Error added in v0.4.0

func (w GenerateWarning) Error() string

func (GenerateWarning) String added in v0.4.0

func (w GenerateWarning) String() string

type GetMethod added in v0.4.0

type GetMethod struct {
	BasePosition

	MethodName    string
	MethodRetType Type
	MethodExpr    Expr
	MethodBelongs *NormalField
}

func (GetMethod) GetMethodBelongs added in v0.4.0

func (m GetMethod) GetMethodBelongs() *NormalField

func (GetMethod) GetMethodKind added in v0.4.0

func (m GetMethod) GetMethodKind() MethodKindID

func (GetMethod) GetMethodName added in v0.4.0

func (m GetMethod) GetMethodName() string

func (*GetMethod) SetMethodBelongs added in v0.4.0

func (m *GetMethod) SetMethodBelongs(belongs *NormalField)

type ImportCycleError

type ImportCycleError struct {
	File *FileIdentifer
}

func (ImportCycleError) Error

func (e ImportCycleError) Error() string

func (ImportCycleError) String

func (e ImportCycleError) String() string

type ImportSelfError

type ImportSelfError struct{}

func (ImportSelfError) Error

func (e ImportSelfError) Error() string

func (ImportSelfError) String

func (e ImportSelfError) String() string

type ImportingError

type ImportingError struct {
	File *FileIdentifer
	Err  error
}

func (ImportingError) Error

func (e ImportingError) Error() string

func (ImportingError) String

func (e ImportingError) String() string

type ImportingWarning

type ImportingWarning struct {
	File    *FileIdentifer
	Warning error
}

func (ImportingWarning) Error

func (w ImportingWarning) Error() string

func (ImportingWarning) String

func (w ImportingWarning) String() string

type IntLiteral

type IntLiteral struct {
	BasePosition
	IntValue int64
}

func (IntLiteral) GetLiteralKind

func (l IntLiteral) GetLiteralKind() LiteralKindID

func (IntLiteral) GetLiteralValue

func (l IntLiteral) GetLiteralValue() interface{}

func (IntLiteral) GetLiteralValueIn

func (l IntLiteral) GetLiteralValueIn(ty TypeID) interface{}

func (IntLiteral) GetMinimalTypeID added in v0.4.0

func (l IntLiteral) GetMinimalTypeID() TypeID

func (IntLiteral) String

func (l IntLiteral) String() string

type InvalidEmbeddedFieldError

type InvalidEmbeddedFieldError struct{}

func (InvalidEmbeddedFieldError) Error

func (InvalidEmbeddedFieldError) String

func (e InvalidEmbeddedFieldError) String() string

type InvalidEnumDefError

type InvalidEnumDefError struct {
	DefName string
	Err     error
}

func (InvalidEnumDefError) Error

func (e InvalidEnumDefError) Error() string

func (InvalidEnumDefError) String

func (e InvalidEnumDefError) String() string

type InvalidFieldError

type InvalidFieldError struct {
	FieldName string
	Msg       string
}

func (InvalidFieldError) Error

func (e InvalidFieldError) Error() string

func (InvalidFieldError) String

func (e InvalidFieldError) String() string

type InvalidLiteralError

type InvalidLiteralError struct {
	Literal string
	Err     error
}

func (InvalidLiteralError) Error

func (e InvalidLiteralError) Error() string

func (InvalidLiteralError) String

func (e InvalidLiteralError) String() string

type InvalidSizeError

type InvalidSizeError struct {
	Size int64
	Msg  string
}

func (InvalidSizeError) Error

func (e InvalidSizeError) Error() string

func (InvalidSizeError) String

func (e InvalidSizeError) String() string

type InvalidStructDefError

type InvalidStructDefError struct {
	DefName string
	Err     error
}

func (InvalidStructDefError) Error

func (e InvalidStructDefError) Error() string

func (InvalidStructDefError) String

func (e InvalidStructDefError) String() string

type JoinTopLevelErrors

type JoinTopLevelErrors struct {
	TopLevelError
	Errs []TopLevelError
}

func (JoinTopLevelErrors) Error

func (e JoinTopLevelErrors) Error() string

func (JoinTopLevelErrors) String

func (e JoinTopLevelErrors) String() string

type JoinTopLevelWarnings

type JoinTopLevelWarnings struct {
	TopLevelWarning
	Warnings []TopLevelWarning
}

func (JoinTopLevelWarnings) Error

func (w JoinTopLevelWarnings) Error() string

func (JoinTopLevelWarnings) String

func (w JoinTopLevelWarnings) String() string

type Literal

type Literal interface {
	GetLiteralKind() LiteralKindID
	GetLiteralValue() interface{}
	GetLiteralValueIn(ty TypeID) interface{}
	GetMinimalTypeID() TypeID
}

type LiteralKindID

type LiteralKindID int
const (
	LiteralKindID_Bool LiteralKindID = iota
	LiteralKindID_Int
	LiteralKindID_Float
	LiteralKindID_String
)

func (LiteralKindID) IsBool added in v0.3.0

func (l LiteralKindID) IsBool() bool

func (LiteralKindID) IsFloat added in v0.3.0

func (l LiteralKindID) IsFloat() bool

func (LiteralKindID) IsInt added in v0.3.0

func (l LiteralKindID) IsInt() bool

func (LiteralKindID) IsString added in v0.3.0

func (l LiteralKindID) IsString() bool

func (LiteralKindID) String

func (l LiteralKindID) String() string

type Method

type Method interface {
	Position
	GetMethodKind() MethodKindID
	GetMethodName() string
	GetMethodBelongs() *NormalField
	SetMethodBelongs(*NormalField)
}

type MethodKindID

type MethodKindID int
const (
	MethodKindID_Get MethodKindID = iota
	MethodKindID_Set
)

func (MethodKindID) IsGet added in v0.4.0

func (m MethodKindID) IsGet() bool

func (MethodKindID) IsSet added in v0.4.0

func (m MethodKindID) IsSet() bool

func (MethodKindID) String

func (m MethodKindID) String() string

type MultipleInputFileError added in v0.4.0

type MultipleInputFileError struct {
	Files []string
}

func (MultipleInputFileError) Error added in v0.4.0

func (e MultipleInputFileError) Error() string

func (MultipleInputFileError) String added in v0.4.0

func (e MultipleInputFileError) String() string

type NameStyleError

type NameStyleError struct {
	Name string
	Msg  string
}

func (NameStyleError) Error

func (e NameStyleError) Error() string

func (NameStyleError) String

func (e NameStyleError) String() string

type NameStyleNotStandardWarning added in v0.4.0

type NameStyleNotStandardWarning struct {
	OriginName string
	RecommName string
	Standard   string
}

func (NameStyleNotStandardWarning) Error added in v0.4.0

func (NameStyleNotStandardWarning) String added in v0.4.0

type NameStyleWarning

type NameStyleWarning struct {
	Name string
	Msg  string
}

func (NameStyleWarning) Error

func (w NameStyleWarning) Error() string

func (NameStyleWarning) String

func (w NameStyleWarning) String() string

type NoInputFileError added in v0.4.0

type NoInputFileError struct{}

func (NoInputFileError) Error added in v0.4.0

func (e NoInputFileError) Error() string

func (NoInputFileError) String added in v0.4.0

func (e NoInputFileError) String() string

type NormalField

type NormalField struct {
	BasePosition

	FieldName    string
	FieldType    Type
	FieldBitSize int64
	FieldMethods *util.OrderedMap[string, *util.OrderedMap[MethodKindID, Method]]
	FieldOptions *util.OrderedMap[string, *Option]
	FieldBelongs *Struct
}

func (NormalField) Copy

func (f NormalField) Copy() Field

func (NormalField) DumpString added in v0.4.0

func (f NormalField) DumpString() string

func (NormalField) GetFieldBelongs

func (f NormalField) GetFieldBelongs() *Struct

func (NormalField) GetFieldBitSize

func (f NormalField) GetFieldBitSize() int64

func (NormalField) GetFieldKind

func (f NormalField) GetFieldKind() FieldKindID

func (NormalField) GetFieldUniqueName

func (f NormalField) GetFieldUniqueName() string

func (*NormalField) SetFieldBelongs

func (f *NormalField) SetFieldBelongs(s *Struct)

func (NormalField) String

func (f NormalField) String() string

type Option

type Option struct {
	BasePosition

	OptionName  string
	OptionValue Literal
}

func (Option) String

func (o Option) String() string

type OptionDuplicateError

type OptionDuplicateError struct {
	PrevDef    Position
	OptionName string
}

func (OptionDuplicateError) Error

func (e OptionDuplicateError) Error() string

func (OptionDuplicateError) String

func (e OptionDuplicateError) String() string

type OptionNotAvailableWarning added in v0.4.0

type OptionNotAvailableWarning struct {
	OptionName string
	Reason     string
}

func (OptionNotAvailableWarning) Error added in v0.4.0

func (OptionNotAvailableWarning) String added in v0.4.0

func (w OptionNotAvailableWarning) String() string

type OptionTypeError

type OptionTypeError struct {
	OptionName string
	Expect     string
	Got        string
}

func (OptionTypeError) Error

func (e OptionTypeError) Error() string

func (OptionTypeError) String

func (e OptionTypeError) String() string

type OptionUnknownWarning

type OptionUnknownWarning struct {
	OptionName string
}

func (OptionUnknownWarning) Error

func (w OptionUnknownWarning) Error() string

func (OptionUnknownWarning) String

func (w OptionUnknownWarning) String() string

type OptionValueError

type OptionValueError struct {
	OptionName string
	Expect     []any
	Got        any
}

func (OptionValueError) Error

func (e OptionValueError) Error() string

func (OptionValueError) String

func (e OptionValueError) String() string

type Package

type Package struct {
	BasePosition

	PackageFullPaths []string // com.example.app.module.pkgname
	PackagePath      []string // com.example.app.module
	PackageName      string   // pkgname
}

func NewPackage added in v0.3.0

func NewPackage(pos Position, fullPaths []string) *Package

func (Package) Difference added in v0.3.0

func (p Package) Difference(other *Package) (diff []string)

Difference returns the diffence of this package and other package name

e.g. com.example.app.module.pkgname and com.example.app.module.pkgname2 returns ["pkgname2"]

e.g. com.example.app.module.pkgname and com.example.app2 returns ["..", "..", "app2"]

e.g. com.example.app.module.pkgname and tt.t returns ["..", "..", "..", "..", "tt", "t"]

e.g. com.example.app.module.pkgname and com.example.app.module.pkgname.subpkg.abc returns ["subpkg", "abc"]

func (Package) PackageEquals added in v0.4.0

func (p Package) PackageEquals(other *Package) bool

func (Package) String

func (p Package) String() string

func (Package) ToFilePath added in v0.3.0

func (p Package) ToFilePath(ext string) string

ToFilePath returns the file path of this package

ext must start with a dot (e.g. ".h", ".c", ".py")

func (Package) ToPath added in v0.3.0

func (p Package) ToPath(sep, ext string) string

ToPath returns the path of this package

sep must be a valid path separator (e.g. "/", ".")

ext must start with a dot (e.g. ".h", ".c", ".py")

func (Package) ToRelativePath added in v0.3.0

func (p Package) ToRelativePath(other *Package, ext string) string

ToRelativePath returns the relative path of this package to other package

ext must start with a dot (e.g. ".h", ".c", ".py")

type PackageDefinitionDuplicateError added in v0.3.0

type PackageDefinitionDuplicateError struct {
	PrevDef     Position
	PackageName string
}

func (PackageDefinitionDuplicateError) Error added in v0.3.0

func (PackageDefinitionDuplicateError) String added in v0.3.0

type PackageDuplicateError

type PackageDuplicateError struct {
	PrevDef Position
	Package *Package
}

func (PackageDuplicateError) Error

func (e PackageDuplicateError) Error() string

func (PackageDuplicateError) String

func (e PackageDuplicateError) String() string

type PackageNameNotSetError added in v0.3.0

type PackageNameNotSetError struct{}

func (PackageNameNotSetError) Error added in v0.3.0

func (e PackageNameNotSetError) Error() string

func (PackageNameNotSetError) String added in v0.3.0

func (e PackageNameNotSetError) String() string

type PackageNameNotSetWarning

type PackageNameNotSetWarning struct{}

func (PackageNameNotSetWarning) Error

func (w PackageNameNotSetWarning) Error() string

func (PackageNameNotSetWarning) String

func (w PackageNameNotSetWarning) String() string

type Position

type Position interface {
	GetFile() string
	GetLine() int
	GetColumn() int
	GetPositionString() string
	PositionEquals(Position) bool
}

type RawExpr added in v0.4.0

type RawExpr struct {
	BasePosition

	ExprType *BasicType
	Expr     string
}

func (RawExpr) GetExprKind added in v0.4.0

func (r RawExpr) GetExprKind() ExprKindID

func (RawExpr) GetExprType added in v0.4.0

func (r RawExpr) GetExprType() *BasicType

func (RawExpr) String added in v0.4.0

func (r RawExpr) String() string

type SetMethod added in v0.4.0

type SetMethod struct {
	BasePosition

	MethodName      string
	MethodParamType Type
	MethodExpr      Expr
	MethodBelongs   *NormalField
}

func (SetMethod) GetMethodBelongs added in v0.4.0

func (m SetMethod) GetMethodBelongs() *NormalField

func (SetMethod) GetMethodKind added in v0.4.0

func (m SetMethod) GetMethodKind() MethodKindID

func (SetMethod) GetMethodName added in v0.4.0

func (m SetMethod) GetMethodName() string

func (*SetMethod) SetMethodBelongs added in v0.4.0

func (m *SetMethod) SetMethodBelongs(belongs *NormalField)

type String

type String struct{}

func (String) GetTypeBitSize

func (t String) GetTypeBitSize() int64

func (String) GetTypeID

func (t String) GetTypeID() TypeID

func (String) GetTypeName

func (t String) GetTypeName() string

func (String) String

func (t String) String() string

type StringLiteral

type StringLiteral struct {
	BasePosition
	StringValue string
}

func (StringLiteral) GetLiteralKind

func (l StringLiteral) GetLiteralKind() LiteralKindID

func (StringLiteral) GetLiteralValue

func (l StringLiteral) GetLiteralValue() interface{}

func (StringLiteral) GetLiteralValueIn

func (l StringLiteral) GetLiteralValueIn(ty TypeID) interface{}

func (StringLiteral) GetMinimalTypeID added in v0.4.0

func (l StringLiteral) GetMinimalTypeID() TypeID

func (StringLiteral) String

func (l StringLiteral) String() string

type Struct

type Struct struct {
	BasePosition

	StructName    string
	StructBitSize int64
	StructFields  *util.OrderedMap[string, Field]
}

func (Struct) DumpString added in v0.4.0

func (s Struct) DumpString() string

func (*Struct) ForEachField added in v0.4.0

func (s *Struct) ForEachField(f func(field Field, index int, start int64) error) error

func (*Struct) ForEachFieldWithPos added in v0.4.0

func (s *Struct) ForEachFieldWithPos(f func(field Field, index int, start int64, pos string) error) error

func (Struct) GetTypeBitSize

func (s Struct) GetTypeBitSize() int64

func (Struct) GetTypeID

func (s Struct) GetTypeID() TypeID

func (Struct) GetTypeName

func (s Struct) GetTypeName() string

func (Struct) String

func (s Struct) String() string

func (*Struct) SumFieldBitSize

func (s *Struct) SumFieldBitSize() (fixed_size int64, has_dynamic bool)

type SyntaxError

type SyntaxError struct {
	TopLevelError
	Position
	Err error
}

func (SyntaxError) Error

func (e SyntaxError) Error() string

func (*SyntaxError) String

func (e *SyntaxError) String() string

type TargetNotSpecifiedError added in v0.4.0

type TargetNotSpecifiedError struct{}

func (TargetNotSpecifiedError) Error added in v0.4.0

func (e TargetNotSpecifiedError) Error() string

func (TargetNotSpecifiedError) String added in v0.4.0

func (e TargetNotSpecifiedError) String() string

type TargetNotSupportedError added in v0.4.0

type TargetNotSupportedError struct {
	Target string
}

func (TargetNotSupportedError) Error added in v0.4.0

func (e TargetNotSupportedError) Error() string

func (TargetNotSupportedError) String added in v0.4.0

func (e TargetNotSupportedError) String() string

type TenaryExpr

type TenaryExpr struct {
	BasePosition

	// ExprType is the type of Expr1 or Expr2
	// Expr1 and Expr2 must be the same type
	Cond  Expr
	Expr1 Expr
	Expr2 Expr
}

func (TenaryExpr) GetExprKind

func (t TenaryExpr) GetExprKind() ExprKindID

func (TenaryExpr) GetExprType

func (t TenaryExpr) GetExprType() *BasicType

func (TenaryExpr) String

func (t TenaryExpr) String() string

type TopLevelError

type TopLevelError interface {
	error
	IsTopLevelError()
}

func TopLevelErrorsJoin

func TopLevelErrorsJoin(errs ...TopLevelError) TopLevelError

type TopLevelWarning

type TopLevelWarning interface {
	error
	IsTopLevelWarning()
}

func TopLevelWarningsJoin

func TopLevelWarningsJoin(warnings ...TopLevelWarning) TopLevelWarning

type Type

type Type interface {
	GetTypeID() TypeID
	GetTypeName() string
	GetTypeBitSize() int64
}

type TypeBinopError

type TypeBinopError struct {
	Expr1 string
	Expr2 string
	Type1 string
	Type2 string
}

func (TypeBinopError) Error

func (e TypeBinopError) Error() string

func (TypeBinopError) String

func (e TypeBinopError) String() string

type TypeID

type TypeID int
const (
	TypeID_Bool TypeID = iota
	TypeID_Uint8
	TypeID_Uint16
	TypeID_Uint32
	TypeID_Uint64
	TypeID_Int8
	TypeID_Int16
	TypeID_Int32
	TypeID_Int64
	TypeID_Float32
	TypeID_Float64
	TypeID_String
	TypeID_Bytes
	TypeID_Array
	TypeID_Struct
	TypeID_Enum
)

func (TypeID) IsArray

func (t TypeID) IsArray() bool

func (TypeID) IsBasic

func (t TypeID) IsBasic() bool

func (TypeID) IsBool

func (t TypeID) IsBool() bool

func (TypeID) IsBytes

func (t TypeID) IsBytes() bool

func (TypeID) IsEnum

func (t TypeID) IsEnum() bool

func (TypeID) IsFloat

func (t TypeID) IsFloat() bool

func (TypeID) IsInt

func (t TypeID) IsInt() bool

func (TypeID) IsIntOrUint

func (t TypeID) IsIntOrUint() bool

func (TypeID) IsNumber

func (t TypeID) IsNumber() bool

func (TypeID) IsString

func (t TypeID) IsString() bool

func (TypeID) IsStruct

func (t TypeID) IsStruct() bool

func (TypeID) IsUint

func (t TypeID) IsUint() bool

func (TypeID) String

func (t TypeID) String() string

type TypeNotMatchError

type TypeNotMatchError struct {
	Type1 string
	Type2 string
}

func (TypeNotMatchError) Error

func (e TypeNotMatchError) Error() string

func (TypeNotMatchError) String

func (e TypeNotMatchError) String() string

type TypeUnopError

type TypeUnopError struct {
	Expr string
	Type string
}

func (TypeUnopError) Error

func (e TypeUnopError) Error() string

func (TypeUnopError) String

func (e TypeUnopError) String() string

type UnopExpr

type UnopExpr struct {
	BasePosition

	ExprType *BasicType
	Op       ExprOp
	Expr1    Expr
}

func (UnopExpr) GetExprKind

func (u UnopExpr) GetExprKind() ExprKindID

func (UnopExpr) GetExprType

func (u UnopExpr) GetExprType() *BasicType

func (UnopExpr) String

func (u UnopExpr) String() string

type ValueExpr

type ValueExpr struct {
	BasePosition

	ValueType *BasicType
}

func (ValueExpr) GetExprKind

func (v ValueExpr) GetExprKind() ExprKindID

func (ValueExpr) GetExprType

func (v ValueExpr) GetExprType() *BasicType

func (ValueExpr) String

func (v ValueExpr) String() string

type VoidField

type VoidField struct {
	BasePosition

	FieldBitSize int64
	FieldOptions *util.OrderedMap[string, *Option]
	FieldBelongs *Struct
}

func (VoidField) Copy

func (f VoidField) Copy() Field

func (VoidField) DumpString added in v0.4.0

func (f VoidField) DumpString() string

func (VoidField) GetFieldBelongs

func (f VoidField) GetFieldBelongs() *Struct

func (VoidField) GetFieldBitSize

func (f VoidField) GetFieldBitSize() int64

func (VoidField) GetFieldKind

func (f VoidField) GetFieldKind() FieldKindID

func (VoidField) GetFieldUniqueName

func (f VoidField) GetFieldUniqueName() string

func (*VoidField) SetFieldBelongs

func (f *VoidField) SetFieldBelongs(s *Struct)

func (VoidField) String

func (f VoidField) String() string

Jump to

Keyboard shortcuts

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