scripting - Precompile script into objects inside C++ application -
i need provide users ability write mathematical computations program. plan have simple text interface few buttons including validate script grammar, save etc.
here's gets interesting. these functions user writing need execute @ multi-megabyte line speeds in communications application. need speed of compiled language, usage of script. interpreted language won't cut it.
my idea precompile saved user modules objects @ initialization of c++ application. use these objects execute code when called upon. here workflows have in mind:
1) testing(initial writing) of script: write code in editor, save, compile object (testing grammar), run test i/o, edit code
2) use of code (normal operation of application): load script file, compile script object, run object code, run object code, run object code, etc.
i've looked several off shelf interpreters, can't find i'm looking for. considered java, pretty fast, need load java virtual machine, means passing objects between c , virtual machine... interface bottleneck here. need create native c++ object running c++ code if possible. need able run code on multiple processors in controlled manner.
i'm not looking whole explanation on how pull off, can own research. i've been stalled couple days here now, however, , need place start looking.
as last resort, create own scripting language fulfill need, seems waste great interpreters out there. i've considered taking existing open source complier , slicing functionality need... not saving compiled results disk... don't know. prefer use mainline language if possible... that's not required.
any appreciated. know not run of mill idea have here, has have done before.
thanks!
p.s. 1 thought occurred me while writing this: using true c compiler create object code, save disk dll library, reload , run inside "my" code? can ms visual studio? need @ licensing of compiler... how reload library dynamically while main application continues run... hmmmmm group "functions" created user library groups. ok that's enough of particular brain dump...
a possible solution use gcc (mingw since on windows) , build dll out of user defined code. dll should export 1 function. can use win32 api handle dll (loadlibrary/getprocaddress etc.) @ end of job have c style function pointer. problem arguments. if computation has 1 parameter can fo cast double (*funct)(double), if have many parameters need match them.
Comments
Post a Comment