Documentation
¶
Index ¶
- Variables
- func ExecuteFastHTTPResponse(ctx context.Context, node *Node, scope *Scope) error
- func FastHTTPResponse(ctx context.Context, w http.ResponseWriter, status int, body interface{}) error
- func FastVarSet(scope *Scope, name string, value interface{})
- func GetBuffer() []byte
- func GetMap() map[string]interface{}
- func PutArena(a *Arena)
- func PutBuffer(b []byte)
- func PutMap(m map[string]interface{})
- func PutScope(s *Scope)
- func TryFastPath(ctx context.Context, node *Node, scope *Scope) (bool, error)
- type Arena
- func (a *Arena) Alloc(n int) unsafe.Pointer
- func (a *Arena) AllocBuffer(capacity int) []byte
- func (a *Arena) AllocMap(capacity int) map[string]interface{}
- func (a *Arena) AllocScope(parent *Scope) *Scope
- func (a *Arena) CreateValuePointer(v interface{}) unsafe.Pointer
- func (a *Arena) Reset()
- func (a *Arena) Stats() (used int, total int)
- type CachedScript
- type Diagnostic
- type Engine
- func (e *Engine) Execute(ctx context.Context, node *Node, scope *Scope) (err error)
- func (e *Engine) GetDocumentation() map[string]SlotMeta
- func (e *Engine) GetSortedSlotNames() []string
- func (e *Engine) Register(name string, fn HandlerFunc, meta SlotMeta)
- func (e *Engine) ResolveShorthandValue(n *Node, scope *Scope) interface{}
- func (e *Engine) ValidateValueType(val interface{}, expectedType string, node *Node, slotName string) error
- type HandlerFunc
- type InputMeta
- type Lexer
- type Node
- type Scope
- func (s *Scope) Clone() *Scope
- func (s *Scope) Delete(key string)
- func (s *Scope) Get(key string) (interface{}, bool)
- func (s *Scope) GetAll() map[string]interface{}
- func (s *Scope) GetDefault(key string, defaultValue interface{}) interface{}
- func (s *Scope) Reset()
- func (s *Scope) Set(key string, val interface{})
- func (s *Scope) SetParent(parent *Scope)
- func (s *Scope) ToMap() map[string]interface{}
- type ScriptCache
- type SlotMeta
- type Token
- type TokenType
Constants ¶
This section is empty.
Variables ¶
var GlobalCache = &ScriptCache{files: make(map[string]*CachedScript)}
Functions ¶
func ExecuteFastHTTPResponse ¶
ExecuteFastHTTPResponse executes http.response using fast path
func FastHTTPResponse ¶
func FastHTTPResponse(ctx context.Context, w http.ResponseWriter, status int, body interface{}) error
FastHTTPResponse provides optimized path for simple JSON responses Bypasses full node traversal and validation for common case Expected: 2-3x faster than generic http.response handler
func FastVarSet ¶
FastVarSet provides optimized path for simple variable assignment Bypasses node execution overhead
func GetBuffer ¶
func GetBuffer() []byte
GetBuffer retrieves a byte buffer from the pool. Always call PutBuffer when done.
func GetMap ¶
func GetMap() map[string]interface{}
GetMap retrieves a map from the pool. Always call PutMap when done.
func PutBuffer ¶
func PutBuffer(b []byte)
PutBuffer returns a byte buffer to the pool. The buffer's length is reset to 0 but capacity is preserved.
func PutMap ¶
func PutMap(m map[string]interface{})
PutMap returns a map to the pool after clearing its data.
Types ¶
type Arena ¶
type Arena struct {
// contains filtered or unexported fields
}
Arena provides high-performance linear memory allocation for request-scoped objects. It bypasses the Go GC for objects allocated within it by using a pre-allocated chunk.
func (*Arena) AllocBuffer ¶
AllocBuffer allocates a byte buffer in the arena.
func (*Arena) AllocMap ¶
AllocMap allocates a new map in the arena (wrapped as a standard map for compatibility). Warning: standard maps still have GC overhead. This is a bridge implementation.
func (*Arena) AllocScope ¶
AllocScope allocates a new Scope in the arena.
func (*Arena) CreateValuePointer ¶
CreateValuePointer creates a pointer to a value in the arena.
type CachedScript ¶
type Diagnostic ¶
type Diagnostic struct {
Type string `json:"type"` // "error", "warning"
Message string `json:"message"`
Filename string `json:"filename"`
Line int `json:"line"`
Col int `json:"col"`
Slot string `json:"slot,omitempty"`
}
func (Diagnostic) Error ¶
func (d Diagnostic) Error() string
type Engine ¶
type Engine struct {
Registry map[string]HandlerFunc
Docs map[string]SlotMeta // <--- Database Dokumentasi
}
func (*Engine) Execute ¶
Execute executes a node with comprehensive panic recovery to ensure runtime immortality. Any panic from user scripts will be caught, logged, and converted to an error.
func (*Engine) GetDocumentation ¶
Helper untuk mengambil semua docs (Sorted by Name)
func (*Engine) GetSortedSlotNames ¶
Helper untuk mendapatkan list nama slot yang terurut
func (*Engine) Register ¶
func (e *Engine) Register(name string, fn HandlerFunc, meta SlotMeta)
Update Register agar menerima Metadata
func (*Engine) ResolveShorthandValue ¶
ResolveShorthandValue Helper internal untuk memproses nilai pada Variable Shorthand (Exported for analysis)
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
func (*Lexer) GetLineInfo ¶
type Node ¶
type Node struct {
Name string
Value interface{}
Children []*Node
Parent *Node
Line int
Col int
Filename string
// contains filtered or unexported fields
}
func LoadScript ¶
LoadScript membaca dan memparsing file script, atau mengambil dari cache jika belum berubah
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
func GetScope ¶
func GetScope() *Scope
GetScope retrieves a Scope from the pool. The returned Scope is ready to use but may contain data from previous use. Always call PutScope when done to return it to the pool.
func (*Scope) Clone ¶
[BARU] Clone membuat salinan scope baru (Deep Copy Level 1) Ini yang dicari oleh router.go
func (*Scope) GetAll ¶
GetAll mengembalikan semua variabel di scope ini dan scope parent secara rekursif
func (*Scope) GetDefault ¶
ToMap mengonversi scope menjadi map standar (berguna untuk template rendering) GetDefault returns the value of the key if found, otherwise returns the default value.
func (*Scope) Reset ¶
func (s *Scope) Reset()
Reset clears all variables from the scope. This is used by the object pool to safely reuse Scope instances without data leakage between requests.
type ScriptCache ¶
type ScriptCache struct {
// contains filtered or unexported fields
}
func (*ScriptCache) ClearHandlerCache ¶
func (c *ScriptCache) ClearHandlerCache()
ClearHandlerCache membersihkan semua cached handler dan metadata dari Node AST Fungsi ini harus dipanggil sebelum hot reload untuk mencegah panic akibat stale handlers
type SlotMeta ¶
type SlotMeta struct {
Description string `json:"description"`
Example string `json:"example"` // Snippet kode .zl
Inputs map[string]InputMeta `json:"inputs,omitempty"`
RequiredBlocks []string `json:"required_blocks,omitempty"` // e.g. ["do"], ["then", "else"]
ValueType string `json:"value_type,omitempty"` // [BARU] Tipe data untuk value utama slot
}
Struct untuk menyimpan Dokumentasi Slot