private void exec_usrcall(NakoILCode code)
 {
     NakoCallStack c = new NakoCallStack();
     c.localVar = localVar;
     c.nextpos = runpos + 1;
     c.sore = globalVar.GetValue(0);
     this.localVar = new NakoVariableManager(NakoVariableScope.Local);
     callStack.Push(c);
     // JUMP
     autoIncPos = false;
     runpos = Convert.ToInt32((long)code.value);
 }
 /// <summary>
 /// 環境のリセット
 /// </summary>
 public void Reset()
 {
     // インタプリタ識別番号の設定
     _interpreter_id = _interpreter_id_count;
     _interpreter_id_count++;
     // スタックや変数などを生成
     calcStack = new Stack<object>();
     globalVar = new NakoVariableManager(NakoVariableScope.Global);
     localVar = new NakoVariableManager(NakoVariableScope.Local);
     callStack = new Stack<NakoCallStack>();
     PrintLog = "";
     InitPlugins();
 }
 private void exec_ret(NakoILCode code)
 {
     autoIncPos = false;
     NakoCallStack c = callStack.Pop();
     this.runpos = c.nextpos;
     if (((bool)code.value) == false)
         globalVar.SetValue(0, c.sore);// "それ"を関数実行前に戻す
     this.localVar = c.localVar;
 }
        /// <summary>
        /// システムに登録する
        /// </summary>
        /// <param name="dic"></param>
        /// <param name="globalVar"></param>
        public void RegisterToSystem(NakoTokenDic dic, NakoVariableManager globalVar)
        {
            // --- 関数
            // Tokenizer に登録
            for (int i = 0; i < FuncList.Count; i++)
            {
                NakoAPIFunc call = FuncList[i];
                if (!dic.ContainsKey(call.name))
                {
                    dic.Add(call.name, NakoTokenType.FUNCTION_NAME);
                }
                else
                {
                    dic[call.name] = NakoTokenType.FUNCTION_NAME;
                }
            }

            // NakoVariables に登録
            for (int i = 0; i < FuncList.Count; i++)
            {
                NakoVariable var = new NakoVariable();
                var.SetBody(i, NakoVarType.SystemFunc);
                NakoAPIFunc call = FuncList[i];
                globalVar.SetVar(call.name, var);
            }

            // --- 変数
            foreach (string name in VarList.Keys)
            {
                NakoVariable var = new NakoVariable();
                var.SetBodyAutoType(VarList[name]);
                globalVar.SetVar(name, var);
            }
        }