Giter Site home page Giter Site logo

cxxs's Introduction

C++ Script Interpreter

The idea of this project is to be able to run C/C++ code as if it is script. This will speed up the C/C++ development iteration cycle tremendously.

Overview

The idea is to parse and interpret C/C++ code as follows:

  • Use the standard pre-processor to process pre-processor statements and remove comments.
    g++ -E -P myfile.cpp
  • 'Parse' the resulting file by reading symbol definitions. This means we read block statements (i.e.: code between '{' and '}') and saving that back for later processing. The goal is to get a full list of all symbols from the source code.
  • Use a some kind of storage (like a sqlite database) to assemble all the symbol definitions. The chalange is to have some kind of incremental process here. We want to avoid this process if nothings changed, but headers might be a fly in the ointment.
  • Use stub implementations to run the code in a script fashion. We need to short circuit some calls, like std::cout in order to improve the script performance. We want this to be declarative.

Architecture

We can have one of the following situations

  • The main function is in compiled code.
  • The main function must be treated as script.

main function is in compiled code

In this case, the executable produced by linking the code will be the host of the scripting engine. We would require stubs for all symbols found in the source files, so we can link the executable, and when one of these scripted symbols are invoked, the scripting engine will take over. This is acceptable, since the stubs will basically just capture the interface of the symbols, which would not change often. I see the process happening as follows:

  • User run the script parser passing all the compiler flags which would've been passed to the compiler.
    • Parse all source files and cache the text for each symbol.
    • Create or update the stubs for each public symbol.
  • Recompile/link the executable. This is only required if some of the stubs changed.
  • User start the executable program, which would invoke the main function
  • When a stub is called, the stub will call the interpreter which would load the script for this symbol from the cache and start executing the script.
  • Calls into libraries needs to be addressed.

main function must be treated as script

In this case, we need a seperate executable to serve as the host of the scripting engine. This is basically the same as above, but we have another executable to call the stub of the main function from the script parser.

Scripting Engine

cxxs's People

Contributors

ddlindeque avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.