private void ReadStates(PapyrusAssemblyDefinition asm, PapyrusTypeDefinition typeDef) { var stateCount = pexReader.ReadInt16(); for (var i = 0; i < stateCount; i++) { var state = new PapyrusStateDefinition(typeDef); state.Name = pexReader.ReadStringRef(); var methodCount = pexReader.ReadInt16(); for (var k = 0; k < methodCount; k++) { var name = pexReader.ReadString(); var method = ReadMethod(asm); method.DeclaringState = state; method.Name = new PapyrusStringRef(asm, name); if (method.Name.Value.ToLower().StartsWith("on")) { // For now, lets assume that all functions with the name starting with "On" is an event. method.IsEvent = true; } state.Methods.Add(method); } // typeDef.States.Add(state); } UpdateOperands(typeDef.States); }
public PapyrusStateEditorViewModel(PapyrusStateDefinition stateToEdit = null) { if (stateToEdit != null) { Name = stateToEdit.Name.Value; } }
private void WriteState(PapyrusStateDefinition state) { pexWriter.Write(state.Name); pexWriter.Write((short)state.Methods.Count); foreach (var method in state.Methods) { pexWriter.Write(method.Name); WriteMethod(method); } }
private PapyrusTypeDefinition CreateType(PapyrusAssemblyDefinition pex, TypeDefinition type, PapyrusCompilerOptions options, bool isStruct = false) { var papyrusType = new PapyrusTypeDefinition(pex, isStruct); if (isStruct) { papyrusType.IsStruct = true; papyrusType.IsClass = false; } papyrusType.Name = type.Name.Ref(pex); papyrusType.AutoStateName = "".Ref(pex); papyrusType.Documentation = "".Ref(pex); papyrusType.BaseTypeName = type.BaseType != null ? Utility.GetPapyrusBaseType(type.BaseType).Ref(pex) : "".Ref(pex); UpdateUserFlags(type, pex); // Create Fields CreateFields(type, pex).ForEach(papyrusType.Fields.Add); // Create Properties CreateProperties(papyrusAssemblies, type, papyrusType, pex).ForEach(papyrusType.Properties.Add); // Create Structs foreach (var nestedType in type.NestedTypes) { // Make sure we don't add any delegate classes, as those are not supported as is if (delegatePairDefinition.DelegateTypeDefinitions.Contains(nestedType)) { continue; } // We do not want to include any Enums either :-) if (EnumDefinitions.Contains(nestedType)) { continue; } papyrusType.NestedTypes.Add(CreateStruct(nestedType, pex, options)); } if (!isStruct) { var autoState = new PapyrusStateDefinition(papyrusType) { Name = "".Ref(pex) }; // -- Do not create the methods until all types has been parsed. excluding getters and setters // CreateMethods(type, papyrusType, pex, options).ForEach(autoState.Methods.Add); } return(papyrusType); }
public void AddResult(PapyrusTypeDefinition type, PapyrusStateDefinition state, PapyrusMethodDefinition method, PapyrusInstruction instruction, string search, string resultRepresentation) { SearchText = search; usageRepresentaitons.Add(new FindResultData { Type = type, State = state, Method = method, Instruction = instruction, Text = resultRepresentation, SearchText = search }); }