Compiler/Virtual Machine Environment

C

ccrabfo

Has anyone ever implemented embedding a "virtual host" or "virual machine"
environment inside your C/C++ programs so that end-users could write small
snippets of customized code, compile it using your custom compiler, and if
the compiled byte-code file exists, it gets loaded and ran by the embedded
virtual host engine?

My thought was to develop a basic-like compiler system that the user could
write a file called TASKA.MSC which looks like:

// File: TASKA.MSC
// Simple Task A Example
Dim userdata as TUserData
Clear userdata
if GetUserData(userdata) then
// do something with the data
// specific to this end-user install
end if

Then run this through my compiler:

mysc.exe taska.msc

This would create something like taska.mxc which is a compiled byte-code
binary file of the instructions found in the 4GL base source file. The
virtual host environment would be inclusive inside my program or a DLL which
basically is a virtual machine environment that loads the MXC file, and runs
the binary version instead of having to verify the 4GL syntax, compile it,
and then run it. All the virtual environment does is execute it (very much
like java and its JVM).

Anyone have any thoughts on:
1) How to create such a compiler
2) How to create the host environment to execute the compiled binary?

Thanks
--
 
C

Claudio Puviani

ccrabfo said:
Has anyone ever implemented embedding a
"virtual host" or "virual machine" environment
inside your C/C++ programs so that end-users
could write small snippets of customized code,
compile it using your custom compiler, and if
the compiled byte-code file exists, it gets loaded
and ran by the embedded virtual host engine?

...

Anyone have any thoughts on:
1) How to create such a compiler
2) How to create the host environment to execute
the compiled binary?

A number of commercial and free solutions already exist. Commercial
solutions tend to emulate VBA and are fairly expensive. Free solutions
include embedding Perl, Python, LISP, or other freely available
interpreters.

If you want to implement this yourself, you'll save yourself a lot of hassle
if you write an interpreter instead of a compiler. How to do that, however,
is both off-topic for this newsgroup and beyond the reasonable scope for any
posting. You could start with the following book:
http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?isbn=0471597538

Claudio Puviani
 
M

Mike Higginbottom

Has anyone ever implemented embedding a "virtual host" or "virual
machine"
environment inside your C/C++ programs so that end-users could write
small
snippets of customized code, compile it using your custom compiler, and
if
the compiled byte-code file exists, it gets loaded and ran by the
embedded
virtual host engine?

Don't know what your exact requirements are but you could try LUA [1]

[1] http://www.lua.org/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top