Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-02-10 Thread Basile B. via Digitalmars-d-learn
On Monday, 10 February 2020 at 12:31:03 UTC, Basile B. wrote: On Friday, 31 January 2020 at 14:25:30 UTC, Basile B. wrote: [...] about [1] (llvm) I've made a better binding this weekend: https://gitlab.com/basile.b/llvmd-d Seriouly I cant believe that at some point in the past I translated

Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-02-10 Thread Basile B. via Digitalmars-d-learn
On Friday, 31 January 2020 at 14:25:30 UTC, Basile B. wrote: On Friday, 31 January 2020 at 11:19:37 UTC, Saurabh Das wrote: I see that DUB has DMD as a library package, but I was not able to understand how to use it. Is it possible to use DMD as a library within a D program to compile a

Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-02-03 Thread Saurabh Das via Digitalmars-d-learn
On Sunday, 2 February 2020 at 06:03:01 UTC, H. S. Teoh wrote: On Sun, Feb 02, 2020 at 03:16:46AM +, Saurabh Das via Digitalmars-d-learn wrote: [...] [...] > [...] [...] [...] [...] It's very simple. Let's say you have your code in some string called 'code'. Since dmd nowadays can

Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-02-01 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Feb 02, 2020 at 03:16:46AM +, Saurabh Das via Digitalmars-d-learn wrote: > On Saturday, 1 February 2020 at 20:37:03 UTC, H. S. Teoh wrote: [...] > > I've actually done this before in an equation grapher program: the > > user inputs an equation, the program generates D code to compute

Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-02-01 Thread Saurabh Das via Digitalmars-d-learn
On Saturday, 1 February 2020 at 20:37:03 UTC, H. S. Teoh wrote: On Sat, Feb 01, 2020 at 08:01:34PM +, Andre Pany via Digitalmars-d-learn wrote: [...] Another approach: - include the dmd compiler package with your application - within your app call the compiler executable and compile the

Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-02-01 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Feb 01, 2020 at 08:01:34PM +, Andre Pany via Digitalmars-d-learn wrote: [...] > Another approach: > - include the dmd compiler package with your application > - within your app call the compiler executable and compile the source > code to a dll / so > - call the dll / so function

Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-02-01 Thread Andre Pany via Digitalmars-d-learn
On Friday, 31 January 2020 at 11:19:37 UTC, Saurabh Das wrote: I see that DUB has DMD as a library package, but I was not able to understand how to use it. Is it possible to use DMD as a library within a D program to compile a string to machine code and run the compiled code at runtime?

Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-01-31 Thread Saurabh Das via Digitalmars-d-learn
On Friday, 31 January 2020 at 14:25:30 UTC, Basile B. wrote: On Friday, 31 January 2020 at 11:19:37 UTC, Saurabh Das wrote: [...] Fundamentally DMD as a library is a front-end. Jitting is to the backend side. You'll be able to lex and parse the source to get an AST, to perform the semantic

Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-01-31 Thread Basile B. via Digitalmars-d-learn
On Friday, 31 January 2020 at 11:19:37 UTC, Saurabh Das wrote: I see that DUB has DMD as a library package, but I was not able to understand how to use it. Is it possible to use DMD as a library within a D program to compile a string to machine code and run the compiled code at runtime?