Files
five/hbrt/symbol.go
Charles KWON OhJun 59568f3301 Five v0.9 — Harbour + Go fusion language
- Compiler: PP → Lexer → Parser → Analyzer → Gengo pipeline
- Parser: 232/236 (98%) Harbour compatibility, registry-based dispatch
- RTL: 351 Harbour-compatible functions
- RDD: DBF/NTX/CDX engines with Rushmore bitmap optimization
- Go Interop: IMPORT + pkg.Func() + obj:Method() with FastPath (15M calls/sec)
- HB_FUNC API: Full Harbour C API compatible Go bridge
- Concurrency: SPAWN/LAUNCH/GOROUTINE, <-, WATCH, PARALLEL FOR, ASYNC/AWAIT
- Extensions: Multi-return, DEFER, Slice, f-string, Nil-safe ?:, CONST
- Macro Compiler: Runtime AST parsing and evaluation
- Debugger: TUI debugger with source display, breakpoints, stepping
- FRB: Native + Pcode dual mode runtime binary
- Tests: 13 packages ALL PASS

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 09:41:50 +09:00

59 lines
1.4 KiB
Go

// Copyright (c) 2026 Charles KWON OhJun (charleskwonohjun@gmail.com)
// All rights reserved.
package hbrt
// Scope flags (matching Harbour's HB_FS_*)
const (
FsPublic uint16 = 0x0001
FsStatic uint16 = 0x0002
FsFirst uint16 = 0x0004
FsInit uint16 = 0x0008
FsExit uint16 = 0x0010
FsMessage uint16 = 0x0020
FsMemvar uint16 = 0x0080
FsPcodeFunc uint16 = 0x0100
FsLocal uint16 = 0x0200
FsDynCode uint16 = 0x0400
FsDeferred uint16 = 0x0800
FsFrame uint16 = 0x1000
)
// Symbol represents a function/variable symbol.
type Symbol struct {
Name string
Scope uint16
Func func(*Thread) // nil for external/deferred
}
// Module is a collection of symbols from one PRG file.
type Module struct {
Name string
Symbols []Symbol
}
// Sym creates a Symbol (convenience constructor for generated code).
func Sym(name string, scope uint16, fn func(*Thread)) Symbol {
return Symbol{Name: name, Scope: scope, Func: fn}
}
// NewModule creates a Module with the given symbols.
func NewModule(name string, symbols ...Symbol) *Module {
return &Module{Name: name, Symbols: symbols}
}
// At returns a pointer to the symbol at index (for generated code).
func (m *Module) At(index int) *Symbol {
return &m.Symbols[index]
}
// Find returns a symbol by name within this module.
func (m *Module) Find(name string) *Symbol {
for i := range m.Symbols {
if m.Symbols[i].Name == name {
return &m.Symbols[i]
}
}
return nil
}