Skip to content

Commit

Permalink
Clean up namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Viir committed Oct 15, 2024
1 parent e57fd20 commit 2c7617c
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 29 deletions.
8 changes: 8 additions & 0 deletions implement/Pine.Core/PineVM/IPineVM.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Pine.Core.PineVM;

public interface IPineVM
{
Result<string, PineValue> EvaluateExpression(
Expression expression,
PineValue environment);
}
21 changes: 21 additions & 0 deletions implement/Pine.Core/PineVM/LockingPineVM.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace Pine.Core.PineVM;

public class LockingPineVM : IPineVM
{
private readonly IPineVM pineVM;

private readonly object pineVMLock = new();

public LockingPineVM(IPineVM pineVM)
{
this.pineVM = pineVM;
}

public Result<string, PineValue> EvaluateExpression(Expression expression, PineValue environment)
{
lock (pineVMLock)
{
return pineVM.EvaluateExpression(expression, environment);
}
}
}
4 changes: 2 additions & 2 deletions implement/pine/Elm/Platform/CommandLineApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public static CommandLineAppConfig ConfigFromDeclarationValue(PineValue runRootD
public static (PineValue, CommandLineAppEventResponse) Init(
CommandLineAppConfig config,
CommandLineAppInitEnvironment environment,
PineVM.IPineVM pineVM)
Core.PineVM.IPineVM pineVM)
{
var initRecord =
new ElmValue.ElmRecord(
Expand Down Expand Up @@ -225,7 +225,7 @@ public static (PineValue, CommandLineAppEventResponse)?
CommandLineAppConfig config,
ReadOnlyMemory<byte> input,
PineValue stateBefore,
PineVM.IPineVM pineVM)
Core.PineVM.IPineVM pineVM)
{
var subscriptionsValue =
ElmTime.ElmInteractive.ElmInteractiveEnvironment.ApplyFunction(
Expand Down
2 changes: 1 addition & 1 deletion implement/pine/ElmInteractive/ElmInteractive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ public static Result<string, PineValue> ParseElmModuleTextToPineValue(
.ToString()!;

var responseResultStructure =
System.Text.Json.JsonSerializer.Deserialize<Result<string, ElmInteractive.PineValueJson>>(
System.Text.Json.JsonSerializer.Deserialize<Result<string, PineValueJson>>(
responseJson,
compilerInterfaceJsonSerializerOptions)!;

Expand Down
2 changes: 1 addition & 1 deletion implement/pine/ElmInteractive/ElmInteractiveEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static Result<string, PineValue> ApplyFunctionInElmModule(
}

public static Result<string, PineValue> ApplyFunction(
IPineVM pineVM,
Pine.Core.PineVM.IPineVM pineVM,
FunctionRecord functionRecord,
IReadOnlyList<PineValue> arguments)
{
Expand Down
20 changes: 1 addition & 19 deletions implement/pine/ElmInteractive/InteractiveSessionPine.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Pine;
using Pine.Core;
using Pine.Core.PineVM;
using Pine.Elm;
using Pine.ElmInteractive;
using Pine.PineVM;
Expand Down Expand Up @@ -632,25 +633,6 @@ public static IReadOnlyDictionary<ExpressionUsageAnalysis, ExpressionUsageProfil
return pineExpressionsToOptimize;
}

public class LockingPineVM : IPineVM
{
private readonly IPineVM pineVM;

private readonly object pineVMLock = new();

public LockingPineVM(IPineVM pineVM)
{
this.pineVM = pineVM;
}

public Result<string, PineValue> EvaluateExpression(Expression expression, PineValue environment)
{
lock (pineVMLock)
{
return pineVM.EvaluateExpression(expression, environment);
}
}
}

public class PineVMWithPersistentCache : IPineVM
{
Expand Down
1 change: 1 addition & 0 deletions implement/pine/Pine/PineVM/DynamicPGOShare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading;
using System.Threading.Tasks;
using Pine.Core;
using Pine.Core.PineVM;

namespace Pine.PineVM;

Expand Down
7 changes: 1 addition & 6 deletions implement/pine/Pine/PineVM/PineVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
using System.Collections.Immutable;
using System.Linq;
using Pine.Core;
using Pine.Core.PineVM;

namespace Pine.PineVM;

public interface IPineVM
{
Result<string, PineValue> EvaluateExpression(
Expression expression,
PineValue environment);
}

public record struct EvalCacheEntryKey(
PineValue ExprValue,
Expand Down
1 change: 1 addition & 0 deletions implement/pine/Pine/PineVM/ProfilingPineVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Immutable;
using System.Linq;
using Pine.Core;
using Pine.Core.PineVM;
using ExpressionUsageRecord = System.Collections.Generic.Dictionary<Pine.Core.PineValue, Pine.PineVM.ExpressionEnvUsageRecord>;

namespace Pine.PineVM;
Expand Down
1 change: 1 addition & 0 deletions implement/test-elm-time/CompileElmCompilerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Pine;
using Pine.Core;
using Pine.Core.PineVM;
using Pine.Elm;
using Pine.ElmInteractive;
using Pine.PineVM;
Expand Down

0 comments on commit 2c7617c

Please sign in to comment.