在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):deemess/uLua开源软件地址(OpenSource Url):https://github.com/deemess/uLua开源编程语言(OpenSource Language):C 76.2%开源软件介绍(OpenSource Introduction):uLuaLua compiler and iterpreter to run on microcontroller (AVR 8 bit) About uLua aimed to run Lua scripts on microcontrollers with very limited resources, like RAM. uLua should work on microcontrollers with RAM >= 1k. Second thing which uLua should achieve is fast code interpreter. Goal is 1 Million Lua instructions on 10 MIPS (10 MHz for AVR). Usage
ChunkSpy.lua - optional. This script used to generate listing file from compiled luc file. Features Currenly support: function calls global consts global and local variables math operations for loops native functions (like print()) closures with upvalues garbage collector Following code could be executed by uLua. --load nil test
function loadtest()
local a,b,c,d,e = nil,nil,0
local aa,bb = true,false
print(a,b,c)
print(aa,bb)
end
loadtest()
-- for loop test
for i = 1, 3, 1 do
print(i)
end
for i = 3, 1, -1 do
print(i)
end
-- upvalue test
function newCounter ()
local i = 0
return function () -- anonymous function
i = i + 1
return i
end
end
c1 = newCounter()
print(c1()) --> 1
print(c1()) --> 2
print(c1()) --> 3
-- function call test
function func1(par1,par2)
local local1 = par1 + par2
return local1
end
function func2(par1,par2,par3)
local local1 = par1 + par2
local local2 = par3 * par3
local1 = local1 + local2
return local1
end
a=1
b=3
c=3.5
result1 = func1(a,b)
result2 = func2(a,b,c)
print("Result1 = ", result1)
print("Result2 = ", result2)
--math test
local a,b = 2,4; a = a + 4 * b - a / 2 ^ b % 3
print("a + 4 * b - a / 2 ^ b % 3 = ", a)
--conditional jumps test
if a ~= b
then print("a != b")
end
if a > b
then print("a > b")
end
if a >= b
then print("a >= b")
end
if a < b
then print("a < b")
end
if a <= b
then print("a <= b")
end
if a == b
then print("a == b")
end Upcoming features: GC - garbage collector. Currenly implemented GC heap standard functions, like: //initialize garbage collector and memory management
void gcInit();
//create new variable and return its number
gcvarpt* gcNew(vartype type);
//create new variable with given size and return its number
gcvarpt* gcNew(vartype type, u08 size);
//delete variable
void gcDelete(gcvarpt* variable); Tables - widly used in lua variable type. Will be implemented as hash table. GC should be implemented first. Supported Operands
Not yet supported
Known Issues GC could leak, implemented simple reference counting logic. Reference cycling is not supported. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论