aboutsummaryrefslogtreecommitdiff
path: root/src/lane.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lane.cpp')
-rw-r--r--src/lane.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/lane.cpp b/src/lane.cpp
index 8f31973..17c4126 100644
--- a/src/lane.cpp
+++ b/src/lane.cpp
@@ -48,7 +48,7 @@ static LUAG_FUNC(get_debug_threadname)
48{ 48{
49 Lane* const _lane{ ToLane(L_, 1) }; 49 Lane* const _lane{ ToLane(L_, 1) };
50 luaL_argcheck(L_, lua_gettop(L_) == 1, 2, "too many arguments"); 50 luaL_argcheck(L_, lua_gettop(L_) == 1, 2, "too many arguments");
51 std::ignore = luaG_pushstring(L_, _lane->debugName); 51 luaG_pushstring(L_, _lane->debugName);
52 return 1; 52 return 1;
53} 53}
54 54
@@ -123,7 +123,7 @@ static LUAG_FUNC(thread_join)
123 lua_State* const _L2{ _lane->L }; 123 lua_State* const _L2{ _lane->L };
124 if (!_done || !_L2) { 124 if (!_done || !_L2) {
125 lua_pushnil(L_); // L_: lane nil 125 lua_pushnil(L_); // L_: lane nil
126 lua_pushliteral(L_, "timeout"); // L_: lane nil "timeout" 126 luaG_pushstring(L_, "timeout"); // L_: lane nil "timeout"
127 return 2; 127 return 2;
128 } 128 }
129 129
@@ -218,7 +218,7 @@ static int thread_index_number(lua_State* L_)
218 lua_pushboolean(L_, 1); // L_: lane n {uv} 0 true 218 lua_pushboolean(L_, 1); // L_: lane n {uv} 0 true
219 lua_rawset(L_, kUsr); // L_: lane n {uv} 219 lua_rawset(L_, kUsr); // L_: lane n {uv}
220 // tell join() that we are called from __index, to avoid raising an error if the first returned value is not nil 220 // tell join() that we are called from __index, to avoid raising an error if the first returned value is not nil
221 std::ignore = luaG_pushstring(L_, "[]"); // L_: lane n {uv} "[]" 221 luaG_pushstring(L_, "[]"); // L_: lane n {uv} "[]"
222 // wait until thread has completed, transfer everything from the lane's stack to our side 222 // wait until thread has completed, transfer everything from the lane's stack to our side
223 lua_pushcclosure(L_, LG_thread_join, 1); // L_: lane n {uv} join 223 lua_pushcclosure(L_, LG_thread_join, 1); // L_: lane n {uv} join
224 lua_pushvalue(L_, kSelf); // L_: lane n {uv} join lane 224 lua_pushvalue(L_, kSelf); // L_: lane n {uv} join lane
@@ -227,7 +227,7 @@ static int thread_index_number(lua_State* L_)
227 default: 227 default:
228 // this is an internal error, we probably never get here 228 // this is an internal error, we probably never get here
229 lua_settop(L_, 0); // L_: 229 lua_settop(L_, 0); // L_:
230 lua_pushliteral(L_, "Unexpected status: "); // L_: "Unexpected status: " 230 luaG_pushstring(L_, "Unexpected status: "); // L_: "Unexpected status: "
231 std::ignore = _lane->pushThreadStatus(L_); // L_: "Unexpected status: " "<status>" 231 std::ignore = _lane->pushThreadStatus(L_); // L_: "Unexpected status: " "<status>"
232 lua_concat(L_, 2); // L_: "Unexpected status: <status>" 232 lua_concat(L_, 2); // L_: "Unexpected status: <status>"
233 raise_lua_error(L_); 233 raise_lua_error(L_);
@@ -353,7 +353,7 @@ static LUAG_FUNC(thread_index)
353 default: // unknown key 353 default: // unknown key
354 lua_getmetatable(L_, kSelf); // L_: mt 354 lua_getmetatable(L_, kSelf); // L_: mt
355 std::ignore = luaG_getfield(L_, -1, "cached_error"); // L_: mt error 355 std::ignore = luaG_getfield(L_, -1, "cached_error"); // L_: mt error
356 lua_pushliteral(L_, "Unknown key: "); // L_: mt error "Unknown key: " 356 luaG_pushstring(L_, "Unknown key: "); // L_: mt error "Unknown key: "
357 lua_pushvalue(L_, kKey); // L_: mt error "Unknown key: " k 357 lua_pushvalue(L_, kKey); // L_: mt error "Unknown key: " k
358 lua_concat(L_, 2); // L_: mt error "Unknown key: <k>" 358 lua_concat(L_, 2); // L_: mt error "Unknown key: <k>"
359 lua_call(L_, 1, 0); // error( "Unknown key: " .. key) -> doesn't return // L_: mt 359 lua_call(L_, 1, 0); // error( "Unknown key: " .. key) -> doesn't return // L_: mt
@@ -474,9 +474,9 @@ static constexpr RegistryUniqueKey kStackTraceRegKey{ 0x3F327747CACAA904ull };
474 lua_pushstring(L_, _ar.what); // L_: some_error {} {} what 474 lua_pushstring(L_, _ar.what); // L_: some_error {} {} what
475 lua_setfield(L_, -2, "what"); // L_: some_error {} {} 475 lua_setfield(L_, -2, "what"); // L_: some_error {} {}
476 } else if (_ar.currentline > 0) { 476 } else if (_ar.currentline > 0) {
477 std::ignore = luaG_pushstring(L_, "%s:%d", _ar.short_src, _ar.currentline); // L_: some_error {} "blah:blah" 477 luaG_pushstring(L_, "%s:%d", _ar.short_src, _ar.currentline); // L_: some_error {} "blah:blah"
478 } else { 478 } else {
479 std::ignore = luaG_pushstring(L_, "%s:?", _ar.short_src); // L_: some_error {} "blah" 479 luaG_pushstring(L_, "%s:?", _ar.short_src); // L_: some_error {} "blah"
480 } 480 }
481 lua_rawseti(L_, -2, static_cast<lua_Integer>(_n)); // L_: some_error {} 481 lua_rawseti(L_, -2, static_cast<lua_Integer>(_n)); // L_: some_error {}
482 } 482 }
@@ -745,7 +745,7 @@ static LUAG_FUNC(lane_close)
745 lua_settop(L_, 1); // L_: lane 745 lua_settop(L_, 1); // L_: lane
746 746
747 // no error if the lane body doesn't return a non-nil first value 747 // no error if the lane body doesn't return a non-nil first value
748 std::ignore = luaG_pushstring(L_, "close"); // L_: lane "close" 748 luaG_pushstring(L_, "close"); // L_: lane "close"
749 lua_pushcclosure(L_, LG_thread_join, 1); // L_: lane join() 749 lua_pushcclosure(L_, LG_thread_join, 1); // L_: lane join()
750 lua_insert(L_, 1); // L_: join() lane 750 lua_insert(L_, 1); // L_: join() lane
751 lua_call(L_, 1, LUA_MULTRET); // L_: join() results 751 lua_call(L_, 1, LUA_MULTRET); // L_: join() results
@@ -777,7 +777,7 @@ static LUAG_FUNC(lane_gc)
777 lua_rawget(L_, -2); // L_: ud uservalue gc_cb|nil 777 lua_rawget(L_, -2); // L_: ud uservalue gc_cb|nil
778 if (!lua_isnil(L_, -1)) { 778 if (!lua_isnil(L_, -1)) {
779 lua_remove(L_, -2); // L_: ud gc_cb|nil 779 lua_remove(L_, -2); // L_: ud gc_cb|nil
780 std::ignore = luaG_pushstring(L_, _lane->debugName); // L_: ud gc_cb name 780 luaG_pushstring(L_, _lane->debugName); // L_: ud gc_cb name
781 _have_gc_cb = true; 781 _have_gc_cb = true;
782 } else { 782 } else {
783 lua_pop(L_, 2); // L_: ud 783 lua_pop(L_, 2); // L_: ud
@@ -789,7 +789,7 @@ static LUAG_FUNC(lane_gc)
789 selfdestruct_add(_lane); 789 selfdestruct_add(_lane);
790 assert(_lane->selfdestruct_next); 790 assert(_lane->selfdestruct_next);
791 if (_have_gc_cb) { 791 if (_have_gc_cb) {
792 lua_pushliteral(L_, "selfdestruct"); // L_: ud gc_cb name status 792 luaG_pushstring(L_, "selfdestruct"); // L_: ud gc_cb name status
793 lua_call(L_, 2, 0); // L_: ud 793 lua_call(L_, 2, 0); // L_: ud
794 } 794 }
795 return 0; 795 return 0;
@@ -805,7 +805,7 @@ static LUAG_FUNC(lane_gc)
805 805
806 // do this after lane cleanup in case the callback triggers an error 806 // do this after lane cleanup in case the callback triggers an error
807 if (_have_gc_cb) { 807 if (_have_gc_cb) {
808 lua_pushliteral(L_, "closed"); // L_: ud gc_cb name status 808 luaG_pushstring(L_, "closed"); // L_: ud gc_cb name status
809 lua_call(L_, 2, 0); // L_: ud 809 lua_call(L_, 2, 0); // L_: ud
810 } 810 }
811 return 0; 811 return 0;
@@ -979,7 +979,7 @@ void Lane::PushMetatable(lua_State* L_)
979 lua_getglobal(L_, "tostring"); // L_: mt kCachedTostring tostring() 979 lua_getglobal(L_, "tostring"); // L_: mt kCachedTostring tostring()
980 lua_rawset(L_, -3); // L_: mt 980 lua_rawset(L_, -3); // L_: mt
981 // hide the actual metatable from getmetatable() 981 // hide the actual metatable from getmetatable()
982 lua_pushliteral(L_, kLaneMetatableName); // L_: mt "Lane" 982 luaG_pushstring(L_, kLaneMetatableName); // L_: mt "Lane"
983 lua_setfield(L_, -2, "__metatable"); // L_: mt 983 lua_setfield(L_, -2, "__metatable"); // L_: mt
984 } 984 }
985 STACK_CHECK(L_, 1); 985 STACK_CHECK(L_, 1);