Added constructors to tangible.build, more work on keyword argument parsing, added LS.tailcall.
This commit is contained in:
@@ -493,6 +493,7 @@ private:
|
||||
friend class LuaCoreStack;
|
||||
friend class LuaDefStack;
|
||||
friend class LuaExtStack;
|
||||
friend class LuaKeywordParser;
|
||||
};
|
||||
|
||||
class LuaArg : public LuaSlot {};
|
||||
@@ -1136,7 +1137,33 @@ public:
|
||||
return nret_;
|
||||
}
|
||||
|
||||
// Tail-call into lua.
|
||||
//
|
||||
// This is meant to be used as follows: return LS.tailcall(passup, func, arg, arg...)
|
||||
//
|
||||
// If passup is true, the return value to our caller consists of our
|
||||
// LuaRet arguments concatenated to the return values from the tail-call.
|
||||
// If passup is false, the return value to our caller consists solely
|
||||
// of our LuaRet arguments.
|
||||
//
|
||||
template<typename... T>
|
||||
int tailcall(bool passup, LuaSlot func, T... args) {
|
||||
lua_checkstack(L_, nret_ + 20);
|
||||
int base = lua_gettop(L_);
|
||||
for (int i = 1; i <= nret_; i++) {
|
||||
lua_pushvalue(L_, i);
|
||||
}
|
||||
push_any_value(func);
|
||||
int argbase = lua_gettop(L_);
|
||||
push_any_values(args...);
|
||||
int nargs = lua_gettop(L_) - argbase;
|
||||
return tailcall_internal(passup, base, nargs);
|
||||
}
|
||||
|
||||
~LuaDefStack() { }
|
||||
|
||||
private:
|
||||
int tailcall_internal(bool passup, int base, int nargs);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@@ -1237,7 +1264,7 @@ class LuaKeywordParser {
|
||||
private:
|
||||
LuaVar found, error, key, val;
|
||||
LuaSpecial keytab;
|
||||
LuaExtStack LS;
|
||||
LuaCoreStack LS;
|
||||
bool istable;
|
||||
|
||||
void init(const lua_State *L, int slot);
|
||||
@@ -1255,12 +1282,14 @@ public:
|
||||
// stores an [ERROR] report in the keyword table.
|
||||
bool required(LuaSlot slot, std::string_view kw);
|
||||
|
||||
// Check if there are any errors so far. If any error has been
|
||||
// Check if there are any errors so far, by checking for an [ERROR]
|
||||
// report in the keyword table. If any error has been
|
||||
// detected, returns an error message, otherwise, returns empty
|
||||
// string.
|
||||
eng::string check();
|
||||
|
||||
// Check if there are any errors so far. Also check that all keyword
|
||||
// Check if there are any errors so far, by checking for an [ERROR]
|
||||
// report in the keyword table. Also check that all keyword
|
||||
// arguments present in the table are in the [FOUND] set. If there are
|
||||
// any errors, returns an error message, otherwise returns empty string.
|
||||
eng::string final_check();
|
||||
|
||||
Reference in New Issue
Block a user