Documentation
¶
Index ¶
- type AliasDecl
- type ArrayType
- type AssignStmt
- type Attribute
- type BinaryExpr
- type BindingArrayType
- type BitcastExpr
- type BlockStmt
- type BreakIfStmt
- type BreakStmt
- type CallExpr
- type ConstAssertDecl
- type ConstDecl
- type ConstructExpr
- type ContinueStmt
- type Decl
- type Diagnostic
- type DiscardStmt
- type Enable
- type Expr
- type ExprStmt
- type ForStmt
- type FunctionDecl
- type Ident
- type IfStmt
- type IndexExpr
- type Lexer
- type Literal
- type LoopStmt
- type MemberExpr
- type Module
- type NamedType
- type Node
- type OverrideDecl
- type Parameter
- type ParseError
- type Parser
- type Position
- type PtrType
- type ReturnStmt
- type SourceError
- type SourceErrors
- type Span
- type Stmt
- type StructDecl
- type StructMember
- type SwitchCaseClause
- type SwitchStmt
- type Token
- type TokenKind
- type Type
- type UnaryExpr
- type VarDecl
- type WhileStmt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssignStmt ¶
AssignStmt represents an assignment statement.
func (*AssignStmt) Pos ¶
func (a *AssignStmt) Pos() Span
type BinaryExpr ¶
BinaryExpr represents a binary expression.
func (*BinaryExpr) Pos ¶
func (b *BinaryExpr) Pos() Span
type BindingArrayType ¶
BindingArrayType represents a binding array type (binding_array<T, N>).
func (*BindingArrayType) Pos ¶
func (b *BindingArrayType) Pos() Span
type BitcastExpr ¶
BitcastExpr represents a bitcast expression: bitcast<TargetType>(expr).
func (*BitcastExpr) Pos ¶
func (b *BitcastExpr) Pos() Span
type BreakIfStmt ¶
BreakIfStmt represents a "break if" statement inside a continuing block. WGSL spec: continuing { ... break if condition; }
func (*BreakIfStmt) Pos ¶
func (b *BreakIfStmt) Pos() Span
type ConstAssertDecl ¶
ConstAssertDecl represents a const_assert declaration (module or function scope). WGSL spec: const_assert expr; — compile-time assertion.
func (*ConstAssertDecl) Pos ¶
func (c *ConstAssertDecl) Pos() Span
type ConstDecl ¶
type ConstDecl struct {
Name string
Type Type
Init Expr
Span Span
IsConst bool // true for `const`, false for `let`
}
ConstDecl represents a const declaration.
type ConstructExpr ¶
ConstructExpr represents a type constructor expression.
func (*ConstructExpr) Pos ¶
func (c *ConstructExpr) Pos() Span
type ContinueStmt ¶
type ContinueStmt struct {
Span Span
}
ContinueStmt represents a continue statement.
func (*ContinueStmt) Pos ¶
func (c *ContinueStmt) Pos() Span
type Decl ¶
type Decl interface {
Node
// contains filtered or unexported methods
}
Decl is the interface for declarations.
func DependencyOrder ¶
DependencyOrder returns declarations sorted in dependency order using DFS-based topological sort. This matches Rust naga's visit_ordered() from front/wgsl/index.rs — declarations are ordered so that every declaration appears after all declarations it references.
When there are no dependencies between declarations, they appear in source order (the outer DFS loop iterates in original order).
type Diagnostic ¶
Diagnostic represents a diagnostic directive.
type DiscardStmt ¶
type DiscardStmt struct {
Span Span
}
DiscardStmt represents a discard statement.
func (*DiscardStmt) Pos ¶
func (d *DiscardStmt) Pos() Span
type Expr ¶
type Expr interface {
Node
// contains filtered or unexported methods
}
Expr is the interface for expressions.
type FunctionDecl ¶
type FunctionDecl struct {
Name string
Params []*Parameter
ReturnType Type
ReturnAttrs []Attribute // Attributes on return type (e.g., @builtin(position), @location(0))
Attributes []Attribute
Body *BlockStmt
Span Span
}
FunctionDecl represents a function declaration.
func (*FunctionDecl) Pos ¶
func (f *FunctionDecl) Pos() Span
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer tokenizes WGSL source code.
type Literal ¶
type Literal struct {
Kind TokenKind // IntLiteral, FloatLiteral, BoolLiteral
Value string
Span Span
}
Literal represents a literal value.
type MemberExpr ¶
MemberExpr represents a member access expression.
func (*MemberExpr) Pos ¶
func (m *MemberExpr) Pos() Span
type Module ¶
type Module struct {
Enables []Enable
Diagnostics []Diagnostic
Structs []*StructDecl
Functions []*FunctionDecl
GlobalVars []*VarDecl
Aliases []*AliasDecl
Constants []*ConstDecl
Overrides []*OverrideDecl
// Declarations preserves all top-level declarations in source order.
// This is used by the lowerer to register types in the same order as
// Rust naga, which processes declarations via topological sort that
// closely follows source order.
Declarations []Decl
}
Module represents a WGSL module (translation unit).
type OverrideDecl ¶
type OverrideDecl struct {
Name string
Type Type
Init Expr // May be nil (override without default value)
Attributes []Attribute
Span Span
}
OverrideDecl represents an override declaration (pipeline-overridable constant). WGSL spec: @id(N) override name: type = default;
func (*OverrideDecl) Pos ¶
func (o *OverrideDecl) Pos() Span
type ParseError ¶
ParseError represents a parsing error.
func (ParseError) Error ¶
func (e ParseError) Error() string
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser parses WGSL tokens into an AST.
type ReturnStmt ¶
ReturnStmt represents a return statement.
func (*ReturnStmt) Pos ¶
func (r *ReturnStmt) Pos() Span
type SourceError ¶
type SourceError struct {
Message string
Span Span
Source string // Original source code (for context display)
}
SourceError represents an error with source location information.
func NewSourceError ¶
func NewSourceError(message string, span Span, source string) *SourceError
NewSourceError creates a new SourceError.
func NewSourceErrorf ¶
func NewSourceErrorf(span Span, source string, format string, args ...interface{}) *SourceError
NewSourceErrorf creates a new SourceError with formatted message.
func (*SourceError) Error ¶
func (e *SourceError) Error() string
Error implements the error interface.
func (*SourceError) FormatWithContext ¶
func (e *SourceError) FormatWithContext() string
FormatWithContext returns the error message with source context. Shows the problematic line with a caret pointing to the error location.
type SourceErrors ¶
type SourceErrors []*SourceError
SourceErrors represents a list of source errors.
func (*SourceErrors) Add ¶
func (el *SourceErrors) Add(err *SourceError)
Add adds an error to the list.
func (*SourceErrors) AddError ¶
func (el *SourceErrors) AddError(message string, span Span, source string)
AddError adds an error with the given message and span.
func (SourceErrors) Error ¶
func (el SourceErrors) Error() string
func (SourceErrors) FormatAll ¶
func (el SourceErrors) FormatAll() string
FormatAll returns all errors formatted with context.
func (SourceErrors) HasErrors ¶
func (el SourceErrors) HasErrors() bool
HasErrors returns true if there are any errors.
type Stmt ¶
type Stmt interface {
Node
// contains filtered or unexported methods
}
Stmt is the interface for statements.
type StructDecl ¶
type StructDecl struct {
Name string
Members []*StructMember
Span Span
}
StructDecl represents a struct declaration.
func (*StructDecl) Pos ¶
func (s *StructDecl) Pos() Span
type StructMember ¶
StructMember represents a struct member.
type SwitchCaseClause ¶
type SwitchCaseClause struct {
Selectors []Expr // Case selectors (nil or empty for default)
IsDefault bool // True for default case
DefaultFirst bool // True when default appears before selectors (case default, 6:)
Body *BlockStmt // Case body
Span Span
}
SwitchCaseClause represents a case clause in a switch statement.
type SwitchStmt ¶
type SwitchStmt struct {
Selector Expr
Cases []*SwitchCaseClause
Span Span
}
SwitchStmt represents a switch statement.
func (*SwitchStmt) Pos ¶
func (s *SwitchStmt) Pos() Span
type TokenKind ¶
type TokenKind uint8
TokenKind represents the type of token.
const ( TokenEOF TokenKind = iota TokenError // Literals TokenIdent TokenIntLiteral TokenFloatLiteral TokenBoolLiteral // Operators TokenPlus // + TokenMinus // - TokenStar // * TokenSlash // / TokenPercent // % TokenAmpersand // & TokenPipe // | TokenCaret // ^ TokenTilde // ~ TokenBang // ! TokenEqual // = TokenLess // < TokenGreater // > TokenDot // . TokenComma // , TokenColon // : TokenSemicolon // ; TokenAt // @ TokenArrow // -> TokenPlusPlus // ++ TokenMinusMinus // -- TokenEqualEqual // == TokenBangEqual // != TokenLessEqual // <= TokenGreaterEqual // >= TokenAmpAmp // && TokenPipePipe // || TokenLessLess // << TokenGreaterGreater // >> TokenPlusEqual // += TokenMinusEqual // -= TokenStarEqual // *= TokenSlashEqual // /= TokenPercentEqual // %= TokenAmpEqual // &= TokenPipeEqual // |= TokenCaretEqual // ^= TokenLessLessEqual // <<= TokenGreaterGreaterEqual // >>= // Delimiters TokenLeftParen // ( TokenRightParen // ) TokenLeftBrace // { TokenRightBrace // } TokenLeftBracket // [ TokenRightBracket // ] // Keywords TokenAlias TokenBreak TokenCase TokenConst TokenConstAssert TokenContinue TokenContinuing TokenDefault TokenDiagnostic TokenDiscard TokenElse TokenEnable TokenFalse TokenFn TokenFor TokenIf TokenLet TokenLoop TokenOverride TokenReturn TokenStruct TokenSwitch TokenTrue TokenVar TokenWhile // Reserved keywords TokenNull TokenSelf TokenSuper TokenTrait TokenType TokenUsing // Type keywords TokenBool TokenF16 TokenF32 TokenF64 TokenI32 TokenI64 TokenU32 TokenU64 TokenVec2 TokenVec3 TokenVec4 TokenMat2x2 TokenMat2x3 TokenMat2x4 TokenMat3x2 TokenMat3x3 TokenMat3x4 TokenMat4x2 TokenMat4x3 TokenMat4x4 TokenArray TokenAtomic TokenPtr TokenSampler TokenSamplerComparison TokenTexture1d TokenTexture2d TokenTexture2dArray TokenTexture3d TokenTextureCube TokenTextureCubeArray TokenTextureMultisampled2d TokenTextureStorage1d TokenTextureStorage2d TokenTextureStorage2dArray TokenTextureStorage3d TokenTextureDepth2d TokenTextureDepth2dArray TokenTextureDepthCube TokenTextureDepthCubeArray TokenTextureDepthMultisampled2d )
type Type ¶
type Type interface {
Node
// contains filtered or unexported methods
}
Type represents a type.