Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Samples/Kaleidoscope/Chapter2/ReplEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Kaleidoscope.Chapter2
{
internal class ReplEngine
: KaleidoscopeReadEvaluatePrintLoopBase<IAstNode>
: ReadEvaluatePrintLoopBase<IAstNode>
{
public ReplEngine( )
: base( LanguageLevel.MutableVariables )
Expand Down
2 changes: 1 addition & 1 deletion src/Samples/Kaleidoscope/Chapter3.5/ReplEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Kaleidoscope.Chapter3_5
{
internal class ReplEngine
: KaleidoscopeReadEvaluatePrintLoopBase<Value>
: ReadEvaluatePrintLoopBase<Value>
{
public ReplEngine( )
: base( LanguageLevel.SimpleExpressions )
Expand Down
2 changes: 1 addition & 1 deletion src/Samples/Kaleidoscope/Chapter3/ReplEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Kaleidoscope.Chapter3
{
internal class ReplEngine
: KaleidoscopeReadEvaluatePrintLoopBase<Value>
: ReadEvaluatePrintLoopBase<Value>
{
public ReplEngine( )
: base( LanguageLevel.SimpleExpressions )
Expand Down
13 changes: 10 additions & 3 deletions src/Samples/Kaleidoscope/Chapter4/ReplEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Kaleidoscope.Chapter4
{
internal class ReplEngine
: KaleidoscopeReadEvaluatePrintLoopBase<Value>
: ReadEvaluatePrintLoopBase<Value>
{
public ReplEngine( )
: base( LanguageLevel.SimpleExpressions )
Expand Down Expand Up @@ -41,8 +41,15 @@ public override void ProcessResults( Value resultValue )

case Function function:
#if SAVE_LLVM_IR
string safeFileName = Utilities.GetSafeFileName( function.Name );
_ = function.ParentModule.WriteToTextFile( System.IO.Path.ChangeExtension( safeFileName, "ll" ), out string _ );
if(function.Name is not null)
{
string safeFileName = Utilities.GetSafeFileName( function.Name );
string finalPath = System.IO.Path.ChangeExtension( safeFileName, "ll" );
if(!function.ParentModule.WriteToTextFile( finalPath, out string errMessage ))
{
Console.Error.WriteLine($"ERROR saving output file '{finalPath}': {errMessage}");
}
}
#endif
break;

Expand Down
13 changes: 10 additions & 3 deletions src/Samples/Kaleidoscope/Chapter5/ReplEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Kaleidoscope.Chapter5
{
internal class ReplEngine
: KaleidoscopeReadEvaluatePrintLoopBase<Value>
: ReadEvaluatePrintLoopBase<Value>
{
public ReplEngine( )
: base( LanguageLevel.ControlFlow )
Expand Down Expand Up @@ -41,8 +41,15 @@ public override void ProcessResults( Value resultValue )

case Function function:
#if SAVE_LLVM_IR
string safeFileName = Utilities.GetSafeFileName( function.Name );
_ = function.ParentModule.WriteToTextFile( System.IO.Path.ChangeExtension( safeFileName, "ll" ), out string _ );
if(function.Name is not null)
{
string safeFileName = Utilities.GetSafeFileName( function.Name );
string finalPath = System.IO.Path.ChangeExtension( safeFileName, "ll" );
if(!function.ParentModule.WriteToTextFile( finalPath, out string errMessage ))
{
Console.Error.WriteLine($"ERROR saving output file '{finalPath}': {errMessage}");
}
}
#endif
break;

Expand Down
13 changes: 10 additions & 3 deletions src/Samples/Kaleidoscope/Chapter6/ReplEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Kaleidoscope.Chapter6
{
internal class ReplEngine
: KaleidoscopeReadEvaluatePrintLoopBase<Value>
: ReadEvaluatePrintLoopBase<Value>
{
public ReplEngine( )
: base( LanguageLevel.UserDefinedOperators )
Expand Down Expand Up @@ -41,8 +41,15 @@ public override void ProcessResults( Value resultValue )

case Function function:
#if SAVE_LLVM_IR
string safeFileName = Utilities.GetSafeFileName( function.Name );
_ = function.ParentModule.WriteToTextFile( System.IO.Path.ChangeExtension( safeFileName, "ll" ), out string _ );
if(function.Name is not null)
{
string safeFileName = Utilities.GetSafeFileName( function.Name );
string finalPath = System.IO.Path.ChangeExtension( safeFileName, "ll" );
if(!function.ParentModule.WriteToTextFile( finalPath, out string errMessage ))
{
Console.Error.WriteLine($"ERROR saving output file '{finalPath}': {errMessage}");
}
}
#endif
break;

Expand Down
13 changes: 10 additions & 3 deletions src/Samples/Kaleidoscope/Chapter7.1/ReplEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Kaleidoscope.Chapter71
{
internal class ReplEngine
: KaleidoscopeReadEvaluatePrintLoopBase<Value>
: ReadEvaluatePrintLoopBase<Value>
{
public ReplEngine( )
: base( LanguageLevel.MutableVariables )
Expand Down Expand Up @@ -41,8 +41,15 @@ public override void ProcessResults( Value resultValue )

case Function function:
#if SAVE_LLVM_IR
string safeFileName = Utilities.GetSafeFileName( function.Name );
_ = function.ParentModule.WriteToTextFile( System.IO.Path.ChangeExtension( safeFileName, "ll" ), out string _ );
if(function.Name is not null)
{
string safeFileName = Utilities.GetSafeFileName( function.Name );
string finalPath = System.IO.Path.ChangeExtension( safeFileName, "ll" );
if(!function.ParentModule.WriteToTextFile( finalPath, out string errMessage ))
{
Console.Error.WriteLine($"ERROR saving output file '{finalPath}': {errMessage}");
}
}
#endif
break;

Expand Down
13 changes: 10 additions & 3 deletions src/Samples/Kaleidoscope/Chapter7/ReplEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Kaleidoscope.Chapter7
{
internal class ReplEngine
: KaleidoscopeReadEvaluatePrintLoopBase<Value>
: ReadEvaluatePrintLoopBase<Value>
{
public ReplEngine( )
: base( LanguageLevel.MutableVariables )
Expand Down Expand Up @@ -41,8 +41,15 @@ public override void ProcessResults( Value resultValue )

case Function function:
#if SAVE_LLVM_IR
string safeFileName = Utilities.GetSafeFileName( function.Name );
_ = function.ParentModule.WriteToTextFile( System.IO.Path.ChangeExtension( safeFileName, "ll" ), out string _ );
if(function.Name is not null)
{
string safeFileName = Utilities.GetSafeFileName( function.Name );
string finalPath = System.IO.Path.ChangeExtension( safeFileName, "ll" );
if(!function.ParentModule.WriteToTextFile( finalPath, out string errMessage ))
{
Console.Error.WriteLine($"ERROR saving output file '{finalPath}': {errMessage}");
}
}
#endif
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ namespace Kaleidoscope.Runtime
{
/// <summary>REPL Loop implementation for the Kaleidoscope language</summary>
/// <typeparam name="T">Type of values produced by the evaluation stage</typeparam>
public abstract class KaleidoscopeReadEvaluatePrintLoopBase<T>
: REPLBase<T>
public abstract class ReadEvaluatePrintLoopBase<T>
: Ubiquity.NET.Runtime.Utils.REPLBase<T>
{
/// <summary>Gets the Kaleidoscope language level for this instance</summary>
public LanguageLevel LanguageFeatureLevel { get; }
Expand Down Expand Up @@ -64,23 +64,23 @@ public sealed override void ShowPrompt( ReadyState state )
await Run( input, parser, generator, cancelToken );
}

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

/// <summary>Initializes a new instance of the <see cref="KaleidoscopeReadEvaluatePrintLoopBase{T}"/> class.</summary>
/// <summary>Initializes a new instance of the <see cref="ReadEvaluatePrintLoopBase{T}"/> class.</summary>
/// <param name="level">Language level supported by this REPL instance</param>
/// <param name="logger">Logger to report any issues parsing the input.</param>
/// <remarks>
/// This is protected to prevent use by anything other than a derived type.
/// </remarks>
protected KaleidoscopeReadEvaluatePrintLoopBase( LanguageLevel level, IParseErrorReporter logger )
protected ReadEvaluatePrintLoopBase( LanguageLevel level, IParseErrorReporter logger )
: base( logger )
{
LanguageFeatureLevel = level;
Expand Down
Loading