564
565
566
567
568
569
570
571
572
573
574
575
576
577
...
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
...
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
|
'blob'; -- opaque binary blob, so 3d-pty mods can use the
-- file mechanism to store arbirary data.
};
drm = T.u8; -- inhibit copying
name = T.str;
body = T.text;
}, function(file) -- enc
local b = E.chip.file[file.kind].enc(file.body)
return {
kind = file.kind;
drm = file.drm;
name = file.name;
body = b;
}
................................................................................
end;
__index = {
read = function(self)
local dat = E.chip.read(self.chip)
return dat.files[self.inode]
end;
write = function(self,data)
-- print('writing', self.chip, self.inode)
return E.chip.fileWrite(self.chip, self.inode, data)
end;
erase = function(self)
local dat = E.chip.read(self.chip)
table.remove(dat.files, self.inode)
E.chip.write(self.chip, dat)
self.inode = nil
................................................................................
then
for fl, inode in E.chip.files(e) do
if fl.kind == 'sw' then
local s = starlit.item.sw.db[fl.body.pgmId]
table.insert(sw, {
sw = s, chip = e, chipSlot = i;
file = fl, inode = inode;
})
end
end
end
end
end
for _, s in pairs(sw) do
if s.sw.cost.ram <= comp.ram and pred(s) then
table.insert(r, {
sw = s.sw;
chip = s.chip, chipSlot = s.chipSlot;
file = s.file;
fd = E.chip.fileHandle(s.chip, s.inode);
speed = s.sw.cost.cycles / comp.cycles;
powerCost = s.sw.cost.cycles / comp.powerEfficiency;
comp = comp;
|
|
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
...
873
874
875
876
877
878
879
880
881
882
883
884
885
886
...
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
|
'blob'; -- opaque binary blob, so 3d-pty mods can use the
-- file mechanism to store arbirary data.
};
drm = T.u8; -- inhibit copying
name = T.str;
body = T.text;
}, function(file) -- enc
assert(E.chip.file[file.kind], string.format('invalid file kind "%s"', file.kind))
local b = E.chip.file[file.kind].enc(file.body)
return {
kind = file.kind;
drm = file.drm;
name = file.name;
body = b;
}
................................................................................
end;
__index = {
read = function(self)
local dat = E.chip.read(self.chip)
return dat.files[self.inode]
end;
write = function(self,data)
return E.chip.fileWrite(self.chip, self.inode, data)
end;
erase = function(self)
local dat = E.chip.read(self.chip)
table.remove(dat.files, self.inode)
E.chip.write(self.chip, dat)
self.inode = nil
................................................................................
then
for fl, inode in E.chip.files(e) do
if fl.kind == 'sw' then
local s = starlit.item.sw.db[fl.body.pgmId]
table.insert(sw, {
sw = s, chip = e, chipSlot = i;
file = fl, inode = inode;
id = fl.body.pgmId;
})
end
end
end
end
end
for _, s in pairs(sw) do
if s.sw.cost.ram <= comp.ram and pred(s) then
table.insert(r, {
id = s.id;
sw = s.sw;
chip = s.chip, chipSlot = s.chipSlot;
file = s.file;
fd = E.chip.fileHandle(s.chip, s.inode);
speed = s.sw.cost.cycles / comp.cycles;
powerCost = s.sw.cost.cycles / comp.powerEfficiency;
comp = comp;
|