Processor_IExecutionContext.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace MoonSharp.Interpreter.Execution.VM
  6. {
  7. sealed partial class Processor : IExecutionContext
  8. {
  9. DynValue IExecutionContext.GetVar(SymbolRef symref)
  10. {
  11. return this.GetGenericSymbol(symref);
  12. }
  13. void IExecutionContext.SetVar(SymbolRef symref, DynValue value)
  14. {
  15. AssignGenericSymbol(symref, value);
  16. }
  17. SymbolRef IExecutionContext.FindVar(string name)
  18. {
  19. return FindRefByName(name);
  20. }
  21. DynValue IExecutionContext.GetMetamethod(DynValue value, string metamethod)
  22. {
  23. if (value.Meta == null || value.Type == DataType.Nil)
  24. return null;
  25. if (value.Meta.Type != DataType.Table)
  26. throw new InternalErrorException("Metatable is not a table!");
  27. var metameth = value.Meta.Table.RawGet(metamethod);
  28. if (metameth == null || metameth.Type == DataType.Nil)
  29. return null;
  30. return metameth;
  31. }
  32. DynValue IExecutionContext.GetMetamethodTailCall(DynValue value, string metamethod, params DynValue[] args)
  33. {
  34. DynValue meta = ((IExecutionContext)this).GetMetamethod(value, metamethod);
  35. if (meta == null) return null;
  36. return DynValue.NewTailCallReq(meta, args);
  37. }
  38. Script IExecutionContext.GetOwnerScript()
  39. {
  40. return m_Script;
  41. }
  42. }
  43. }