Skip to content

Commit

Permalink
General code and project cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rbergen committed Mar 23, 2021
1 parent 3ee292d commit 1e621ae
Show file tree
Hide file tree
Showing 22 changed files with 77 additions and 482 deletions.
4 changes: 1 addition & 3 deletions MixAssembler/Assembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@ public static InstructionInstanceBase[] Assemble(string[] sourceLines, out PreIn

list.Add(instructionInstance);

if (instructionInstance != null && instructionInstance.Instruction is LoaderInstruction)
if (instructionInstance != null && instructionInstance.Instruction is LoaderInstruction loaderInstruction)
{
var loaderInstruction = (LoaderInstruction)instructionInstance.Instruction;

if (loaderInstruction.Operation == LoaderInstruction.Operations.SetLocationCounter)
{
status.LocationCounter = (int)((LoaderInstruction.Instance)instructionInstance).Value.LongValue;
Expand Down
4 changes: 2 additions & 2 deletions MixAssembler/Instruction/MixInstructionParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ public static IInstructionParameters ParseAddressField(InstructionBase instructi
return null;
}

var index = IPartValue.ParseValue(addressField.Substring(indexCharIndex, sectionCharIndex - indexCharIndex), indexCharIndex, status);
var index = IPartValue.ParseValue(addressField[indexCharIndex..sectionCharIndex], indexCharIndex, status);
if (index == null)
{
status.ReportParsingError(indexCharIndex, sectionCharIndex - indexCharIndex, "unable to parse index");
return null;
}

var field = FPartValue.ParseValue(addressField.Substring(sectionCharIndex), sectionCharIndex, status);
var field = FPartValue.ParseValue(addressField[sectionCharIndex..], sectionCharIndex, status);
if (field == null)
{
status.ReportParsingError(sectionCharIndex, addressField.Length - sectionCharIndex, "unable to parse field");
Expand Down
7 changes: 1 addition & 6 deletions MixAssembler/MixAssembler.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<OutputType>Library</OutputType>
Expand All @@ -16,11 +16,6 @@
<ItemGroup>
<Content Include="MixFormIcon.ico" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Symbol\SymbolBase.cs" />
<Compile Remove="Symbol\SymbolCollection.cs" />
<Compile Remove="Value\IValue.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.2.212405">
<PrivateAssets>all</PrivateAssets>
Expand Down
10 changes: 5 additions & 5 deletions MixAssembler/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public static class Parser
const int addressFieldIndex = 2;
const int commentFieldIndex = 3;

static readonly InstructionSet mInstructionSet = new InstructionSet();
static readonly LoaderInstructions mLoaderInstructions = new LoaderInstructions();
static readonly InstructionSet mInstructionSet = new();
static readonly LoaderInstructions mLoaderInstructions = new();

static bool IsCommentLine(string sourceLine)
{
Expand Down Expand Up @@ -283,7 +283,7 @@ static string[] SplitLine(string sourceLine)
var opFieldEnd = FindFirstWhiteSpace(sourceLine, opFieldStart);
if (opFieldEnd == -1)
{
return new string[] { sourceLine.Substring(0, searchBeyondIndex), sourceLine.Substring(opFieldStart), "", "" };
return new string[] { sourceLine.Substring(0, searchBeyondIndex), sourceLine[opFieldStart..], "", "" };
}

int opFieldLength = opFieldEnd - opFieldStart;
Expand Down Expand Up @@ -312,7 +312,7 @@ static string[] SplitLine(string sourceLine)

if (addressFieldEnd == -1)
{
return new string[] { sourceLine.Substring(0, searchBeyondIndex), sourceLine.Substring(opFieldStart, opFieldLength), sourceLine.Substring(addressFieldStart), "" };
return new string[] { sourceLine.Substring(0, searchBeyondIndex), sourceLine.Substring(opFieldStart, opFieldLength), sourceLine[addressFieldStart..], "" };
}

int addressFieldLength = addressFieldEnd - addressFieldStart;
Expand All @@ -322,7 +322,7 @@ static string[] SplitLine(string sourceLine)
return new string[] { sourceLine.Substring(0, searchBeyondIndex), sourceLine.Substring(opFieldStart, opFieldLength), sourceLine.Substring(addressFieldStart, addressFieldLength), "" };
}

return new string[] { sourceLine.Substring(0, searchBeyondIndex), sourceLine.Substring(opFieldStart, opFieldLength), sourceLine.Substring(addressFieldStart, addressFieldLength), sourceLine.Substring(commentFieldStart) };
return new string[] { sourceLine.Substring(0, searchBeyondIndex), sourceLine.Substring(opFieldStart, opFieldLength), sourceLine.Substring(addressFieldStart, addressFieldLength), sourceLine[commentFieldStart..] };
}
}
}
7 changes: 0 additions & 7 deletions MixAssembler/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MixAssembler": {
"commandName": "Project",
"launchBrowser": true,
Expand Down
4 changes: 2 additions & 2 deletions MixAssembler/Symbol/LiteralConstantSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ static string GetName(Word.Signs literalSign, long literalMagnitude, int count)

public static IValue ParseValue(string text, int sectionCharIndex, ParsingStatus status)
{
if (text.Length < 2 || text[0] != '=' || text[text.Length - 1] != '=')
if (text.Length < 2 || text[0] != '=' || text[^1] != '=')
{
return null;
}

var expressionValue = WValue.ParseValue(text.Substring(1, text.Length - 2), sectionCharIndex + 1, status);
var expressionValue = WValue.ParseValue(text[1..^1], sectionCharIndex + 1, status);
if (expressionValue == null)
{
return null;
Expand Down
10 changes: 2 additions & 8 deletions MixAssembler/Symbol/LocalSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ public override void SetValue(long value)
mAddresses.Add(value);
}

static bool IsBackwardReferenceChar(char c)
{
return c == 'B';
}

static bool IsDefinitionChar(char c)
{
return c == 'H';
Expand All @@ -53,7 +48,7 @@ static bool IsLocalSymbol(string text)

static bool IsLocalSymbolChar(char c)
{
return "BHF".IndexOf(c) >= 0;
return "BHF".Contains(c);
}

public override bool IsValueDefined(int currentAddress)
Expand Down Expand Up @@ -181,11 +176,10 @@ public bool IsValueDefined(int currentAddress)
/// <returns></returns>
public long GetValue(int currentAddress)
{
long previousAddress = -1L;
long followingAddress = -1L;
foreach (long refereeAddress in mReferee.Addresses)
{
previousAddress = followingAddress;
long previousAddress = followingAddress;
followingAddress = refereeAddress;

if (mDirection == Directions.Backwards && followingAddress >= currentAddress)
Expand Down
76 changes: 0 additions & 76 deletions MixAssembler/Symbol/SymbolBase.cs

This file was deleted.

78 changes: 0 additions & 78 deletions MixAssembler/Symbol/SymbolCollection.cs

This file was deleted.

13 changes: 0 additions & 13 deletions MixAssembler/Value/IValue.cs

This file was deleted.

12 changes: 0 additions & 12 deletions MixEmul/Components/INavigableWordEditor.cs

This file was deleted.

9 changes: 4 additions & 5 deletions MixEmul/Components/SourceAndFindingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using MixLib.Instruction;
using MixLib.Misc;
using System;
using System.ComponentModel;
using System.Windows.Forms;

namespace MixGui.Components
Expand Down Expand Up @@ -54,7 +53,7 @@ void InitializeComponent()
// mStatusStrip
//
this.mStatusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mToolStripStatusLabel});
this.mToolStripStatusLabel});
this.mStatusStrip.Location = new System.Drawing.Point(0, 383);
this.mStatusStrip.Name = "mStatusStrip";
this.mStatusStrip.Size = new System.Drawing.Size(568, 22);
Expand Down Expand Up @@ -111,9 +110,9 @@ void InitializeComponent()
//
// mFindingListView
//
this.mFindingListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.mFindingListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.mFindingListView.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.mFindingListView.Location = new System.Drawing.Point(0, 0);
this.mFindingListView.Name = "mFindingListView";
Expand Down
5 changes: 5 additions & 0 deletions MixEmul/Documentation/Changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ x: Bugfix

=========================================

0.4.7752.30280 (2021-03-23)
* Migrated to .NET 5.0
* Applied visual changes, of which enabling visual styles is the most noticeable
x Multiple small bugfixes, mainly in project/solution structure and builds

0.3.7512.22699
* Applied flat-style visual appearance throughout MixEmul
x Fixed regression in this change list
Expand Down
Loading

0 comments on commit 1e621ae

Please sign in to comment.