Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
lock9 committed Mar 1, 2019
1 parent f3660c1 commit 8520346
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Neo-Debugger-Core-UnitTests/InvocationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void TestPythonCompiler()
var fullFilePath = Path.Combine(path, "NEP5.py");
var sourceCode = File.ReadAllText(fullFilePath);
Assert.NotNull(sourceCode);
var compiled = compiler.CompileContract(sourceCode, fullFilePath, Neo.Debugger.Core.Data.SourceLanguage.Python, "/Users/ricardmprado/Workspace/neo-boa/");
var compiled = compiler.CompileContract(sourceCode, fullFilePath, Neo.Debugger.Core.Data.SourceLanguage.Python);
Assert.IsTrue(compiled);
}

Expand Down
21 changes: 10 additions & 11 deletions Neo-Debugger-Core/Utils/NeonCompiler.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System;
using System.Diagnostics;
using System;
using System.IO;
using System.Linq;
using Neo.Compiler;
using Neo.Debugger.Core.Data;
using Neo.Debugger.Core.Models;
using Neo.Debugger.Core.Utils;
using Neo.DebuggerCompiler;
using Neo_Boa_Proxy_Lib;

namespace NeoDebuggerCore.Utils
Expand All @@ -16,7 +13,7 @@ public abstract class NeonCompiler : ILogger
internal DebuggerSettings _settings;
public event CompilerLogEventHandler SendToLog;
public delegate void CompilerLogEventHandler(object sender, CompilerLogEventArgs e);
public abstract string PythonCompilerExecutableName();
public abstract string Python3();

public NeonCompiler(DebuggerSettings settings)
{
Expand Down Expand Up @@ -59,14 +56,16 @@ public bool CompileCSharpContract(string sourceCode, string outputFilePath)
return true;
}

public bool CompilePythonContract(string sourceCode, string outputFilePath, string compilerPath = null)
public bool CompilePythonContract(string sourceCode, string outputFilePath)
{
if (string.IsNullOrEmpty(outputFilePath))
throw new ArgumentNullException(nameof(outputFilePath));

File.WriteAllText(outputFilePath, sourceCode);

if (PythonCompilerProxy.Execute(outputFilePath, PythonCompilerExecutableName(), (m) => { SendToLog?.Invoke(this, new CompilerLogEventArgs() { Message = m }); }, compilerPath))
if (PythonCompilerProxy.Execute(outputFilePath,
Python3(),
(m) => { SendToLog?.Invoke(this, new CompilerLogEventArgs() { Message = m }); }))
{
SendToLog?.Invoke(this, new CompilerLogEventArgs() { Message = "SUCC" });
}
Expand All @@ -78,7 +77,7 @@ public bool CompilePythonContract(string sourceCode, string outputFilePath, stri
return true;
}

public bool CompileContract(string sourceCode, string outputFilePath, SourceLanguage language, string compilerPath = null)
public bool CompileContract(string sourceCode, string outputFilePath, SourceLanguage language)
{
if (string.IsNullOrEmpty(outputFilePath))
throw new ArgumentNullException(nameof(outputFilePath));
Expand All @@ -91,7 +90,7 @@ public bool CompileContract(string sourceCode, string outputFilePath, SourceLang
}
else if (language == SourceLanguage.Python)
{
return CompilePythonContract(sourceCode, outputFilePath, compilerPath);
return CompilePythonContract(sourceCode, outputFilePath);
}
else
{
Expand All @@ -108,12 +107,12 @@ public void Log(string message)
});
}

private string NeonDotNetExecutableName()
private string NeonDotNet()
{
return "Neo-Compiler.dll";
}

private string DotNetExecutableName()
private string DotNet()
{
return "dotnet";
}
Expand Down
2 changes: 1 addition & 1 deletion Neo-Debugger-Core/Utils/UnixCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public UnixCompiler(DebuggerSettings settings) : base(settings)
{
}

public override string PythonCompilerExecutableName()
public override string Python3()
{
return "python3";
}
Expand Down
2 changes: 1 addition & 1 deletion Neo-Debugger-Core/Utils/WindowsCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public WindowsCompiler(DebuggerSettings settings) : base(settings)
{
}

public override string PythonCompilerExecutableName()
public override string Python3()
{
return "python.exe";
}
Expand Down

0 comments on commit 8520346

Please sign in to comment.