mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-01-06 18:31:05 +00:00
First stab at asynchronous sysmbols parsing
This commit is contained in:
parent
33a131b361
commit
7ba78a830b
@ -7,6 +7,7 @@
|
||||
using System;
|
||||
using System.Collections.Frozen;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public sealed class Parser
|
||||
{
|
||||
@ -329,7 +330,7 @@
|
||||
|
||||
#region Parser driver
|
||||
|
||||
public void Parse(string? path)
|
||||
public async Task ParseAsync(string? path)
|
||||
{
|
||||
if (this.Parsed)
|
||||
{
|
||||
@ -342,24 +343,19 @@
|
||||
}
|
||||
|
||||
using var reader = new StreamReader(path);
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
var line = reader.ReadLine();
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
await this.ParseAsync(reader);
|
||||
}
|
||||
|
||||
this.ParseLine(line.Split(' ', '\t'));
|
||||
}
|
||||
private async Task ParseAsync(StreamReader reader)
|
||||
{
|
||||
await this.ParseLinesAsync(reader);
|
||||
|
||||
this.FreezeParsedData();
|
||||
|
||||
// Intermediate data no longer needed
|
||||
// Only "frozen" parsed data is needed.
|
||||
#if DEBUG
|
||||
this._parsed_intermediate.Clear();
|
||||
#endif
|
||||
|
||||
this.ExtractFiles();
|
||||
this.ExtractLines();
|
||||
this.ExtractModules();
|
||||
@ -370,9 +366,7 @@
|
||||
this.ExtractTypes();
|
||||
|
||||
// Frozen parsed data is no longer needed
|
||||
#if DEBUG
|
||||
this._parsed = null;
|
||||
#endif
|
||||
|
||||
// We are now mostly parsed
|
||||
this.Parsed = true;
|
||||
@ -381,6 +375,20 @@
|
||||
this.BuildAddressableScopes();
|
||||
}
|
||||
|
||||
private async Task ParseLinesAsync(StreamReader reader)
|
||||
{
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
var line = await reader.ReadLineAsync();
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
this.ParseLine(line.Split(' ', '\t'));
|
||||
}
|
||||
}
|
||||
|
||||
private void FreezeParsedData()
|
||||
{
|
||||
var intermediateSections = new Dictionary<string, FrozenDictionary<int, FrozenDictionary<string, string>>>(this._parsed_intermediate.Count);
|
||||
|
@ -7,6 +7,7 @@ namespace M6502.Test
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using EightBit;
|
||||
|
||||
internal class Board : Bus
|
||||
@ -61,6 +62,12 @@ namespace M6502.Test
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
Task? symbolsParserTask = null;
|
||||
if (this.configuration.Profile || this.configuration.DebugMode)
|
||||
{
|
||||
symbolsParserTask = this.symbols.ParseAsync(string.IsNullOrEmpty(this.configuration.Symbols) ? string.Empty : this.configuration.RomDirectory + "/" + this.configuration.Symbols);
|
||||
}
|
||||
|
||||
var programPath = this.configuration.RomDirectory + "/" + this.configuration.Program;
|
||||
var loadAddress = this.configuration.LoadAddress;
|
||||
this.ram.Load(programPath, loadAddress.Word);
|
||||
@ -80,11 +87,6 @@ namespace M6502.Test
|
||||
this.CPU.ExecutedInstruction += this.CPU_ExecutedInstruction;
|
||||
this.WrittenByte += this.Bus_WrittenByte;
|
||||
|
||||
if (this.configuration.Profile || this.configuration.DebugMode)
|
||||
{
|
||||
this.symbols.Parse(string.IsNullOrEmpty(this.configuration.Symbols) ? string.Empty : this.configuration.RomDirectory + "/" + this.configuration.Symbols);
|
||||
}
|
||||
|
||||
if (this.configuration.Profile)
|
||||
{
|
||||
this.profiler.StartingOutput += this.Profiler_StartingOutput;
|
||||
@ -102,6 +104,8 @@ namespace M6502.Test
|
||||
|
||||
this.Poke(0x00, 0x4c);
|
||||
this.CPU.PokeWord(0x01, this.configuration.StartAddress);
|
||||
|
||||
symbolsParserTask?.Wait();
|
||||
}
|
||||
|
||||
public override MemoryMapping Mapping(ushort absolute) => this.mapping;
|
||||
|
Loading…
Reference in New Issue
Block a user