//Formで作っていた型情報を追加. void ROMTypeLoadResource() { char[] skipTrim = new char[] { ' ', '_' }; Assembly assembly = Assembly.GetExecutingAssembly(); foreach (Type q in assembly.GetTypes()) { if (!q.IsClass) { continue; } if (q.Name.LastIndexOf("Form") == q.Name.Length - 4) { continue; } List <AsmStructNode> structSt = new List <AsmStructNode>(); const BindingFlags FINDS_FLAG = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly; FieldInfo[] fields = q.GetFields(FINDS_FLAG); foreach (FieldInfo f in fields) { string name = f.Name; if (name.IndexOf("L_") >= 0 || name.IndexOf("J_") >= 0) { continue; } string prefix = InputFormRef.GetPrefixName(name); uint id = InputFormRef.GetStructID(prefix, name); if (id == U.NOT_FOUND) { continue; } AsmStruct aStruct; string key = q.Name + prefix; if (AsmStructs.ContainsKey(key)) { aStruct = AsmStructs[key]; } else { aStruct = new AsmStruct(); aStruct.Nodes = new List <AsmStructNode>(); AsmStructs[key] = aStruct; } AsmStructNode node; string a = InputFormRef.SkipPrefixName(name, prefix); if (a.Length <= 0) { continue; } else if (a[0] == 'b') { node = new AsmStructNode(); node.Type = AsmStructTypeEnum.b; aStruct.SizeOf = Math.Max(aStruct.SizeOf, id + 1); } else if (a[0] == 'B') { node = new AsmStructNode(); node.Type = AsmStructTypeEnum.B; aStruct.SizeOf = Math.Max(aStruct.SizeOf, id + 1); } else if (a[0] == 'W') { node = new AsmStructNode(); node.Type = AsmStructTypeEnum.W; aStruct.SizeOf = Math.Max(aStruct.SizeOf, id + 2); } else if (a[0] == 'D') { node = new AsmStructNode(); node.Type = AsmStructTypeEnum.D; aStruct.SizeOf = Math.Max(aStruct.SizeOf, id + 4); } else if (a[0] == 'P') { node = new AsmStructNode(); node.Type = AsmStructTypeEnum.P; aStruct.SizeOf = Math.Max(aStruct.SizeOf, id + 4); } else {//不明 continue; } node.Offset = id; node.Name = ""; node.Comment = ""; node.TypeName = ""; string find_jump_name = "J_" + id; string find_label_name = "L_" + id; foreach (FieldInfo ff in fields) { int p = ff.Name.IndexOf(find_jump_name); if (p >= 0) { uint lid = InputFormRef.GetStructID(prefix, name); if (lid != id) { continue; } node.Name = U.substr(ff.Name, p + find_jump_name.Length + 1).Trim(skipTrim); if (node.TypeName.Length < 0) { node.TypeName = node.Name; } continue; } p = ff.Name.IndexOf(find_label_name); if (p >= 0) { uint lid = InputFormRef.GetStructID(prefix, name); if (lid != id) { continue; } string label = U.substr(ff.Name, p + find_label_name.Length + 1).Trim(skipTrim); if (label == "COMBO") { continue; } node.TypeName = label; continue; } } aStruct.Nodes.Add(node); } } }
void ASMMapLoadStruct(string fullfilename, ROM rom) { //ユーザが定義したmapファイル if (!File.Exists(fullfilename)) { Debug.Assert(false); return; } using (StreamReader reader = File.OpenText(fullfilename)) { string line; while ((line = reader.ReadLine()) != null) { if (U.IsComment(line) || U.OtherLangLine(line, rom)) { continue; } line = U.ClipComment(line); string[] sp = line.Split('\t'); if (sp.Length <= 2) { continue; } string op = sp[0]; if (op.Length <= 0) { continue; } if (op[0] != '@') {//struct定義でなければ無視 continue; } string[] st = op.Split('@'); if (st.Length <= 2) { continue; } AsmStruct asmStrict; if (!AsmStructs.ContainsKey(st[1])) { asmStrict = new AsmStruct(); asmStrict.SizeOf = 0; asmStrict.Nodes = new List <AsmStructNode>(); AsmStructs[st[1]] = asmStrict; } else { asmStrict = AsmStructs[st[1]]; } AsmStructNode node = new AsmStructNode(); node.Offset = U.atoh(st[2]); string type = sp[1]; if (type == "short") { asmStrict.SizeOf = Math.Max(asmStrict.SizeOf, node.Offset + 2); node.Type = AsmStructTypeEnum.W; } else if (type == "sbyte") { asmStrict.SizeOf = Math.Max(asmStrict.SizeOf, node.Offset + 1); node.Type = AsmStructTypeEnum.b; } else if (type == "word" || type == "dword") { asmStrict.SizeOf = Math.Max(asmStrict.SizeOf, node.Offset + 4); node.Type = AsmStructTypeEnum.D; } else if (type == "pointer") { asmStrict.SizeOf = Math.Max(asmStrict.SizeOf, node.Offset + 4); node.Type = AsmStructTypeEnum.P; } else if (type.Length > 0 && type[0] == '&') { asmStrict.SizeOf = Math.Max(asmStrict.SizeOf, node.Offset + 4); node.Type = AsmStructTypeEnum.P; node.TypeName = type.Substring(1); } else { asmStrict.SizeOf = Math.Max(asmStrict.SizeOf, node.Offset + 1); node.Type = AsmStructTypeEnum.B; //不明 } node.Name = sp[2]; StringBuilder comment = new StringBuilder(); for (int i = 3; i < sp.Length; i++) { comment.Append(" "); comment.Append(sp[i]); } node.Comment = U.substr(comment.ToString(), 1); asmStrict.Nodes.Add(node); } } }