예제 #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);
        }
예제 #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);
     }
 }
예제 #3
0
 public void UpdateContexts()
 {
     _machine.Cleanup();
     foreach (var item in Environment.AttachedContexts)
     {
         _machine.AttachContext(item, false);
     }
 }
예제 #4
0
 public void LoadMemory(MachineInstance machine)
 {
     machine.Cleanup();
     foreach (var item in AttachedContexts)
     {
         machine.AttachContext(item);
     }
     machine.ContextsAttached();
 }
예제 #5
0
 public void Initialize(MachineInstance runner)
 {
     _machine = runner;
     _machine.StateConsistentOperation(() =>
     {
         _machine.SetModule(_module);
         _machine.AttachContext(this, true);
         _machine.ExecuteModuleBody();
     });
 }
예제 #6
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("Конструктор не определен, но переданы параметры конструктора.");
                }
            }
        }
예제 #7
0
        public void Initialize(RuntimeEnvironment environment)
        {
            _symbolsContext = environment.SymbolsContext;

            foreach (var item in environment.AttachedContexts)
            {
                _machine.AttachContext(item, false);
            }

            _attachedScriptsFactory = new AttachedScriptsFactory(this);
            AttachedScriptsFactory.SetInstance(_attachedScriptsFactory);
        }
예제 #8
0
        public void Initialize()
        {
            SetDefaultEnvironmentIfNeeded();

            var symbolsContext = Environment.SymbolsContext;

            _machine.Cleanup();
            foreach (var item in Environment.AttachedContexts)
            {
                _machine.AttachContext(item, false);
            }

            _attachedScriptsFactory = new AttachedScriptsFactory(this);
            AttachedScriptsFactory.SetInstance(_attachedScriptsFactory);
        }
예제 #9
0
        public void AttachExternalAssembly(System.Reflection.Assembly asm, RuntimeEnvironment globalEnvironment)
        {
            ContextDiscoverer.DiscoverClasses(asm);

            var lastCount = globalEnvironment.AttachedContexts.Count();

            ContextDiscoverer.DiscoverGlobalContexts(globalEnvironment, asm);

            var newCount = globalEnvironment.AttachedContexts.Count();

            while (lastCount < newCount)
            {
                _machine.AttachContext(globalEnvironment.AttachedContexts[lastCount]);
                ++lastCount;
            }
        }
예제 #10
0
 public void Initialize(MachineInstance runner)
 {
     _machine = runner;
     _machine.StateConsistentOperation(() =>
     {
         _machine.SetModule(_module);
         _machine.AttachContext(this, true);
         _machine.ExecuteModuleBody();
     });
 }