public virtual void Visit(FunctionClosure e) { LuaAST f = Transform(e.Function); function.ChildFunction(f); result = new FunctionClosure(e.SourceSpan, f); }
public void Visit(FunctionClosure e) { o.Write("function "); if (e.Function.Name != null) { o.Write(e.Function.Name); } else { o.Write("x"); o.Write(e.Function.GetHashCode().ToString("X")); } }
public void Visit(FunctionClosure e) { // Compile function and reference it. LuaPrototype prototype = BuildPrototype(e.Function); function.InstructionABx(e.SourceSpan, Opcode.Closure, target, function.Prototype(prototype)); // Initialize upvals. for (int upval = 0; upval < e.Function.UpVals.Count; ++upval) { Variable variable = e.Function.UpVals[upval]; if (function.Function.UpVals.Contains(variable)) { function.InstructionABC(e.SourceSpan, Opcode.GetUpVal, upval, function.UpVal(variable), 0); } else { function.InstructionABC(e.SourceSpan, Opcode.Move, upval, function.Local(variable), 0); } } }