azizamari / Ncodi

Tunisian Programming Language, Ncodi - Code in your own words.
http://ncodi.tn
Apache License 2.0
117 stars 11 forks source link

Unable to compile a file under Linux #56

Open LyesSaadi opened 3 years ago

LyesSaadi commented 3 years ago

Hello again!

Because it is using Windows-exclusive code, the compiler is unable to compile a program.

Here is the stack trace:

Unhandled exception. System.IO.DirectoryNotFoundException: Could not find a part of the path '/var/home/lyes/.opt/Ncodi/D:/ncodi/cfg.dot'.
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter) in /_/src/System.Private.CoreLib/shared/Interop/Unix/Interop.IOErrors.cs:line 24
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) in /_/src/System.Private.CoreLib/shared/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs:line 39
   at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options) in /_/src/System.Private.CoreLib/shared/System/IO/FileStream.Unix.cs:line 61
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) in /_/src/System.Private.CoreLib/shared/System/IO/FileStream.cs:line 237
   at System.IO.StreamWriter.ValidateArgsAndOpenPath(String path, Boolean append, Encoding encoding, Int32 bufferSize) in /_/src/System.Private.CoreLib/shared/System/IO/StreamWriter.cs:line 170
   at System.IO.StreamWriter..ctor(String path) in /_/src/System.Private.CoreLib/shared/System/IO/StreamWriter.cs:line 140
   at Ncodi.CodeAnalysis.Compilation.Evaluate(Dictionary`2 variables, Boolean useConsole, Func`1 GetInput, Action`1 send) in /var/home/lyes/.opt/Ncodi/src/Ncodi/CodeAnalysis/Compilation.cs:line 69
   at Ncodi.Program.Main(String[] args) in /var/home/lyes/.opt/Ncodi/src/Nc/Program.cs:line 39

I do not have any experience in C#, but looking at the stack trace, the issue is obviously here: https://github.com/azizamari/Ncodi/blob/47bca33fa426d5d5fbcb980b84385e6140c7c293/src/Ncodi/CodeAnalysis/Compilation.cs#L63-L70

Looking at it, I wouldn't be surprised if it also causes issues in Windows systems, since it is looking for a configuration file in a hard-coded path.

NOTE: I used compile here, but I have no idea if it's doing any compilation or not TBH since I wasn't able to execute it yet :P !

azizamari commented 3 years ago

I changed the code when testing and forgot to change it back my bad Line 64 should be like this var cfgPath = Path.Combine(appDirectory, "cfg.dot");

azizamari commented 3 years ago

If you use the Ncodi.Cli to execute some .ncodi file you will find a cfg.dot generated there it contains a graph visualization of how the code was ran. Simply open it in a text editor copy the data in it and paste it in a graphviz renderer like this (make sure the engine is set to dot) https://dreampuf.github.io/GraphvizOnline/ I used this mainly for debugging but it's cool to see :)