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