www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Runtime execution

reply "Bauss" <jj_1337 live.dk> writes:
Is there anyway to pull of a runtime compilation of D code or at 
the very least asm execution?
Oct 18 2014
next sibling parent Marco Leise <Marco.Leise gmx.de> writes:
Am Sun, 19 Oct 2014 06:55:17 +0000
schrieb "Bauss" <jj_1337 live.dk>:

 Is there anyway to pull of a runtime compilation of D code or at 
 the very least asm execution?
Sure. For runtime compilation you invoke any installed D compiler and compile a conventional shared library that you then load with: http://dlang.org/library/core/runtime/Runtime.loadLibrary.html For ASM execution you'd simply load the ASM into an executable memory area (See virtual memory page protection attributes for your OS) and call or jump into it through D's inline asm {} blocks. I hope that helps. -- Marco
Oct 19 2014
prev sibling parent "Mjkp" <Mjkp nowhere.jp> writes:
On Sunday, 19 October 2014 at 06:55:18 UTC, Bauss wrote:
 Is there anyway to pull of a runtime compilation of D code or 
 at the very least asm execution?
You can call dmd using std.process to compile a D plug-in edited in your D program and dynamic link the output .dll or .so just after the dmd process 's successfully returned.
Oct 19 2014