ErrorHandling.cs 658 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using MoonSharp.Interpreter.Execution;
  6. using MoonSharp.Interpreter.Execution.VM;
  7. namespace MoonSharp.Interpreter.CoreLib
  8. {
  9. [MoonSharpModule]
  10. public class ErrorHandling
  11. {
  12. [MoonSharpMethod]
  13. public static DynValue pcall(ScriptExecutionContext executionContext, CallbackArguments args)
  14. {
  15. DynValue v = args[0];
  16. DynValue[] a = new DynValue[args.Count - 1];
  17. for (int i = 1; i < args.Count; i++)
  18. a[i - 1] = args[i];
  19. return DynValue.NewTailCallReq(new TailCallData()
  20. {
  21. Args = a,
  22. Function = v,
  23. Mode = CallMode.PCall
  24. });
  25. }
  26. }
  27. }