Skip to content

Commit

Permalink
Merge pull request #14 from chrisjbreisch/feature/error-handling
Browse files Browse the repository at this point in the history
interface cleanup
  • Loading branch information
chrisjbreisch authored Jun 20, 2022
2 parents 4e0de0a + 8c7dcb8 commit 4ada61f
Show file tree
Hide file tree
Showing 34 changed files with 150 additions and 127 deletions.
8 changes: 8 additions & 0 deletions Trs80.Level1Basic.CommandModels/ITrs80DataModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Trs80.Level1Basic.HostMachine;

namespace Trs80.Level1Basic.CommandModels;

public interface ITrs80DataModel
{
HostFont OriginalHostFont { get; set; }
}
5 changes: 0 additions & 5 deletions Trs80.Level1Basic.CommandModels/Trs80DataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

namespace Trs80.Level1Basic.CommandModels;

public interface ITrs80DataModel
{
HostFont OriginalHostFont { get; set; }
}

public class Trs80DataModel : ITrs80DataModel
{
public HostFont OriginalHostFont { get; set; } = new();
Expand Down
6 changes: 0 additions & 6 deletions Trs80.Level1Basic.Common/AppSettings.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@

namespace Trs80.Level1Basic.Common;

public interface IAppSettings
{
string FontName { get; set; }
short FontSize { get; set; }
}

public sealed class AppSettings : IAppSettings
{
public string FontName { get; set; }
Expand Down
7 changes: 7 additions & 0 deletions Trs80.Level1Basic.Common/IAppSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Trs80.Level1Basic.Common;

public interface IAppSettings
{
string FontName { get; set; }
short FontSize { get; set; }
}

This file was deleted.

This file was deleted.

16 changes: 16 additions & 0 deletions Trs80.Level1Basic.HostMachine/FontInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Runtime.InteropServices;

namespace Trs80.Level1Basic.HostMachine;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FontInfo
{
public int cbSize;
public int FontIndex;
public short FontWidth;
public short FontSize;
public int FontFamily;
public int FontWeight;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string FontName;
}
24 changes: 0 additions & 24 deletions Trs80.Level1Basic.HostMachine/Host.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,6 @@

namespace Trs80.Level1Basic.HostMachine;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FontInfo
{
public int cbSize;
public int FontIndex;
public short FontWidth;
public short FontSize;
public int FontFamily;
public int FontWeight;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string FontName;
}

[StructLayout(LayoutKind.Sequential)]
public struct Rect
{
public int Left; // x position of upper-left corner
public int Top; // y position of upper-left corner
public int Right; // x position of lower-right corner
public int Bottom; // y position of lower-right corner
}



public class Host : IHost, IDisposable
{
// https://www.pinvoke.net/default.aspx/user32/FindWindow.html
Expand Down
12 changes: 12 additions & 0 deletions Trs80.Level1Basic.HostMachine/Rect.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Runtime.InteropServices;

namespace Trs80.Level1Basic.HostMachine;

[StructLayout(LayoutKind.Sequential)]
public struct Rect
{
public int Left; // x position of upper-left corner
public int Top; // y position of upper-left corner
public int Right; // x position of lower-right corner
public int Bottom; // y position of lower-right corner
}
4 changes: 3 additions & 1 deletion Trs80.Level1Basic.VirtualMachine/Interpreter/Interpreter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,8 @@ private void ExecuteGosub(IStatement jumpToStatement, IStatement resumeStatement

public Void VisitPrintStatement(Print statement)
{
if (statement.AtPosition != null) PrintAt(statement.AtPosition);
if (statement.AtPosition != null)
PrintAt(statement.AtPosition);

if (statement.Expressions is { Count: > 0 })
foreach (Expression expression in statement.Expressions)
Expand All @@ -661,6 +662,7 @@ public Void VisitPrintStatement(Print statement)
_trs80.WriteLine();
_machine.CursorX = 0;
_machine.CursorY++;

return null!;
}

Expand Down
6 changes: 0 additions & 6 deletions Trs80.Level1Basic.VirtualMachine/Machine/Callable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@

namespace Trs80.Level1Basic.VirtualMachine.Machine;

public interface ICallable
{
int Arity { get; set; }
Func<ITrs80, List<dynamic>, dynamic> Call { get; set; }
}

public class Callable : ICallable
{
public int Arity { get; set; }
Expand Down
10 changes: 10 additions & 0 deletions Trs80.Level1Basic.VirtualMachine/Machine/ICallable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;

namespace Trs80.Level1Basic.VirtualMachine.Machine;

public interface ICallable
{
int Arity { get; set; }
Func<ITrs80, List<dynamic>, dynamic> Call { get; set; }
}
8 changes: 8 additions & 0 deletions Trs80.Level1Basic.VirtualMachine/Machine/INativeFunctions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.Collections.Generic;

namespace Trs80.Level1Basic.VirtualMachine.Machine;

public interface INativeFunctions
{
List<Callable> Get(string name);
}
5 changes: 0 additions & 5 deletions Trs80.Level1Basic.VirtualMachine/Machine/NativeFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@

namespace Trs80.Level1Basic.VirtualMachine.Machine;

public interface INativeFunctions
{
List<Callable> Get(string name);
}

[SuppressMessage("ReSharper", "UnusedParameter.Local")]
public class NativeFunctions : INativeFunctions
{
Expand Down
10 changes: 10 additions & 0 deletions Trs80.Level1Basic.VirtualMachine/Parser/IParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;
using Trs80.Level1Basic.VirtualMachine.Parser.Statements;
using Trs80.Level1Basic.VirtualMachine.Scanner;

namespace Trs80.Level1Basic.VirtualMachine.Parser;

public interface IParser
{
IStatement Parse(List<Token> tokens);
}
5 changes: 0 additions & 5 deletions Trs80.Level1Basic.VirtualMachine/Parser/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@

namespace Trs80.Level1Basic.VirtualMachine.Parser;

public interface IParser
{
IStatement Parse(List<Token> tokens);
}

public class Parser : IParser
{
private List<Token> _tokens;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements;

public interface IListStatementDecorator : IStatement
{
public Type BaseType();
public IStatement UnDecorate();

IStatement Enclosing { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

namespace Trs80.Level1Basic.VirtualMachine.Parser.Statements;

public interface IListStatementDecorator : IStatement
{
public Type BaseType();
public IStatement UnDecorate();

IStatement Enclosing { get; set; }
}

public class ListStatementDecorator : IListStatementDecorator
{
private readonly IStatement _statement;
Expand Down
9 changes: 9 additions & 0 deletions Trs80.Level1Basic.VirtualMachine/Scanner/IScanner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;
using Trs80.Level1Basic.Common;

namespace Trs80.Level1Basic.VirtualMachine.Scanner;

public interface IScanner
{
List<Token> ScanTokens(SourceLine source);
}
5 changes: 0 additions & 5 deletions Trs80.Level1Basic.VirtualMachine/Scanner/Scanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@

namespace Trs80.Level1Basic.VirtualMachine.Scanner;

public interface IScanner
{
List<Token> ScanTokens(SourceLine source);
}

public class Scanner : IScanner
{
private string _source;
Expand Down
11 changes: 11 additions & 0 deletions Trs80.Level1Basic.Workflow/IInputStep.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Trs80.Level1Basic.Common;
using WorkflowCore.Interface;

namespace Trs80.Level1Basic.Workflow;

public interface IInputStep : IStepBody
{
bool WritePrompt { get; set; }
bool Done { get; set; }
SourceLine SourceLine { get; set; }
}
9 changes: 9 additions & 0 deletions Trs80.Level1Basic.Workflow/IInterpretStep.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Trs80.Level1Basic.VirtualMachine.Parser.Statements;
using WorkflowCore.Interface;

namespace Trs80.Level1Basic.Workflow;

public interface IInterpretStep : IStepBody
{
Statement Statement { get; set; }
}
11 changes: 11 additions & 0 deletions Trs80.Level1Basic.Workflow/IParseStep.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Trs80.Level1Basic.VirtualMachine.Parser.Statements;
using Trs80.Level1Basic.VirtualMachine.Scanner;
using WorkflowCore.Interface;

namespace Trs80.Level1Basic.Workflow;

public interface IParseStep : IStepBody
{
List<Token> Tokens { get; set; }
IStatement Statement { get; set; }
}
11 changes: 11 additions & 0 deletions Trs80.Level1Basic.Workflow/IScanStep.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Trs80.Level1Basic.Common;
using Trs80.Level1Basic.VirtualMachine.Scanner;
using WorkflowCore.Interface;

namespace Trs80.Level1Basic.Workflow;

public interface IScanStep : IStepBody
{
SourceLine SourceLine { get; set; }
List<Token> Tokens { get; set; }
}
7 changes: 7 additions & 0 deletions Trs80.Level1Basic.Workflow/ISetupConsoleStep.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using WorkflowCore.Interface;

namespace Trs80.Level1Basic.Workflow;

public interface ISetupConsoleStep : IStepBody
{
}
7 changes: 7 additions & 0 deletions Trs80.Level1Basic.Workflow/IShutdownConsoleStep.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using WorkflowCore.Interface;

namespace Trs80.Level1Basic.Workflow;

public interface IShutdownConsoleStep : IStepBody
{
}
7 changes: 0 additions & 7 deletions Trs80.Level1Basic.Workflow/InputStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@

namespace Trs80.Level1Basic.Workflow;

public interface IInputStep : IStepBody
{
bool WritePrompt { get; set; }
bool Done { get; set; }
SourceLine SourceLine { get; set; }
}

public class InputStep : StepBody, IInputStep
{
private readonly ICommand<InputModel> _command;
Expand Down
5 changes: 0 additions & 5 deletions Trs80.Level1Basic.Workflow/InterpretStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@

namespace Trs80.Level1Basic.Workflow;

public interface IInterpretStep : IStepBody
{
Statement Statement { get; set; }
}

public class InterpretStep : StepBody, IInterpretStep
{
private readonly ICommand<InterpretModel> _command;
Expand Down
6 changes: 0 additions & 6 deletions Trs80.Level1Basic.Workflow/ParseStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@

namespace Trs80.Level1Basic.Workflow;

public interface IParseStep : IStepBody
{
List<Token> Tokens { get; set; }
IStatement Statement { get; set; }
}

public class ParseStep : StepBody, IParseStep
{
private readonly ICommand<ParseModel> _command;
Expand Down
6 changes: 0 additions & 6 deletions Trs80.Level1Basic.Workflow/ScanStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@

namespace Trs80.Level1Basic.Workflow;

public interface IScanStep : IStepBody
{
SourceLine SourceLine { get; set; }
List<Token> Tokens { get; set; }
}

public class ScanStep : StepBody, IScanStep
{
private readonly ICommand<ScanModel> _command;
Expand Down
Loading

0 comments on commit 4ada61f

Please sign in to comment.