Compiler/Virtual Machine Environment

Discussion in 'C++' started by ccrabfo, Apr 9, 2004.

  1. ccrabfo

    ccrabfo Guest

    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
    --
    ccrabfo, Apr 9, 2004
    #1
    1. Advertising

  2. "ccrabfo" <> wrote
    > 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
    Claudio Puviani, Apr 9, 2004
    #2
    1. Advertising

  3. On Fri, 9 Apr 2004 15:11:40 -0400, ccrabfo <> wrote:

    > 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/
    --
    Mike Higginbottom
    http://www.peak41.co.uk
    Mike Higginbottom, Apr 9, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. while_1
    Replies:
    2
    Views:
    617
    Roedy Green
    Jun 25, 2004
  2. Replies:
    4
    Views:
    5,673
    Michael Borgwardt
    Dec 10, 2004
  3. Replies:
    5
    Views:
    640
  4. chandan
    Replies:
    1
    Views:
    360
    Naraendirakumar R.R.
    Jan 8, 2008
  5. chandan
    Replies:
    1
    Views:
    292
Loading...

Share This Page