示例#1
0
        private async Task ReturnToPreviousScript()
        {
            // 切换历史作用域
            ActiveScope = _historyScope.Pop();
            // 重定向执行位置
            _callStack.Pop();
            var pointer = _callStack.Last;

            Script = ScriptFile.LoadSync(pointer.ScriptId);
            Script.MoveTo(pointer.Offset);
            await Script.UseTranslation(ActiveLanguage);

            // 跳过刚刚执行完的跳转指令
            Script.ReadOperationCode();
        }
 protected ScriptRuntime(SerializationInfo info, StreamingContext context)
 {
     MemoryStack   = (Stack <SerializableValue>)info.GetValue("memory", typeof(Stack <SerializableValue>));
     Exported      = (Dictionary <string, SerializableValue>)info.GetValue("exported", typeof(Dictionary <string, SerializableValue>));
     _callStack    = (CallStack)info.GetValue("callstack", typeof(CallStack));
     _historyScope = (Stack <ScopeValue>)info.GetValue("history", typeof(Stack <ScopeValue>));
     LoadingTarget = (ScriptRuntime)info.GetValue("loading", typeof(ScriptRuntime));
     ActiveScope   = (ScopeValue)info.GetValue("scope", typeof(ScopeValue));
     if (ActiveScope != null)
     {
         Script = ScriptFile.LoadSync(ActiveScope.scriptId);
         Script.MoveTo(info.GetInt64("offset"));
         Script.UseTranslation(ActiveLanguage).Wait();
     }
     ActiveLanguage = info.GetString("language");
 }