Skip to content

Commit

Permalink
CodeCache cleared after Eval
Browse files Browse the repository at this point in the history
  • Loading branch information
ackava committed Aug 31, 2024
1 parent c032eb4 commit cb39b89
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion Positron/Platforms/Android/Engine/JSContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;
using YantraJS.Core;
using YantraJS.Core.Clr;
using YantraJS.Emit;
using ErrorEventArgs = NeuroSpeech.Positron.ErrorEventArgs;

namespace YantraJS.Core;
Expand Down Expand Up @@ -86,7 +87,18 @@ public IJSValue CreateSymbol(string name)

public IJSValue Evaluate(string script, string location = null)
{
return CoreScript.Evaluate(script, location);
using var s = this.SetTemporaryCodeCache();
return this.Eval(script, location);
}

private IDisposable SetTemporaryCodeCache()
{
var oldCodeCache = this.CodeCache;
this.CodeCache = new DictionaryCodeCache();
return new DisposableAction(() =>
{
this.CodeCache = oldCodeCache;
});
}

public void RunOnUIThread(Func<Task> task)
Expand Down

0 comments on commit cb39b89

Please sign in to comment.