Skip to content

Commit 1e621ae

Browse files
committed
General code and project cleanup
1 parent 3ee292d commit 1e621ae

22 files changed

Lines changed: 77 additions & 482 deletions

MixAssembler/Assembler.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@ public static InstructionInstanceBase[] Assemble(string[] sourceLines, out PreIn
5151

5252
list.Add(instructionInstance);
5353

54-
if (instructionInstance != null && instructionInstance.Instruction is LoaderInstruction)
54+
if (instructionInstance != null && instructionInstance.Instruction is LoaderInstruction loaderInstruction)
5555
{
56-
var loaderInstruction = (LoaderInstruction)instructionInstance.Instruction;
57-
5856
if (loaderInstruction.Operation == LoaderInstruction.Operations.SetLocationCounter)
5957
{
6058
status.LocationCounter = (int)((LoaderInstruction.Instance)instructionInstance).Value.LongValue;

MixAssembler/Instruction/MixInstructionParameters.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,14 @@ public static IInstructionParameters ParseAddressField(InstructionBase instructi
171171
return null;
172172
}
173173

174-
var index = IPartValue.ParseValue(addressField.Substring(indexCharIndex, sectionCharIndex - indexCharIndex), indexCharIndex, status);
174+
var index = IPartValue.ParseValue(addressField[indexCharIndex..sectionCharIndex], indexCharIndex, status);
175175
if (index == null)
176176
{
177177
status.ReportParsingError(indexCharIndex, sectionCharIndex - indexCharIndex, "unable to parse index");
178178
return null;
179179
}
180180

181-
var field = FPartValue.ParseValue(addressField.Substring(sectionCharIndex), sectionCharIndex, status);
181+
var field = FPartValue.ParseValue(addressField[sectionCharIndex..], sectionCharIndex, status);
182182
if (field == null)
183183
{
184184
status.ReportParsingError(sectionCharIndex, addressField.Length - sectionCharIndex, "unable to parse field");

MixAssembler/MixAssembler.csproj

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>net5.0-windows</TargetFramework>
44
<OutputType>Library</OutputType>
@@ -16,11 +16,6 @@
1616
<ItemGroup>
1717
<Content Include="MixFormIcon.ico" />
1818
</ItemGroup>
19-
<ItemGroup>
20-
<Compile Remove="Symbol\SymbolBase.cs" />
21-
<Compile Remove="Symbol\SymbolCollection.cs" />
22-
<Compile Remove="Value\IValue.cs" />
23-
</ItemGroup>
2419
<ItemGroup>
2520
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.2.212405">
2621
<PrivateAssets>all</PrivateAssets>

MixAssembler/Parser.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public static class Parser
2424
const int addressFieldIndex = 2;
2525
const int commentFieldIndex = 3;
2626

27-
static readonly InstructionSet mInstructionSet = new InstructionSet();
28-
static readonly LoaderInstructions mLoaderInstructions = new LoaderInstructions();
27+
static readonly InstructionSet mInstructionSet = new();
28+
static readonly LoaderInstructions mLoaderInstructions = new();
2929

3030
static bool IsCommentLine(string sourceLine)
3131
{
@@ -283,7 +283,7 @@ static string[] SplitLine(string sourceLine)
283283
var opFieldEnd = FindFirstWhiteSpace(sourceLine, opFieldStart);
284284
if (opFieldEnd == -1)
285285
{
286-
return new string[] { sourceLine.Substring(0, searchBeyondIndex), sourceLine.Substring(opFieldStart), "", "" };
286+
return new string[] { sourceLine.Substring(0, searchBeyondIndex), sourceLine[opFieldStart..], "", "" };
287287
}
288288

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

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

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

325-
return new string[] { sourceLine.Substring(0, searchBeyondIndex), sourceLine.Substring(opFieldStart, opFieldLength), sourceLine.Substring(addressFieldStart, addressFieldLength), sourceLine.Substring(commentFieldStart) };
325+
return new string[] { sourceLine.Substring(0, searchBeyondIndex), sourceLine.Substring(opFieldStart, opFieldLength), sourceLine.Substring(addressFieldStart, addressFieldLength), sourceLine[commentFieldStart..] };
326326
}
327327
}
328328
}

MixAssembler/Properties/launchSettings.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88
}
99
},
1010
"profiles": {
11-
"IIS Express": {
12-
"commandName": "IISExpress",
13-
"launchBrowser": true,
14-
"environmentVariables": {
15-
"ASPNETCORE_ENVIRONMENT": "Development"
16-
}
17-
},
1811
"MixAssembler": {
1912
"commandName": "Project",
2013
"launchBrowser": true,

MixAssembler/Symbol/LiteralConstantSymbol.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ static string GetName(Word.Signs literalSign, long literalMagnitude, int count)
5555

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

63-
var expressionValue = WValue.ParseValue(text.Substring(1, text.Length - 2), sectionCharIndex + 1, status);
63+
var expressionValue = WValue.ParseValue(text[1..^1], sectionCharIndex + 1, status);
6464
if (expressionValue == null)
6565
{
6666
return null;

MixAssembler/Symbol/LocalSymbol.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ public override void SetValue(long value)
3131
mAddresses.Add(value);
3232
}
3333

34-
static bool IsBackwardReferenceChar(char c)
35-
{
36-
return c == 'B';
37-
}
38-
3934
static bool IsDefinitionChar(char c)
4035
{
4136
return c == 'H';
@@ -53,7 +48,7 @@ static bool IsLocalSymbol(string text)
5348

5449
static bool IsLocalSymbolChar(char c)
5550
{
56-
return "BHF".IndexOf(c) >= 0;
51+
return "BHF".Contains(c);
5752
}
5853

5954
public override bool IsValueDefined(int currentAddress)
@@ -181,11 +176,10 @@ public bool IsValueDefined(int currentAddress)
181176
/// <returns></returns>
182177
public long GetValue(int currentAddress)
183178
{
184-
long previousAddress = -1L;
185179
long followingAddress = -1L;
186180
foreach (long refereeAddress in mReferee.Addresses)
187181
{
188-
previousAddress = followingAddress;
182+
long previousAddress = followingAddress;
189183
followingAddress = refereeAddress;
190184

191185
if (mDirection == Directions.Backwards && followingAddress >= currentAddress)

MixAssembler/Symbol/SymbolBase.cs

Lines changed: 0 additions & 76 deletions
This file was deleted.

MixAssembler/Symbol/SymbolCollection.cs

Lines changed: 0 additions & 78 deletions
This file was deleted.

MixAssembler/Value/IValue.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)