Example #1
0
        protected IValue CallScriptMethod(int methodIndex, IValue[] parameters)
        {
            IValue returnValue = null;

            _machine.StateConsistentOperation(() =>
            {
                _machine.SetModule(_module);
                _machine.AttachContext(this, true);
                returnValue = _machine.ExecuteMethod(methodIndex, parameters);
            });

            return(returnValue);
        }
Example #2
0
 public override void CallAsProcedure(int methodNumber, IValue[] arguments)
 {
     if (MethodDefinedInScript(methodNumber))
     {
         _machine.StateConsistentOperation(() =>
         {
             _machine.AttachContext(this, true);
             _machine.SetModule(_module);
             _machine.ExecuteMethod(methodNumber - METHOD_COUNT, arguments);
         });
     }
     else
     {
         CallOwnProcedure(methodNumber, arguments);
     }
 }
Example #3
0
 public void Initialize(MachineInstance runner)
 {
     _machine = runner;
     _machine.StateConsistentOperation(() =>
     {
         _machine.SetModule(_module);
         _machine.AttachContext(this, true);
         _machine.ExecuteModuleBody();
     });
 }
Example #4
0
        public void Initialize(MachineInstance runner)
        {
            _machine = runner;
            _machine.StateConsistentOperation(() =>
            {
                _machine.SetModule(_module);
                _machine.AttachContext(this, true);
                _machine.ExecuteModuleBody();
            });

            var methId = GetScriptMethod("ПриСозданииОбъекта", "OnObjectCreate");
            int constructorParamsCount = ConstructorParams.Count();

            if (methId > -1)
            {
                bool hasParamsError = false;
                var  procInfo       = GetMethodInfo(methId);

                int procParamsCount = procInfo.Params.Count();

                if (procParamsCount < constructorParamsCount)
                {
                    hasParamsError = true;
                }

                int reqParams = 0;
                foreach (var itm in procInfo.Params)
                {
                    if (!itm.HasDefaultValue)
                    {
                        reqParams++;
                    }
                }
                if (reqParams > constructorParamsCount)
                {
                    hasParamsError = true;
                }
                if (hasParamsError)
                {
                    throw new RuntimeException("Параметры конструктора: "
                                               + "необходимых параметров: " + Math.Min(procParamsCount, reqParams).ToString()
                                               + ", передано параметров " + constructorParamsCount.ToString()
                                               );
                }

                CallAsProcedure(methId, ConstructorParams);
            }
            else
            {
                if (constructorParamsCount > 0)
                {
                    throw new RuntimeException("Конструктор не определен, но переданы параметры конструктора.");
                }
            }
        }
Example #5
0
 public void Initialize(MachineInstance runner)
 {
     _machine = runner;
     _machine.StateConsistentOperation(() =>
     {
         _machine.SetModule(_module);
         _machine.AttachContext(this, true);
         _machine.ExecuteModuleBody();
     });
 }