Example #1
0
        private bool SysFuncCall(object func, VAL proc, VAL instance, bool arg0)
        {
            if (proc.ty == VALTYPE.funccon)
            {
                UserFuncCall(proc, instance, arg0);
                return(true);
            }

            VALL L = SysFuncBeginParameter();

            if (arg0 && proc.temp is HostOffset)
            {
                object host = ((HostOffset)proc.temp).host;
                if (host != instance.value)
                {
                    L.Insert(instance);       //extend method
                    arg0 = false;
                }
            }
            VAL ret = HostOperation.HostTypeFunction(proc, L);

            if (ret.Defined)
            {
                return(SysFuncEnd(ret));
            }



            if (arg0)
            {
                L.Insert(instance);
            }
            try
            {
                ret = context.InvokeFunction((string)func, new VAL(L), position);
            }
            catch (FunctionNotFoundException e1)
            {
                throw e1;
            }
            catch (Exception e2)
            {
                if (e2 is RuntimeException)
                {
                    throw e2;
                }
                else
                {
                    throw new RuntimeException(position, "Error: function {0}({1}) implementation, {2}", func, L.ToString2(), e2.Message);
                }
            }

            return(SysFuncEnd(ret));
        }
Example #2
0
        private void paramsArray(int argc1, int argc2)
        {
            int diff = argc1 - argc2;

            VAL retAddr = SS.Pop();

            VALL L1 = new VALL();

            for (int i = 0; i < argc2 - 1; i++)
            {
                L1.Insert(SS.Pop());
            }

            VALL L2 = new VALL();

            for (int i = 0; i <= diff; i++)
            {
                L2.Add(SS.Pop());
            }
            SS.Push(new VAL(L2));

            for (int i = 0; i < argc2 - 1; i++)
            {
                SS.Push(L1[i]);
            }

            SS.Push(retAddr);

            CS[retAddr.Intcon].operand.Addr += diff;
        }
Example #3
0
        private void UserFuncCall(VAL func, VAL instance, bool arg0)
        {
            int count1 = -CS[IP + 1].operand.Addr - 1;

            if (moduleName == func.Class)
            {
                if (arg0)
                {
                    VAL ip = SS.Pop();
                    SS.Push(instance);
                    SS.Push(ip);
                    count1++;
                }

                IP = (int)func.value;
                paramsCheck(IP, count1);
            }
            else
            {
                VALL L = SysFuncBeginParameter();
                if (arg0)
                {
                    L.Insert(instance);
                }
                VAL ret = InternalUserFuncCall(func, instance, new VAL(L));

                SysFuncEnd(ret);
            }
        }