aboutsummaryrefslogtreecommitdiff
path: root/src/lanes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lanes.cpp')
-rw-r--r--src/lanes.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lanes.cpp b/src/lanes.cpp
index 462de0f..1f795cc 100644
--- a/src/lanes.cpp
+++ b/src/lanes.cpp
@@ -967,10 +967,10 @@ LUAG_FUNC(require)
967LUAG_FUNC(register) 967LUAG_FUNC(register)
968{ 968{
969 char const* name = luaL_checkstring(L, 1); 969 char const* name = luaL_checkstring(L, 1);
970 int const mod_type = lua_type(L, 2); 970 LuaType const mod_type{ lua_type_as_enum(L, 2) };
971 // ignore extra parameters, just in case 971 // ignore extra parameters, just in case
972 lua_settop(L, 2); 972 lua_settop(L, 2);
973 luaL_argcheck(L, (mod_type == LUA_TTABLE) || (mod_type == LUA_TFUNCTION), 2, "unexpected module type"); 973 luaL_argcheck(L, (mod_type == LuaType::TABLE) || (mod_type == LuaType::FUNCTION), 2, "unexpected module type");
974 DEBUGSPEW_CODE(Universe* U = universe_get(L)); 974 DEBUGSPEW_CODE(Universe* U = universe_get(L));
975 STACK_CHECK_START_REL(L, 0); // "name" mod_table 975 STACK_CHECK_START_REL(L, 0); // "name" mod_table
976 DEBUGSPEW_CODE(fprintf(stderr, INDENT_BEGIN "lanes.register %s BEGIN\n" INDENT_END, name)); 976 DEBUGSPEW_CODE(fprintf(stderr, INDENT_BEGIN "lanes.register %s BEGIN\n" INDENT_END, name));
@@ -1226,7 +1226,8 @@ LUAG_FUNC(lane_new)
1226 STACK_CHECK(L2, 0); 1226 STACK_CHECK(L2, 0);
1227 1227
1228 // Lane main function 1228 // Lane main function
1229 if (lua_type(L, 1) == LUA_TFUNCTION) 1229 LuaType const func_type{ lua_type_as_enum(L, 1) };
1230 if (func_type == LuaType::FUNCTION)
1230 { 1231 {
1231 DEBUGSPEW_CODE(fprintf( stderr, INDENT_BEGIN "lane_new: transfer lane body\n" INDENT_END)); 1232 DEBUGSPEW_CODE(fprintf( stderr, INDENT_BEGIN "lane_new: transfer lane body\n" INDENT_END));
1232 DEBUGSPEW_CODE(U->debugspew_indent_depth.fetch_add(1, std::memory_order_relaxed)); 1233 DEBUGSPEW_CODE(U->debugspew_indent_depth.fetch_add(1, std::memory_order_relaxed));
@@ -1238,7 +1239,7 @@ LUAG_FUNC(lane_new)
1238 luaL_error(L, "tried to copy unsupported types"); // doesn't return 1239 luaL_error(L, "tried to copy unsupported types"); // doesn't return
1239 } 1240 }
1240 } 1241 }
1241 else if (lua_type(L, 1) == LUA_TSTRING) 1242 else if (func_type == LuaType::STRING)
1242 { 1243 {
1243 DEBUGSPEW_CODE(fprintf(stderr, INDENT_BEGIN "lane_new: compile lane body\n" INDENT_END)); 1244 DEBUGSPEW_CODE(fprintf(stderr, INDENT_BEGIN "lane_new: compile lane body\n" INDENT_END));
1244 // compile the string 1245 // compile the string
@@ -1247,6 +1248,10 @@ LUAG_FUNC(lane_new)
1247 luaL_error(L, "error when parsing lane function code"); // doesn't return 1248 luaL_error(L, "error when parsing lane function code"); // doesn't return
1248 } 1249 }
1249 } 1250 }
1251 else
1252 {
1253 luaL_error(L, "Expected function, got %s", lua_typename(L, func_type)); // doesn't return
1254 }
1250 STACK_CHECK(L, 0); 1255 STACK_CHECK(L, 0);
1251 STACK_CHECK(L2, 1); 1256 STACK_CHECK(L2, 1);
1252 ASSERT_L(lua_isfunction(L2, 1)); 1257 ASSERT_L(lua_isfunction(L2, 1));