All Projects → mvhooren → JitCat

mvhooren / JitCat

Licence: MIT license
A C++17 library for parsing and executing expressions. Allows easy exposure of variables and functions from C++ through built-in reflection functionality.

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to JitCat

Batch-First
A JIT compiled chess engine which traverses the search tree in batches in a best-first manner, allowing for neural network batching, asynchronous GPU use, and vectorized CPU computations.
Stars: ✭ 27 (+68.75%)
Mutual labels:  llvm, jit-compiler
jingle
🔔 Jingle is a dynamically-typed, multi-paradigm programming language designed for humans and machines.
Stars: ✭ 34 (+112.5%)
Mutual labels:  llvm, jit-compiler
Expr
Expression language for Go
Stars: ✭ 2,123 (+13168.75%)
Mutual labels:  expression-evaluator, expression-language
dmjit
.dmJIT is a Rust-based JIT compiler using modified auxtools, dmasm and Inkwell LLVM wrapper for boosting Byond DM performance without any hassle! (formerly known as dm-jitaux)
Stars: ✭ 18 (+12.5%)
Mutual labels:  llvm, jit-compiler
Compiler-written-in-Haskell
A Turing complete language 😉
Stars: ✭ 31 (+93.75%)
Mutual labels:  llvm, jit-compiler
Pure Lang
Pure programming language
Stars: ✭ 209 (+1206.25%)
Mutual labels:  llvm, jit-compiler
verificarlo
A tool for debugging and assessing floating point precision and reproducibility.
Stars: ✭ 51 (+218.75%)
Mutual labels:  llvm
CFI-LB
Adaptive Callsite-sensitive Control Flow Integrity - EuroS&P'19
Stars: ✭ 13 (-18.75%)
Mutual labels:  llvm
imp
Compiler for IMP programming language implemented in Haskell
Stars: ✭ 16 (+0%)
Mutual labels:  llvm
open-ops
Open Optimizing Parallelizing System
Stars: ✭ 21 (+31.25%)
Mutual labels:  llvm
proton-clang-build
A set of scripts to build optimized LLVM and binutils toolchains. See https://github.com/kdrag0n/proton-clang for prebuilts.
Stars: ✭ 30 (+87.5%)
Mutual labels:  llvm
pymlir
Python interface for MLIR - the Multi-Level Intermediate Representation
Stars: ✭ 84 (+425%)
Mutual labels:  llvm
joern
Open-source code analysis platform for C/C++/Java/Binary/Javascript/Python/Kotlin based on code property graphs
Stars: ✭ 968 (+5950%)
Mutual labels:  llvm
LOWLLVM
参照着OLLVM写的一个混淆库,只要机器上有装LLVM,就可以直接编译拿来用
Stars: ✭ 46 (+187.5%)
Mutual labels:  llvm
surveyor
A symbolic debugger for C/C++ (via LLVM), machine code, and JVM programs
Stars: ✭ 14 (-12.5%)
Mutual labels:  llvm
CastXMLSuperbuild
Build CastXML and its dependencies (LLVM/Clang)
Stars: ✭ 32 (+100%)
Mutual labels:  llvm
llvm-semantics
Formal semantics of LLVM IR in K
Stars: ✭ 42 (+162.5%)
Mutual labels:  llvm
string-math
Evaluates a math expression from a string. Supports variables and custom operators.
Stars: ✭ 14 (-12.5%)
Mutual labels:  expression-evaluator
llvm-epp
Efficient Path Profiling using LLVM
Stars: ✭ 16 (+0%)
Mutual labels:  llvm
Jazz
Jazz - modern and fast programming language.
Stars: ✭ 86 (+437.5%)
Mutual labels:  llvm

JitCat

A C++17 library for parsing and executing expressions. Allows easy exposure of variables and functions from C++ through built-in reflection functionality. JitCat is currently being expanded into a more fully featured scripting language.

Get it on github.

Features

  • Supports floating point, integer, boolean, string and object (pointer or by value) typed expressions as well as void typed and any typed expressions. More types to come.
  • Optional native code compilation of expressions using the LLVM core libraries.
  • Expose variables for use in expressions through reflection of C++ classes.
  • Create and expose custom data structures to expressions at runtime.
  • Reflection supports easy reflection of C++ classes and structs including reflection of functions. Limited to the following member types (with more types to come):
    • float, double, bool, int, std::string
    • Reflected objects
    • Reflected enums
    • Pointers to reflected objects
    • std::unique_ptr to reflected objects
    • std::library container types that have implemented operator[]
    • member functions that return one of the supported types or void and that have parameters that are among the supported types (or no parameters).
    • static members and static functions
    • constants
  • Reflection can be done either internally to a class, using static member functions, or externally using an ExternalReflector.
  • Built-in functions for use in expressions for common operations
  • Basic optimizations of expressions such as const collapse.
  • Graceful error handling with human-readable error messages, though this area can use improvement.
  • Builds and is tested to work on Linux with clang (6.0) and gcc (8.0) and on Microsoft Windows with VS2019.
  • Built-in functionality for code completion of expressions.
  • Unit tests testing all aspects of the expression language and reflection.
  • (Currently broken) Can export reflected types to a XML file for use with the JitCatValidator shared library to validate and code-complete expressions outside of the main C++ application.

Usage example

#include <jitcat/Expression.h>
#include <jitcat/ExpressionAny.h>
using namespace jitcat;

//A simple floating point calculation
Expression<float> anExpression("2.0 * abs(21.0)");
anExpression.compile(nullptr);
float value = anExpression.getValue(nullptr);

//String addition
Expression<std::string> anotherExpression("\"Hello\" + \" World\"");
anotherExpression.compile(nullptr);
std::string message = anotherExpression.getValue(nullptr);

//An expression returning an object. It uses a context that contains variables that can be referenced inside the expression.
Expression<MyObject*> objectTypeExpression("anObject.member.list[42].getMyObject()");
objectTypeExpression.compile(myContext);
MyObject* objectResult = objectTypeExpression.getValue(myContext);

//An expression that accepts any return type, in this case it is a std::vector.
//Passing myContext to the constructor will call compile automatically.
ExpressionAny anyTypedExpression(myContext, "anObject.member.list");
std::any anyValue = anyTypedExpression.getValue(myContext);
if (anyTypedExpression.getType().isFloatType())
{
	float floatValue = std::any_cast<float>(anyValue);
	//Do something
}

Documentation

Building JitCat
Building LLVM for use with JitCat
See the the examples directory for a basic example.

Roadmap

JitCat is under active development. These are some of the major features that can be expected in the future:

  • Documentation and more example projects.
  • Support for more types.
  • Extending the language beyond simple expressions.

License

Uses the permissive MIT license, see the included LICENSE file.

Author

Machiel van Hooren

Acknowledgements

Thanks to Ronimo Games, my ex-employer, for supporting and actively using this library. Many improvements have been made during office hours!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].