public static DynValue pairs(ScriptExecutionContext executionContext, CallbackArguments args) { DynValue table = args[0]; DynValue meta = executionContext.GetMetamethodTailCall(table, "__pairs", args.GetArray()); return meta ?? DynValue.NewTuple(DynValue.NewCallback(next), table); }
static DynValue pairs(ScriptExecutionContext executionContext, CallbackArguments args) { DynValue table = args[0]; DynValue meta = executionContext.GetMetamethodTailCall(table, "__pairs", args.GetArray()); return(meta ?? DynValue.NewTuple(DynValue.NewCallback(next), table)); }
public static DynValue ipairs(ScriptExecutionContext executionContext, CallbackArguments args) { DynValue table = args[0]; DynValue meta = executionContext.GetMetamethodTailCall(table, "__ipairs", args.GetArray()); return(meta.IsNotNil() ? meta : DynValue.NewTuple(DynValue.NewCallback(__next_i), table, DynValue.NewNumber(0))); }
public static DynValue ipairs(ScriptExecutionContext executionContext, CallbackArguments args) { var table = args[0]; var meta = executionContext.GetMetamethodTailCall(table, "__ipairs", args.GetArray()); return meta ?? DynValue.NewTuple(DynValue.NewCallback(__next_i), table, DynValue.NewNumber(0)); }
public static DynValue ipairs(ScriptExecutionContext executionContext, CallbackArguments args) { DynValue table = args[0]; if (table == null || table.Type == DataType.Nil) { throw new System.ApplicationException("attempt to index nil"); } DynValue meta = executionContext.GetMetamethodTailCall(table, "__ipairs", args.GetArray()); return(meta ?? DynValue.NewTuple(DynValue.NewCallback(__next_i), table, DynValue.NewNumber(0))); }
public static DynValue tostring(ScriptExecutionContext executionContext, CallbackArguments args) { if (args.Count < 1) { throw ScriptRuntimeException.BadArgumentValueExpected(0, "tostring"); } DynValue v = args[0]; DynValue tail = executionContext.GetMetamethodTailCall(v, "__tostring", v); if (tail == null || tail.IsNil()) { return(DynValue.NewString(v.ToPrintString())); } tail.TailCallData.Continuation = new CallbackFunction(__tostring_continuation, "__tostring"); return(tail); }
public static DynValue tostring(ScriptExecutionContext executionContext, CallbackArguments args) { if (args.Count < 1) throw ScriptRuntimeException.BadArgumentValueExpected(0, "tostring"); DynValue v = args[0]; DynValue tail = executionContext.GetMetamethodTailCall(v, "__tostring", v); if (tail == null || tail.IsNil()) return DynValue.NewString(v.ToPrintString()); tail.TailCallData.Continuation = new CallbackFunction(__tostring_continuation, "__tostring"); return tail; }