esrrhs / Fake
Licence: mit
嵌入式脚本语言 Lightweight embedded scripting language
Stars: ✭ 172
Projects that are alternatives of or similar to Fake
Zetavm
Multi-Language Platform for Dynamic Programming Languages
Stars: ✭ 592 (+244.19%)
Mutual labels: jit, jit-compiler, interpreter
Enso
Hybrid visual and textual functional programming.
Stars: ✭ 5,238 (+2945.35%)
Mutual labels: jit, interpreter
Rbpf
Rust virtual machine and JIT compiler for eBPF programs
Stars: ✭ 306 (+77.91%)
Mutual labels: jit-compiler, interpreter
Tcl
The Tcl Core. (Mirror of core.tcl-lang.org)
Stars: ✭ 342 (+98.84%)
Mutual labels: jit-compiler, interpreter
Wasmjit
Small Embeddable WebAssembly Runtime
Stars: ✭ 1,063 (+518.02%)
Mutual labels: jit, interpreter
jitm
JITM is an automated tool to bypass the JIT Hooking protection on a .NET sample.
Stars: ✭ 27 (-84.3%)
Mutual labels: jit, jit-compiler
Moonshine Ide
Moonshine is a free and open source middleweight IDE built with ActionScript 3 for ActionScript 3, Apache Flex®, Apache Royale™, and Feathers development, with Cloud and Desktop support.
Stars: ✭ 76 (-55.81%)
Mutual labels: flex, ide
Enso Archive
Looking for Enso, the visual programming language? ➡️ https://github.com/enso-org/enso
Stars: ✭ 305 (+77.33%)
Mutual labels: jit, interpreter
Awesome Graal
A curated list of awesome resources for Graal, GraalVM, Truffle and related topics
Stars: ✭ 302 (+75.58%)
Mutual labels: jit, interpreter
RISVM
A low overhead, embeddable bytecode virtual machine in C++
Stars: ✭ 21 (-87.79%)
Mutual labels: interpreter, asm
Kinx
Looks like JavaScript, feels like Ruby, and it is a script language fitting in C programmers.
Stars: ✭ 134 (-22.09%)
Mutual labels: jit-compiler, interpreter
Rustpython
A Python Interpreter written in Rust
Stars: ✭ 10,261 (+5865.7%)
Mutual labels: jit, interpreter
Corium
Corium is a modern scripting language which combines simple, safe and efficient programming.
Stars: ✭ 18 (-89.53%)
Mutual labels: interpreter, jit-compiler
Mir
A light-weight JIT compiler based on MIR (Medium Internal Representation)
Stars: ✭ 1,075 (+525%)
Mutual labels: jit-compiler, interpreter
Embedded Ide
IDE for C embedded development centered on bare-metal ARM systems
Stars: ✭ 127 (-26.16%)
Mutual labels: gcc, ide
fake
轻量级嵌入式脚本语言
简介
fake是一款轻量级的嵌入式脚本语言, 使用c++语言编写, 语法吸取自lua、golang、erlang, 基于flex、bison生成语法树, 编译成字节码解释执行。
脚本特性
- 运行环境linux amd64、MacOS amd64
- 支持VM, JIT(实验性质)
- 支持fake testfunc(param1)产生routine, 在单线程上实现多线程效果(此特性不支持JIT)
- 支持调试, 自带gdb风格的命令行调试器, 以及VS风格的可视化编辑调试ide, 也可在C里直接通过接口调用, 开始命令行调试
- 支持热更新
- 支持C风格函数和C++类成员函数的绑定
- 支持profile, 可获取脚本各个函数运行时间
- 支持array, map, 可以无限嵌套
- 支持多返回值
- 支持Int64
- 支持const定义
- 支持包
- 支持struct
- 支持打包bin文件或可执行文件
产品应用
示例
-- 当前包名
package mypackage.test
-- 引入的文件
include "common.fk"
-- 结构体定义
struct teststruct
sample_a
sample_b
sample_c
end
-- 常量值
const hellostring = "hello"
const helloint = 1234
const hellomap = {1 : "a" 2 : "b" 3 : [1 2 3]}
-- func1 comment
func myfunc1(arg1, arg2)
-- C函数和类成员函数的调用
arg3 := cfunc1(helloint) + arg2:memfunc1(arg1)
-- 分支
if arg1 < arg2 then
-- 创建一个协程
fake myfunc2(arg1, arg2)
elseif arg1 == arg2 then
print("elseif")
else
print("else")
end
-- for循环
for var i = 0, i < arg2, i++ then
print("i = ", i)
end
-- 数组
var a = array()
a[1] = 3
-- 集合
var b = map()
b[a] = 1
b[1] = a
-- Int64
var uid = 1241515236123614u
log("uid = ", uid)
-- 子函数调用
var ret1, var ret2 = myfunc2()
-- 其他包的函数调用
ret1 = otherpackage.test.myfunc1(arg1, arg2)
-- 结构体
var tt = teststruct()
tt->sample_a = 1
tt->sample_b = teststruct()
tt->sample_b->sample_a = 10
-- 分支
switch arg1
case 1 then
print("1")
case "a" then
print("a")
default
print("default")
end
-- 多返回值
return arg1, arg3
end
C++示例
// 创建一个实例
fake * fk = newfake();
// 注册全局函数
fkreg(fk, "cfunc1", cfunc1);
// 注册类成员函数, 不同的类注册一样的函数名字不冲突
fkreg(fk, "memfunc1", &class1::memfunc1);
// 解析fake脚本文件
fkparse(fk, argv[1]);
// 执行myfunc1函数, 传入两个参数分别为1和2
ret = fkrun<int>(fk, "myfunc1", 1, 2);
// 删除实例
delfake(fk);
性能比较
运行cd benchmark/ && ./benchmark.sh
,在MacBook Pro 2.3 GHz Intel Core i5上的数据
Lua | Python | Fake | Fake JIT | |
---|---|---|---|---|
Loop | 0.8s | 2.3s | 1.3s | 0.2s |
Prime | 13.5s | 20.9s | 12.8s | 5.9s |
String | 0.8s | 0.4s | 1.2s | 3.2s |
注:因为JIT目前无法GC,所以String反而最慢
如何使用
复制 include/fake-inc.h 和 bin/libfake.so 到你的工程, 直接使用
如何编译
- 安装cmake
- (可选)安装flex, bison, 运行
./gen.sh
- 安装gcc, gcc-c++
-
./build.sh
或者./build.sh release
测试示例
- test/sample 目录下有脚本示例代码
- 运行方法
cd test && ./test.sh
- bin/fakebin 为可执行文件,可以自己编写运行,如:
./fakebin your.fk
调试环境
- IDE (bin/fakeide.app)
- 命令行 (bin/fakebin)
Stargazers over time
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].