improved the minifier significantly, added miniprompt, and fixed some bugs in microtel

This commit is contained in:
Izaya 2018-05-19 13:36:32 +10:00
parent e9df741396
commit 73694b480f
10 changed files with 96 additions and 15 deletions

View File

@ -1,20 +1,20 @@
{
{"eventTab","Z"},
{"modems","M"},
{"qPacket","qP"},
{"packetID","pID"},
{"packetType","pT"},
{"qPacket","A"},
{"packetID","B"},
{"packetType","E"},
{"to","T"},
{"vport","vP"},
{"vport","F"},
{"data","D"},
{"rawSendPacket","rS"},
{"sendPacket","sP"},
{"genPacketID","gP"},
{"packetCache","pC"},
{"checkCache","cC"},
{"routeCache","rC"},
{"realComputerPullSignal","rCPE"},
{"packetQueue","pQ"},
{"rawSendPacket","G"},
{"sendPacket","I"},
{"genPacketID","J"},
{"packetCache","L"},
{"checkCache","N"},
{"routeCache","O"},
{"realComputerPullSignal","X"},
{"packetQueue","P"},
{"computer","C"},
{"C.uptime","U"},
{"table.unpack","Y"},

View File

@ -0,0 +1,24 @@
{
{"eventTab","Z"},
{"modems","M"},
{"qPacket","qP"},
{"packetID","pID"},
{"packetType","pT"},
{"to","T"},
{"vport","vP"},
{"data","D"},
{"rawSendPacket","rS"},
{"sendPacket","sP"},
{"genPacketID","gP"},
{"packetCache","pC"},
{"checkCache","cC"},
{"routeCache","rC"},
{"realComputerPullSignal","rCPE"},
{"packetQueue","pQ"},
{"computer","C"},
{"C.uptime","U"},
{"table.unpack","Y"},
{"COMPUTER","computer"},
{"UPTIME","C.uptime"},
{"UNPACK","table.unpack"},
}

View File

@ -1,7 +1,7 @@
function net.socket(address, port, sclose)
local conn, rb = {}, ""
conn.state, conn.buffer, conn.port, conn.address = "o", "", tonumber(port), address
function conn.r(self,length)
function conn.r(self,l)
rb=self.buffer:sub(1,l)
self.buffer=self.buffer:sub(l+1)
return rb

View File

@ -5,6 +5,9 @@
{"port","P"},
{"conn.state","conn.s"},
{"conn.buffer","conn.b"},
{"self.buffer","self.b"},
{"self.state","self.s"},
{"self","s"},
{"conn","C"},
{"etype","E"},
{"from","F"},

View File

@ -1,7 +1,7 @@
net.timeout = 60
function net.open(address,vport)
local st,from,port,data=computer.uptime()
net.send(address,port,"openstream")
net.send(address,vport,"openstream")
repeat
_, from, port, data = computer.pullSignal(0.5)
if computer.uptime() > st+net.timeout then return false end
@ -10,5 +10,5 @@ function net.open(address,vport)
repeat
_, from, port, data = computer.pullSignal(0.5)
until from == address and port == vport
return socket(address,vport,data)
return net.socket(address,vport,data)
end

View File

@ -31,6 +31,9 @@ local replacements={
{" %* ","*"},
{" \n","\n"},
{" %.%. ",".."},
{"([%)%}])%s(%a)","%1%2"},
{"(%d)%s([G-Zg-z])","%1%2"},
{"([\"'])%s(%a)","%1%2"},
{"%-%-.-\n",""},
}

35
Embedded/miniprompt.lua Normal file
View File

@ -0,0 +1,35 @@
local ga,sa = component.list("gpu")(),component.list("screen")()
GPU = component.proxy(ga)
GPU.bind(sa)
write = vt100emu(GPU)
function print(...)
for k,v in pairs({...}) do
write(tostring(v).."\n")
end
end
function read()
local sBuffer = ""
repeat
local tSignal = {computer.pullSignal()}
if tSignal[1] == "key_down" then
if tSignal[3] > 31 and tSignal[3] < 127 then
write(string.char(tSignal[3]))
sBuffer = sBuffer .. string.char(tSignal[3])
elseif tSignal[3] == 8 and tSignal[4] == 14 and S:len() > 0 then
write("\8 \8")
sBuffer = sBuffer:sub(1,-2)
end
end
until tSignal[1] == "key_down" and tSignal[3] == 13 and tSignal[4] == 28
write("\n")
return sBuffer
end
--API
while true do
write(_VERSION.."> ")
tResult = {pcall(load(read()))}
for k,v in pairs(tResult) do
print(v)
end
end

View File

@ -0,0 +1,12 @@
{
{"write","W"},
{"print","P"},
{"read","R"},
{"tSignal","T"},
{"sBuffer","S"},
{"tResult","V"},
{"GPU","B"},
{"ga","N"},
{"sa","M"},
{"%-%-API","read,write,print=R,W,P"},
}

View File

@ -0,0 +1,3 @@
{
{"component","GC"},
}

View File

@ -16,4 +16,5 @@
{"my","H"},
{"sx","T"},
{"sy","U"},
{"mode","M"},
}