New calling conventions, start on print.cpp

This commit is contained in:
2021-09-07 17:37:23 -04:00
parent 924a5ec987
commit 6b2ebba84d
16 changed files with 216 additions and 104 deletions

View File

@@ -115,11 +115,10 @@ static void source_install_builtins(lua_State *L) {
LS.setmetatable(nullstring, stringclass);
}
static int source_updatefile(lua_State *L) {
LuaArg source, fn;
LuaRet info;
static void source_updatefile(LuaStack &LS0, LuaSlot source, LuaSlot fn, LuaSlot info) {
lua_State *L = LS0.state();
LuaVar fingerprint, null, loadresult;
LuaStack LS(L, source, fn, info, fingerprint, null, loadresult);
LuaStack LS(L, fingerprint, null, loadresult);
// Get the existing info table from the source DB.
if (LS.istable(source)) {
@@ -158,7 +157,7 @@ static int source_updatefile(lua_State *L) {
LS.rawset(info, "loadresult", loadresult);
}
}
return LS.result();
LS.result();
}
void SourceDB::update() {
@@ -184,7 +183,7 @@ void SourceDB::update() {
LS.set(fn, filenames[i]);
// Call source_updatefile to get the updated info for one file.
LS.call(info, source_updatefile, sourcedb, fn);
source_updatefile(LS, sourcedb, fn, info);
// Insert the sequence number and put finalized info into the new database.
LS.set(seq, i + 1);
@@ -209,7 +208,7 @@ static void source_clear_globals(lua_State *L) {
LS.set(classname, LuaNil);
while (LS.next(globtab, classname, classtab) != 0) {
if (LS.istable(classtab)) {
LS.call(table_clear, classtab);
table_clear(LS, classtab);
} else {
LS.rawset(globtab, classname, LuaNil);
}
@@ -238,7 +237,7 @@ static void source_load_cfunctions(lua_State *L) {
std::string mode = r->get_mode();
if (mode.find('c') != std::string::npos) { // Insert into class
lua_pushlstring(L, classname.c_str(), classname.size());
source_makeclass(L);
lfn_source_makeclass(L);
lua_pushcfunction(L, func);
lua_setfield(L, -2, funcname.c_str());
}