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);
		}
Example #2
0
        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));
        }
Example #3
0
        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));
        }
Example #5
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)));
        }
Example #6
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);
        }
Example #7
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;
		}