public void Add(int address, string name = null) { if (Exists(address)) { return; } var routine = ZRoutine.Create(address, story.Memory, cache, name); routines.Add(address, routine); var index = sortedAddresses.BinarySearch(address); sortedAddresses.Insert(~index, address); var handler = RoutineAdded; if (handler != null) { handler(this, new ZRoutineAddedEventArgs(routine)); } foreach (var i in routine.Instructions.Where(i => IsAnalyzableCall(i))) { Add(UnpackCallAddress(i)); } }
internal ZPropertyTable GetPropertyTable(ushort address) { ZPropertyTable propertyTable; if (!propertyTables.TryGetValue(address, out propertyTable)) { propertyTable = new ZPropertyTable(this, address); propertyTables.Add(address, propertyTable); } return(propertyTable); }
public InstructionLinkedList(ZRoutine routine) : base(routine.Instructions) { this.addressToNodeMap = new IntegerMap <LinkedListNode <Instruction> >(); var node = this.First; while (node != null) { addressToNodeMap.Add(node.Value.Address, node); node = node.Next; } }
internal ZCompilerResult Compile(ZRoutine routine) { ZCompilerResult result; if (!compilationResults.TryGetValue(routine.Address, out result)) { result = ZCompiler.Compile(routine, machine: this); compilationResults.Add(routine.Address, result); if (profiler != null) { profiler.RoutineCompiled(result.Statistics); } } return(result); }
internal ZRoutineCall GetRoutineCall(int address) { ZRoutineCall routineCall; if (!addressToRoutineCallMap.TryGetValue(address, out routineCall)) { cacheMiss++; var routine = GetRoutineByAddress(address); routineCall = new ZRoutineCall(routine, machine: this); addressToRoutineCallMap.Add(address, routineCall); } if (this.precompile && !compiling) { compiling = true; routineCall.Compile(); compiling = false; } return(routineCall); }
internal void Add(int address, Instruction instruction) { map.Add(address, instruction); }
private void DebuggerService_MachineCreated(object sender, MachineCreatedEventArgs e) { var reader = new MemoryReader(storyService.Story.Memory, 0); DisassemblyLineViewModel ipLine; lines.BeginBulkOperation(); try { var routineTable = routineService.RoutineTable; for (int rIndex = 0; rIndex < routineTable.Count; rIndex++) { var routine = routineTable[rIndex]; if (rIndex > 0) { var lastRoutine = routineTable[rIndex - 1]; if (lastRoutine.Address + lastRoutine.Length < routine.Address) { var addressGapLine = new DisassemblyAddressGapLineViewModel(lastRoutine, routine) { ShowBlankBefore = true }; lines.Add(addressGapLine); } } var routineHeaderLine = new DisassemblyRoutineHeaderLineViewModel(routine) { ShowBlankBefore = rIndex > 0, ShowBlankAfter = true }; routineAddressAndIndexList.Add(new AddressAndIndex(routineHeaderLine.Address, lines.Count)); lines.Add(routineHeaderLine); addressToLineMap.Add(routine.Address, routineHeaderLine); var instructions = routine.Instructions; var lastIndex = instructions.Length - 1; for (int i = 0; i <= lastIndex; i++) { var instruction = instructions[i]; var instructionLine = new DisassemblyInstructionLineViewModel(instruction, i == lastIndex); if (breakpointService.Exists(instruction.Address)) { instructionLine.HasBreakpoint = true; } lines.Add(instructionLine); addressToLineMap.Add(instruction.Address, instructionLine); } } ipLine = GetLineByAddress(debuggerService.Machine.PC); ipLine.HasIP = true; } finally { lines.EndBulkOperation(); } BringLineIntoView(ipLine); routineService.RoutineTable.RoutineAdded += RoutineTable_RoutineAdded; }