public static bool CheckFieldExistence(ModuleConstructor constructor, ClassType classType, string fieldName, out int index) { ModuleHeaders.TryGetValue(classType.ModuleName, out ModuleHeader header); int classInfoIndex = 1; foreach (ClassConstantInfo classInfo in header.ClassPoolList) { if (header.StringPoolList[classInfo.Name - 1] == classType.ClassName) { break; } ++classInfoIndex; } foreach (FieldConstantInfo fieldInfo in header.FieldPoolList) { if (fieldInfo.Class == classInfoIndex && header.StringPoolList[fieldInfo.Name - 1] == fieldName) { index = constructor.AddFieldPoolInfo(classType, fieldName, header.StringPoolList[fieldInfo.Descriptor - 1], fieldInfo.Flag); return(true); } } index = -1; return(false); }
public static int AssertClassExistence(string moduleName, string className) { ModuleHeaders.TryGetValue(moduleName, out ModuleHeader header); for (int i = 0; i < header.ClassPoolList.Count; ++i) { if (header.StringPoolList[header.ClassPoolList[i].Name - 1] == className) { return(i + 1); } } throw new XiLangError($"{moduleName}.{className} not found"); }
public static List <(string descriptor, uint flag)> GetMethod(MemberType methodType) { if (!ModuleHeaders.TryGetValue(methodType.ClassType.ModuleName, out ModuleHeader header)) { throw new XiLangError($"Module {methodType.ClassType.ModuleName} not imported but used"); } List <(string descriptor, uint flag)> methodDescriptors = new List <(string descriptor, uint flag)>(); foreach (MethodConstantInfo candidate in header.MethodPoolList) { if (header.StringPoolList[header.ClassPoolList[candidate.Class - 1].Name - 1] == methodType.ClassType.ClassName && header.StringPoolList[candidate.Name - 1] == methodType.Name) { methodDescriptors.Add((header.StringPoolList[candidate.Descriptor - 1], candidate.Flag)); } } return(methodDescriptors); }