github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/ast/localfunctionstat.go (about) 1 package ast 2 3 // LocalFunctionStat is a statement node that represents a local function 4 // definition, i.e. "local function Name() ...". 5 type LocalFunctionStat struct { 6 Location 7 Function 8 Name Name 9 } 10 11 var _ Stat = LocalFunctionStat{} 12 13 // NewLocalFunctionStat returns a LocalFunctionStat instance for the given name 14 // and function definition. 15 func NewLocalFunctionStat(name Name, fx Function) LocalFunctionStat { 16 fx.Name = name.Val 17 return LocalFunctionStat{ 18 Location: MergeLocations(name, fx), // TODO: use "local" for location start 19 Function: fx, 20 Name: name, 21 } 22 } 23 24 // ProcessStat uses the given StatProcessor to process the receiver. 25 func (s LocalFunctionStat) ProcessStat(p StatProcessor) { 26 p.ProcessLocalFunctionStat(s) 27 } 28 29 // HWrite prints a tree representation of the node. 30 func (s LocalFunctionStat) HWrite(w HWriter) { 31 w.Writef("local function ") 32 s.Name.HWrite(w) 33 s.Function.HWrite(w) 34 }