airtrack / luna Goto Github PK
View Code? Open in Web Editor NEWA toy interpreter of lua-like language
License: MIT License
A toy interpreter of lua-like language
License: MIT License
I'm looking into using this for an open source embedded project, but it lacks a license, so I can't. If you could add an MIT or GPL license, that would be great.
例子:
function get_table(...)
return {1,...}
end
a = get_table(2,3)
返回的是{1,2}
,lua的是{1,2,3}
do
local a = {}
for i = 1,2 do
a[i] = function() i = i+1; print(i); end
end
local b = 1 -- 如果这行不注释,下面执行会出错
a[1]()
end
根据字节码,运行到i=i+1时。把常量1加载到以前这个位置是upvalue值上,也就是修改到了闭包上,并没有修改到寄存器上。在后面进行运算OpType_ADD中使用的相应寄存器的内容。原因VM.cpp文件中OpType_LoadConst指令,在*GET_REAL_VALUE(a)=*b后面直接改为
*a = *b
其实OpType_FillNil指令使得变量不是闭包变量,也就能够赋值成功。
闭包捕获,跟lua不一致的原因。虽然生成了不同closure,但是value是指向了同一个地址。
Add JIT backend engine.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.