public override Int64 GetIntValue(ExpressionMediator exm) { if (dic == null) { dic = exm.VEvaluator.Constant.GetKeywordDictionary(out errPos, parentCode, index); } string key = strTerm.GetStrValue(exm); if (key == "") { throw new CodeEE("キーワードを空には出来ません"); } int i; if (!dic.TryGetValue(key, out i)) { if (errPos == null) { throw new CodeEE("配列変数" + parentCode.ToString() + "の要素を文字列で指定することはできません"); } else { throw new CodeEE(errPos + "の中に\"" + key + "\"の定義がありません"); } } return(i); }
public override string ToString() { return(code.ToString()); }
static VariableIdentifier() { Array array = Enum.GetValues(typeof(VariableCode)); nameDic.Add(VariableCode.__FILE__.ToString(), VariableCode.__FILE__); nameDic.Add(VariableCode.__LINE__.ToString(), VariableCode.__LINE__); nameDic.Add(VariableCode.__FUNCTION__.ToString(), VariableCode.__FUNCTION__); foreach (object name in array) { VariableCode code = (VariableCode)name; string key = code.ToString(); if ((key == null) || (key.StartsWith("__") && key.EndsWith("__"))) { continue; } if (Config.ICVariable) { key = key.ToUpper(); } if (nameDic.ContainsKey(key)) { continue; } #if UEMUERA_DEBUG if ((code & VariableCode.__ARRAY_2D__) == VariableCode.__ARRAY_2D__) { if ((code & VariableCode.__ARRAY_1D__) == VariableCode.__ARRAY_1D__) { throw new ExeEE("ARRAY2DとARRAY1Dは排他"); } } if (((code & VariableCode.__INTEGER__) != VariableCode.__INTEGER__) && ((code & VariableCode.__STRING__) != VariableCode.__STRING__)) { throw new ExeEE("INTEGERとSTRINGのどちらかは必須"); } if (((code & VariableCode.__INTEGER__) == VariableCode.__INTEGER__) && ((code & VariableCode.__STRING__) == VariableCode.__STRING__)) { throw new ExeEE("INTEGERとSTRINGは排他"); } if ((code & VariableCode.__EXTENDED__) != VariableCode.__EXTENDED__) { if ((code & VariableCode.__SAVE_EXTENDED__) == VariableCode.__SAVE_EXTENDED__) { throw new ExeEE("SAVE_EXTENDEDにはEXTENDEDフラグ必須"); } if ((code & VariableCode.__LOCAL__) == VariableCode.__LOCAL__) { throw new ExeEE("LOCALにはEXTENDEDフラグ必須"); } if ((code & VariableCode.__GLOBAL__) == VariableCode.__GLOBAL__) { throw new ExeEE("GLOBALにはEXTENDEDフラグ必須"); } if ((code & VariableCode.__ARRAY_2D__) == VariableCode.__ARRAY_2D__) { throw new ExeEE("ARRAY2DにはEXTENDEDフラグ必須"); } } if (((code & VariableCode.__SAVE_EXTENDED__) == VariableCode.__SAVE_EXTENDED__) && ((code & VariableCode.__UNCHANGEABLE__) == VariableCode.__UNCHANGEABLE__)) { throw new ExeEE("CALCとSAVE_EXTENDEDは排他"); } if (((code & VariableCode.__SAVE_EXTENDED__) == VariableCode.__SAVE_EXTENDED__) && ((code & VariableCode.__CALC__) == VariableCode.__CALC__)) { throw new ExeEE("UNCHANGEABLEとSAVE_EXTENDEDは排他"); } if (((code & VariableCode.__SAVE_EXTENDED__) == VariableCode.__SAVE_EXTENDED__) && ((code & VariableCode.__ARRAY_2D__) == VariableCode.__ARRAY_2D__) && ((code & VariableCode.__STRING__) == VariableCode.__STRING__)) { throw new ExeEE("STRINGかつARRAY2DのSAVE_EXTENDEDは未実装"); } #endif nameDic.Add(key, code); ////セーブが必要な変数リストの作成 ////__SAVE_EXTENDED__フラグ持ち //if ((code & VariableCode.__SAVE_EXTENDED__) == VariableCode.__SAVE_EXTENDED__) //{ // if ((code & VariableCode.__CHARACTER_DATA__) == VariableCode.__CHARACTER_DATA__) // charaSaveDataList.Add(code); // else // saveDataList.Add(code); //} //else if ( ((code & VariableCode.__EXTENDED__) != VariableCode.__EXTENDED__) // && ((code & VariableCode.__CALC__) != VariableCode.__CALC__) // && ((code & VariableCode.__UNCHANGEABLE__) != VariableCode.__UNCHANGEABLE__) // && ((code & VariableCode.__LOCAL__) != VariableCode.__LOCAL__) // && (!key.StartsWith("NOTUSE_")) ) //{//eramaker由来の変数でセーブするもの // VariableCode flag = code & (VariableCode.__ARRAY_1D__ | VariableCode.__ARRAY_2D__ | VariableCode.__ARRAY_3D__ | VariableCode.__STRING__ | VariableCode.__INTEGER__ | VariableCode.__CHARACTER_DATA__); // int codeInt = (int)VariableCode.__LOWERCASE__ & (int)code; // switch (flag) // { // case VariableCode.__CHARACTER_DATA__ | VariableCode.__INTEGER__: // if (codeInt < (int)VariableCode.__COUNT_SAVE_CHARACTER_INTEGER__) // charaSaveDataList.Add(code); // break; // case VariableCode.__CHARACTER_DATA__ | VariableCode.__STRING__: // if (codeInt < (int)VariableCode.__COUNT_SAVE_CHARACTER_STRING__) // charaSaveDataList.Add(code); // break; // case VariableCode.__CHARACTER_DATA__ | VariableCode.__INTEGER__ | VariableCode.__ARRAY_1D__: // if (codeInt < (int)VariableCode.__COUNT_SAVE_CHARACTER_INTEGER_ARRAY__) // charaSaveDataList.Add(code); // break; // case VariableCode.__CHARACTER_DATA__ | VariableCode.__STRING__ | VariableCode.__ARRAY_1D__: // if (codeInt < (int)VariableCode.__COUNT_SAVE_CHARACTER_STRING_ARRAY__) // charaSaveDataList.Add(code); // break; // case VariableCode.__INTEGER__: // if (codeInt < (int)VariableCode.__COUNT_SAVE_INTEGER__) // saveDataList.Add(code); // break; // case VariableCode.__STRING__: // if (codeInt < (int)VariableCode.__COUNT_SAVE_STRING__) // saveDataList.Add(code); // break; // case VariableCode.__INTEGER__ | VariableCode.__ARRAY_1D__: // if (codeInt < (int)VariableCode.__COUNT_SAVE_INTEGER_ARRAY__) // saveDataList.Add(code); // break; // case VariableCode.__STRING__ | VariableCode.__ARRAY_1D__: // if (codeInt < (int)VariableCode.__COUNT_SAVE_STRING_ARRAY__) // saveDataList.Add(code); // break; // } //} if ((code & VariableCode.__LOCAL__) == VariableCode.__LOCAL__) { localvarNameDic.Add(key, code); } if ((code & VariableCode.__SAVE_EXTENDED__) == VariableCode.__SAVE_EXTENDED__) { VariableCode flag = code & (VariableCode.__ARRAY_1D__ | VariableCode.__ARRAY_2D__ | VariableCode.__ARRAY_3D__ | VariableCode.__CHARACTER_DATA__ | VariableCode.__STRING__ | VariableCode.__INTEGER__); if (!extSaveListDic.TryGetValue(flag, out var var_code_list)) { var_code_list = new List <VariableCode>(); extSaveListDic.Add(flag, var_code_list); } var_code_list.Add(code); } } }
public int KeywordToInteger(VariableCode code, string key, int index) { if (string.IsNullOrEmpty(key)) throw new CodeEE("キーワードを空には出来ません"); int ret = -1; string errPos; Dictionary<string, int> dic = GetKeywordDictionary(out errPos, code, index); if (dic.TryGetValue(key, out ret)) return ret; if (errPos == null) throw new CodeEE("配列変数" + code.ToString() + "の要素を文字列で指定することはできません"); else throw new CodeEE(errPos + "の中に\"" + key + "\"の定義がありません"); }
public Dictionary<string, int> GetKeywordDictionary(out string errPos, VariableCode code, int index) { errPos = null; int allowIndex = -1; Dictionary<string, int> ret = null; switch (code) { case VariableCode.ABL: ret = nameToIntDics[ablIndex];//AblName; errPos = "abl.csv"; allowIndex = 1; break; case VariableCode.EXP: ret = nameToIntDics[expIndex];//ExpName; errPos = "exp.csv"; allowIndex = 1; break; case VariableCode.TALENT: ret = nameToIntDics[talentIndex];//TalentName; errPos = "talent.csv"; allowIndex = 1; break; case VariableCode.UP: case VariableCode.DOWN: ret = nameToIntDics[paramIndex];//ParamName 1; errPos = "palam.csv"; allowIndex = 0; break; case VariableCode.PALAM: case VariableCode.JUEL: case VariableCode.GOTJUEL: case VariableCode.CUP: case VariableCode.CDOWN: ret = nameToIntDics[paramIndex];//ParamName 2; errPos = "palam.csv"; allowIndex = 1; break; case VariableCode.TRAINNAME: ret = nameToIntDics[trainIndex];//TrainName; errPos = "train.csv"; allowIndex = 0; break; case VariableCode.MARK: ret = nameToIntDics[markIndex];//MarkName; errPos = "mark.csv"; allowIndex = 1; break; case VariableCode.ITEM: case VariableCode.ITEMSALES: case VariableCode.ITEMPRICE: ret = nameToIntDics[itemIndex];//ItemName; errPos = "Item.csv"; allowIndex = 0; break; case VariableCode.LOSEBASE: ret = nameToIntDics[baseIndex];//BaseName; errPos = "base.csv"; allowIndex = 0; break; case VariableCode.BASE: case VariableCode.MAXBASE: case VariableCode.DOWNBASE: ret = nameToIntDics[baseIndex];//BaseName; errPos = "base.csv"; allowIndex = 1; break; case VariableCode.SOURCE: ret = nameToIntDics[sourceIndex];//SourceName; errPos = "source.csv"; allowIndex = 1; break; case VariableCode.EX: case VariableCode.NOWEX: ret = nameToIntDics[exIndex];//ExName; errPos = "ex.csv"; allowIndex = 1; break; case VariableCode.EQUIP: ret = nameToIntDics[equipIndex];//EquipName; errPos = "equip.csv"; allowIndex = 1; break; case VariableCode.TEQUIP: ret = nameToIntDics[tequipIndex];//TequipName; errPos = "tequip.csv"; allowIndex = 1; break; case VariableCode.FLAG: ret = nameToIntDics[flagIndex];//FlagName; errPos = "flag.csv"; allowIndex = 0; break; case VariableCode.TFLAG: ret = nameToIntDics[tflagIndex];//TFlagName; errPos = "tflag.csv"; allowIndex = 0; break; case VariableCode.CFLAG: ret = nameToIntDics[cflagIndex];//CFlagName; errPos = "cflag.csv"; allowIndex = 1; break; case VariableCode.TCVAR: ret = nameToIntDics[tcvarIndex];//TCVarName; errPos = "tcvar.csv"; allowIndex = 1; break; case VariableCode.CSTR: ret = nameToIntDics[cstrIndex];//CStrName; errPos = "cstr.csv"; allowIndex = 1; break; case VariableCode.STAIN: ret = nameToIntDics[stainIndex];//StainName; errPos = "stain.csv"; allowIndex = 1; break; case VariableCode.CDFLAGNAME1: ret = nameToIntDics[cdflag1Index]; errPos = "cdflag1.csv"; allowIndex = 0; break; case VariableCode.CDFLAGNAME2: ret = nameToIntDics[cdflag2Index]; errPos = "cdflag2.csv"; allowIndex = 0; break; case VariableCode.CDFLAG: { if (index == 1) { ret = nameToIntDics[cdflag1Index];//CDFlagName1 errPos = "cdflag1.csv"; } else if (index == 2) { ret = nameToIntDics[cdflag2Index];//CDFlagName2 errPos = "cdflag2.csv"; } else if (index >= 0) throw new CodeEE("配列変数" + code.ToString() + "の" + (index + 1).ToString() + "番目の要素を文字列で指定することはできません"); else throw new CodeEE("CDFLAGの要素の取得にはCDFLAGNAME1又はCDFLAGNAME2を使用します"); return ret; } case VariableCode.STR: ret = nameToIntDics[strnameIndex]; errPos = "strname.csv"; allowIndex = 0; break; case VariableCode.TSTR: ret = nameToIntDics[tstrnameIndex]; errPos = "tstr.csv"; allowIndex = 0; break; case VariableCode.SAVESTR: ret = nameToIntDics[savestrnameIndex]; errPos = "savestr.csv"; allowIndex = 0; break; case VariableCode.GLOBAL: ret = nameToIntDics[globalIndex]; errPos = "global.csv"; allowIndex = 0; break; case VariableCode.GLOBALS: ret = nameToIntDics[globalsIndex]; errPos = "globals.csv"; allowIndex = 0; break; case VariableCode.RELATION: ret = relationDic; errPos = "chara*.csv"; allowIndex = 1; break; } if (index < 0) return ret; if (ret == null) throw new CodeEE("配列変数" + code.ToString() + "の要素を文字列で指定することはできません"); if ((index != allowIndex)) throw new CodeEE("配列変数" + code.ToString() + "の" + (index + 1).ToString() + "番目の要素を文字列で指定することはできません"); return ret; }
private void _decideActualArraySize_sub(VariableCode mainCode, VariableCode nameCode, int[] arraylength, ScriptPosition position) { int nameIndex = (int)(nameCode & VariableCode.__LOWERCASE__); int mainLengthIndex = (int)(mainCode & VariableCode.__LOWERCASE__); if (changedCode.Contains(nameCode) && changedCode.Contains(mainCode)) { if (MaxDataList[nameIndex] != arraylength[mainLengthIndex]) { int i = Math.Max(MaxDataList[nameIndex], arraylength[mainLengthIndex]); arraylength[mainLengthIndex] = i; MaxDataList[nameIndex] = i; //1803beta004 不適切な指定として警告Lv1の対象にする ParserMediator.Warn(mainCode.ToString() + "と" + nameCode.ToString() + "の要素数が異なります(大きい方に合わせます)", position, 1); } } else if (changedCode.Contains(nameCode) && !changedCode.Contains(mainCode)) arraylength[mainLengthIndex] = MaxDataList[nameIndex]; else if (!changedCode.Contains(nameCode) && changedCode.Contains(mainCode)) MaxDataList[nameIndex] = arraylength[mainLengthIndex]; }
public void SaveToStreamBinary(EraBinaryDataWriter writer, VariableData varData) { //eramaker変数の保存 foreach (KeyValuePair <string, VariableToken> pair in varData.GetVarTokenDic()) { VariableToken var = pair.Value; if (!var.IsSavedata || !var.IsCharacterData || var.IsGlobal) { continue; } VariableCode code = var.Code; VariableCode flag = code & (VariableCode.__ARRAY_1D__ | VariableCode.__ARRAY_2D__ | VariableCode.__ARRAY_3D__ | VariableCode.__STRING__ | VariableCode.__INTEGER__); int CodeInt = var.CodeInt; switch (flag) { case VariableCode.__INTEGER__: writer.WriteWithKey(code.ToString(), dataInteger[CodeInt]); break; case VariableCode.__STRING__: writer.WriteWithKey(code.ToString(), dataString[CodeInt]); break; case VariableCode.__INTEGER__ | VariableCode.__ARRAY_1D__: writer.WriteWithKey(code.ToString(), dataIntegerArray[CodeInt]); break; case VariableCode.__STRING__ | VariableCode.__ARRAY_1D__: writer.WriteWithKey(code.ToString(), dataStringArray[CodeInt]); break; case VariableCode.__INTEGER__ | VariableCode.__ARRAY_2D__: writer.WriteWithKey(code.ToString(), dataIntegerArray2D[CodeInt]); break; case VariableCode.__STRING__ | VariableCode.__ARRAY_2D__: writer.WriteWithKey(code.ToString(), dataStringArray2D[CodeInt]); break; //case VariableCode.__INTEGER__ | VariableCode.__ARRAY_3D__: // writer.Write(code.ToString(), dataIntegerArray3D[CodeInt]); // break; //case VariableCode.__STRING__ | VariableCode.__ARRAY_3D__: // writer.Write(code.ToString(), dataStringArray3D[CodeInt]); // break; } } //1813追加 if (UserDefCVarDataList.Count != 0) { writer.WriteSeparator(); //#DIM宣言変数の保存 foreach (UserDefinedCharaVariableToken var in varData.UserDefinedCharaVarList) { if (!var.IsSavedata || !var.IsCharacterData || var.IsGlobal) { continue; } writer.WriteWithKey(var.Name, UserDefCVarDataList[var.ArrayIndex]); } } writer.WriteEOC(); }
protected VariableToken(VariableCode varCode, VariableData varData) { Code = varCode; VariableType = ((varCode & VariableCode.__INTEGER__) == VariableCode.__INTEGER__) ? typeof(Int64) : typeof(string); VarCodeInt = (int)(varCode & VariableCode.__LOWERCASE__); varName = varCode.ToString(); this.varData = varData; IsPrivate = false; IsReference = false; Dimension = 0; IsGlobal = (Code == VariableCode.GLOBAL) || (Code == VariableCode.GLOBALS); if ((Code & VariableCode.__ARRAY_1D__) == VariableCode.__ARRAY_1D__) Dimension = 1; if ((Code & VariableCode.__ARRAY_2D__) == VariableCode.__ARRAY_2D__) Dimension = 2; if ((Code & VariableCode.__ARRAY_3D__) == VariableCode.__ARRAY_3D__) Dimension = 3; IsSavedata = false; if ((Code == VariableCode.GLOBAL) || (Code == VariableCode.GLOBALS)) IsSavedata = true; else if ((Code & VariableCode.__SAVE_EXTENDED__) == VariableCode.__SAVE_EXTENDED__) { IsSavedata = true; } else if (((Code & VariableCode.__EXTENDED__) != VariableCode.__EXTENDED__) && ((Code & VariableCode.__CALC__) != VariableCode.__CALC__) && ((Code & VariableCode.__UNCHANGEABLE__) != VariableCode.__UNCHANGEABLE__) && ((Code & VariableCode.__LOCAL__) != VariableCode.__LOCAL__) && (!varName.StartsWith("NOTUSE_"))) { VariableCode flag = Code & (VariableCode.__ARRAY_1D__ | VariableCode.__ARRAY_2D__ | VariableCode.__ARRAY_3D__ | VariableCode.__STRING__ | VariableCode.__INTEGER__ | VariableCode.__CHARACTER_DATA__); switch (flag) { case VariableCode.__CHARACTER_DATA__ | VariableCode.__INTEGER__: if (VarCodeInt < (int)VariableCode.__COUNT_SAVE_CHARACTER_INTEGER__) IsSavedata = true; break; case VariableCode.__CHARACTER_DATA__ | VariableCode.__STRING__: if (VarCodeInt < (int)VariableCode.__COUNT_SAVE_CHARACTER_STRING__) IsSavedata = true; break; case VariableCode.__CHARACTER_DATA__ | VariableCode.__INTEGER__ | VariableCode.__ARRAY_1D__: if (VarCodeInt < (int)VariableCode.__COUNT_SAVE_CHARACTER_INTEGER_ARRAY__) IsSavedata = true; break; case VariableCode.__CHARACTER_DATA__ | VariableCode.__STRING__ | VariableCode.__ARRAY_1D__: if (VarCodeInt < (int)VariableCode.__COUNT_SAVE_CHARACTER_STRING_ARRAY__) IsSavedata = true; break; case VariableCode.__INTEGER__: if (VarCodeInt < (int)VariableCode.__COUNT_SAVE_INTEGER__) IsSavedata = true; break; case VariableCode.__STRING__: if (VarCodeInt < (int)VariableCode.__COUNT_SAVE_STRING__) IsSavedata = true; break; case VariableCode.__INTEGER__ | VariableCode.__ARRAY_1D__: if (VarCodeInt < (int)VariableCode.__COUNT_SAVE_INTEGER_ARRAY__) IsSavedata = true; break; case VariableCode.__STRING__ | VariableCode.__ARRAY_1D__: if (VarCodeInt < (int)VariableCode.__COUNT_SAVE_STRING_ARRAY__) IsSavedata = true; break; } } }