private object _append(INakoFuncCallInfo info) { object ary = info.StackPop(); // 参照渡しなので変数への参照が得られる object s = info.StackPop(); if (!(ary is NakoVariable)) { throw new NakoPluginRuntimeException("『追加』の引数がvariableではありません"); } NakoVariable ary_link = (NakoVariable)ary; if (ary_link.Body is NakoVarArray) { NakoVarArray arr = (NakoVarArray)ary_link.Body; NakoVariable new_item = new NakoVariable(); new_item.SetBodyAutoType(s); arr.Add(new_item); } else if (ary_link.Body is string && (string)ary_link.Body == "") { NakoVarArray arr = new NakoVarArray(); NakoVariable new_item = new NakoVariable(); new_item.SetBodyAutoType(s); arr.Add(new_item); ary_link.SetBody(arr, NakoVarType.Array); } // 結果をセット return(null); }
/// <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); } }
private object _getFunctionFurigana(INakoFuncCallInfo info) { string funcName = info.StackPopAsString(); NakoVariable v = new NakoVariable(); NakoAPIFunc f = NakoAPIFuncBank.Instance.FuncList.Find((obj) => (obj.name == funcName)); v.SetBodyAutoType(f.kana); return(v); }
private object _getPlugins(INakoFuncCallInfo info) { NakoVarArray a = info.CreateArray(); foreach (KeyValuePair <string, INakoPlugin> pair in NakoAPIFuncBank.Instance.PluginList) { NakoVariable v = new NakoVariable(); v.SetBodyAutoType(pair.Key); a.Add(v); } return(a); }
private object _getFunctionNames(INakoFuncCallInfo info) { NakoVarArray a = info.CreateArray(); foreach (NakoAPIFunc f in NakoAPIFuncBank.Instance.FuncList) { NakoVariable v = new NakoVariable(); v.SetBodyAutoType(f.name); a.Add(v); } return(a); }
private void st_elem() { object value = StackPop(); object index = StackPop(); object var = StackPop(); if (var is NakoVariable) { NakoVariable var2 = (NakoVariable)var; // null か空の文字列なら NakoArray として生成 if (var2.Body == null || (var2.Type == NakoVarType.String && (string)var2.Body == "")) { var2.SetBody(new NakoVarArray(), NakoVarType.Array); } if (!(var2.Body is NakoVarArray)) { string s = ""; if (var2.Body != null) { s = var2.Body.ToString(); } var2.SetBody(new NakoVarArray(), NakoVarType.Array); ((NakoVarArray)var2.Body).SetValuesFromString(s); } // NakoArray なら 要素にセット if (var2.Body is NakoVarArray) { NakoVarArray var3 = (NakoVarArray)(var2.Body); NakoVariable elem = var3.GetVarFromObj(index); if (elem == null) { elem = new NakoVariable(); elem.SetBodyAutoType(value); if (index is long) { elem.varNo = Convert.ToInt32(index); } var3.SetVarFromObj(index, elem); } else { elem.SetBodyAutoType(value); } } } }