Skip to content

Commit 395fe0a

Browse files
authored
Renamed KaleidoscopeReadEvaluatePrintLoopBase -> ReadEvaluatePrintLoopBase (#333)
* No point in duplicating the language name as it is already part of the FQN via the namesace
1 parent 70bb2ee commit 395fe0a

9 files changed

Lines changed: 59 additions & 24 deletions

File tree

src/Samples/Kaleidoscope/Chapter2/ReplEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace Kaleidoscope.Chapter2
1212
{
1313
internal class ReplEngine
14-
: KaleidoscopeReadEvaluatePrintLoopBase<IAstNode>
14+
: ReadEvaluatePrintLoopBase<IAstNode>
1515
{
1616
public ReplEngine( )
1717
: base( LanguageLevel.MutableVariables )

src/Samples/Kaleidoscope/Chapter3.5/ReplEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Kaleidoscope.Chapter3_5
1313
{
1414
internal class ReplEngine
15-
: KaleidoscopeReadEvaluatePrintLoopBase<Value>
15+
: ReadEvaluatePrintLoopBase<Value>
1616
{
1717
public ReplEngine( )
1818
: base( LanguageLevel.SimpleExpressions )

src/Samples/Kaleidoscope/Chapter3/ReplEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Kaleidoscope.Chapter3
1313
{
1414
internal class ReplEngine
15-
: KaleidoscopeReadEvaluatePrintLoopBase<Value>
15+
: ReadEvaluatePrintLoopBase<Value>
1616
{
1717
public ReplEngine( )
1818
: base( LanguageLevel.SimpleExpressions )

src/Samples/Kaleidoscope/Chapter4/ReplEngine.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Kaleidoscope.Chapter4
1313
{
1414
internal class ReplEngine
15-
: KaleidoscopeReadEvaluatePrintLoopBase<Value>
15+
: ReadEvaluatePrintLoopBase<Value>
1616
{
1717
public ReplEngine( )
1818
: base( LanguageLevel.SimpleExpressions )
@@ -41,8 +41,15 @@ public override void ProcessResults( Value resultValue )
4141

4242
case Function function:
4343
#if SAVE_LLVM_IR
44-
string safeFileName = Utilities.GetSafeFileName( function.Name );
45-
_ = function.ParentModule.WriteToTextFile( System.IO.Path.ChangeExtension( safeFileName, "ll" ), out string _ );
44+
if(function.Name is not null)
45+
{
46+
string safeFileName = Utilities.GetSafeFileName( function.Name );
47+
string finalPath = System.IO.Path.ChangeExtension( safeFileName, "ll" );
48+
if(!function.ParentModule.WriteToTextFile( finalPath, out string errMessage ))
49+
{
50+
Console.Error.WriteLine($"ERROR saving output file '{finalPath}': {errMessage}");
51+
}
52+
}
4653
#endif
4754
break;
4855

src/Samples/Kaleidoscope/Chapter5/ReplEngine.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Kaleidoscope.Chapter5
1313
{
1414
internal class ReplEngine
15-
: KaleidoscopeReadEvaluatePrintLoopBase<Value>
15+
: ReadEvaluatePrintLoopBase<Value>
1616
{
1717
public ReplEngine( )
1818
: base( LanguageLevel.ControlFlow )
@@ -41,8 +41,15 @@ public override void ProcessResults( Value resultValue )
4141

4242
case Function function:
4343
#if SAVE_LLVM_IR
44-
string safeFileName = Utilities.GetSafeFileName( function.Name );
45-
_ = function.ParentModule.WriteToTextFile( System.IO.Path.ChangeExtension( safeFileName, "ll" ), out string _ );
44+
if(function.Name is not null)
45+
{
46+
string safeFileName = Utilities.GetSafeFileName( function.Name );
47+
string finalPath = System.IO.Path.ChangeExtension( safeFileName, "ll" );
48+
if(!function.ParentModule.WriteToTextFile( finalPath, out string errMessage ))
49+
{
50+
Console.Error.WriteLine($"ERROR saving output file '{finalPath}': {errMessage}");
51+
}
52+
}
4653
#endif
4754
break;
4855

src/Samples/Kaleidoscope/Chapter6/ReplEngine.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Kaleidoscope.Chapter6
1313
{
1414
internal class ReplEngine
15-
: KaleidoscopeReadEvaluatePrintLoopBase<Value>
15+
: ReadEvaluatePrintLoopBase<Value>
1616
{
1717
public ReplEngine( )
1818
: base( LanguageLevel.UserDefinedOperators )
@@ -41,8 +41,15 @@ public override void ProcessResults( Value resultValue )
4141

4242
case Function function:
4343
#if SAVE_LLVM_IR
44-
string safeFileName = Utilities.GetSafeFileName( function.Name );
45-
_ = function.ParentModule.WriteToTextFile( System.IO.Path.ChangeExtension( safeFileName, "ll" ), out string _ );
44+
if(function.Name is not null)
45+
{
46+
string safeFileName = Utilities.GetSafeFileName( function.Name );
47+
string finalPath = System.IO.Path.ChangeExtension( safeFileName, "ll" );
48+
if(!function.ParentModule.WriteToTextFile( finalPath, out string errMessage ))
49+
{
50+
Console.Error.WriteLine($"ERROR saving output file '{finalPath}': {errMessage}");
51+
}
52+
}
4653
#endif
4754
break;
4855

src/Samples/Kaleidoscope/Chapter7.1/ReplEngine.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Kaleidoscope.Chapter71
1313
{
1414
internal class ReplEngine
15-
: KaleidoscopeReadEvaluatePrintLoopBase<Value>
15+
: ReadEvaluatePrintLoopBase<Value>
1616
{
1717
public ReplEngine( )
1818
: base( LanguageLevel.MutableVariables )
@@ -41,8 +41,15 @@ public override void ProcessResults( Value resultValue )
4141

4242
case Function function:
4343
#if SAVE_LLVM_IR
44-
string safeFileName = Utilities.GetSafeFileName( function.Name );
45-
_ = function.ParentModule.WriteToTextFile( System.IO.Path.ChangeExtension( safeFileName, "ll" ), out string _ );
44+
if(function.Name is not null)
45+
{
46+
string safeFileName = Utilities.GetSafeFileName( function.Name );
47+
string finalPath = System.IO.Path.ChangeExtension( safeFileName, "ll" );
48+
if(!function.ParentModule.WriteToTextFile( finalPath, out string errMessage ))
49+
{
50+
Console.Error.WriteLine($"ERROR saving output file '{finalPath}': {errMessage}");
51+
}
52+
}
4653
#endif
4754
break;
4855

src/Samples/Kaleidoscope/Chapter7/ReplEngine.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Kaleidoscope.Chapter7
1313
{
1414
internal class ReplEngine
15-
: KaleidoscopeReadEvaluatePrintLoopBase<Value>
15+
: ReadEvaluatePrintLoopBase<Value>
1616
{
1717
public ReplEngine( )
1818
: base( LanguageLevel.MutableVariables )
@@ -41,8 +41,15 @@ public override void ProcessResults( Value resultValue )
4141

4242
case Function function:
4343
#if SAVE_LLVM_IR
44-
string safeFileName = Utilities.GetSafeFileName( function.Name );
45-
_ = function.ParentModule.WriteToTextFile( System.IO.Path.ChangeExtension( safeFileName, "ll" ), out string _ );
44+
if(function.Name is not null)
45+
{
46+
string safeFileName = Utilities.GetSafeFileName( function.Name );
47+
string finalPath = System.IO.Path.ChangeExtension( safeFileName, "ll" );
48+
if(!function.ParentModule.WriteToTextFile( finalPath, out string errMessage ))
49+
{
50+
Console.Error.WriteLine($"ERROR saving output file '{finalPath}': {errMessage}");
51+
}
52+
}
4653
#endif
4754
break;
4855

src/Samples/Kaleidoscope/Kaleidoscope.Runtime/KaleidoscopeReadEvaluatePrintLoopBase.cs renamed to src/Samples/Kaleidoscope/Kaleidoscope.Runtime/ReadEvaluatePrintLoopBase.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ namespace Kaleidoscope.Runtime
1515
{
1616
/// <summary>REPL Loop implementation for the Kaleidoscope language</summary>
1717
/// <typeparam name="T">Type of values produced by the evaluation stage</typeparam>
18-
public abstract class KaleidoscopeReadEvaluatePrintLoopBase<T>
19-
: REPLBase<T>
18+
public abstract class ReadEvaluatePrintLoopBase<T>
19+
: Ubiquity.NET.Runtime.Utils.REPLBase<T>
2020
{
2121
/// <summary>Gets the Kaleidoscope language level for this instance</summary>
2222
public LanguageLevel LanguageFeatureLevel { get; }
@@ -64,23 +64,23 @@ public sealed override void ShowPrompt( ReadyState state )
6464
await Run( input, parser, generator, cancelToken );
6565
}
6666

67-
/// <summary>Initializes a new instance of the <see cref="KaleidoscopeReadEvaluatePrintLoopBase{T}"/> class.</summary>
67+
/// <summary>Initializes a new instance of the <see cref="ReadEvaluatePrintLoopBase{T}"/> class.</summary>
6868
/// <param name="level">Language level supported by this REPL instance</param>
6969
/// <remarks>
7070
/// This is protected to prevent use by anything other than a derived type.
7171
/// </remarks>
72-
protected KaleidoscopeReadEvaluatePrintLoopBase( LanguageLevel level )
72+
protected ReadEvaluatePrintLoopBase( LanguageLevel level )
7373
: this(level, new ParseErrorDiagnosticAdapter(new ColoredConsoleReporter(), "KLS"))
7474
{
7575
}
7676

77-
/// <summary>Initializes a new instance of the <see cref="KaleidoscopeReadEvaluatePrintLoopBase{T}"/> class.</summary>
77+
/// <summary>Initializes a new instance of the <see cref="ReadEvaluatePrintLoopBase{T}"/> class.</summary>
7878
/// <param name="level">Language level supported by this REPL instance</param>
7979
/// <param name="logger">Logger to report any issues parsing the input.</param>
8080
/// <remarks>
8181
/// This is protected to prevent use by anything other than a derived type.
8282
/// </remarks>
83-
protected KaleidoscopeReadEvaluatePrintLoopBase( LanguageLevel level, IParseErrorReporter logger )
83+
protected ReadEvaluatePrintLoopBase( LanguageLevel level, IParseErrorReporter logger )
8484
: base( logger )
8585
{
8686
LanguageFeatureLevel = level;

0 commit comments

Comments
 (0)