- 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>
66 lines
1.5 KiB
Plaintext
66 lines
1.5 KiB
Plaintext
// Five OOP test — Harbour-compatible CLASS syntax
|
|
// In Harbour, this would require: #include "hbclass.ch"
|
|
// In Five, CLASS is native syntax (no preprocessor needed)
|
|
|
|
CLASS Person
|
|
DATA cName INIT ""
|
|
DATA nAge INIT 0
|
|
METHOD New(cName, nAge)
|
|
METHOD Greet()
|
|
METHOD GetInfo()
|
|
ENDCLASS
|
|
|
|
METHOD New(cName, nAge) CLASS Person
|
|
::cName := cName
|
|
::nAge := nAge
|
|
RETURN Self
|
|
|
|
METHOD Greet() CLASS Person
|
|
? "Hello, I'm " + ::cName + "!"
|
|
RETURN Self
|
|
|
|
METHOD GetInfo() CLASS Person
|
|
RETURN ::cName + " (age: " + Str(::nAge) + ")"
|
|
|
|
// Inheritance test
|
|
CLASS Employee INHERIT FROM Person
|
|
DATA cCompany INIT ""
|
|
DATA nSalary INIT 0
|
|
METHOD New(cName, nAge, cCompany, nSalary)
|
|
METHOD GetInfo()
|
|
ENDCLASS
|
|
|
|
METHOD New(cName, nAge, cCompany, nSalary) CLASS Employee
|
|
::cName := cName
|
|
::nAge := nAge
|
|
::cCompany := cCompany
|
|
::nSalary := nSalary
|
|
RETURN Self
|
|
|
|
METHOD GetInfo() CLASS Employee
|
|
RETURN ::cName + " @ " + ::cCompany + " ($" + Str(::nSalary) + ")"
|
|
|
|
FUNCTION Main()
|
|
LOCAL oPerson, oEmployee
|
|
|
|
? "=== Five OOP Test ==="
|
|
? ""
|
|
|
|
// Create Person
|
|
oPerson := Person():New("Kim", 30)
|
|
oPerson:Greet()
|
|
? "Info:", oPerson:GetInfo()
|
|
? "Name:", oPerson:cName
|
|
? "Age:", oPerson:nAge
|
|
? ""
|
|
|
|
// Create Employee (inherits Person)
|
|
oEmployee := Employee():New("Lee", 25, "FiveSoft", 50000)
|
|
oEmployee:Greet()
|
|
? "Info:", oEmployee:GetInfo()
|
|
? "Company:", oEmployee:cCompany
|
|
? ""
|
|
|
|
? "OOP test passed!"
|
|
RETURN NIL
|