- /* get the list of visited tables from father at index 1 of dst */
- /* src: ... value
- dst: ... */
- lua_getfield(dst, LUA_REGISTRYINDEX, "simgrid.father_visited_tables");
- /* dst: ... visited */
- lua_insert(dst, 1);
- /* dst: visited ... */
-
- sglua_move_value_impl(src, dst, sglua_tostring(src, -1));
- /* src: ...
- dst: visited ... value */
- lua_remove(dst, 1);
- /* dst: ... value */
- sglua_stack_dump("src after xmove: ", src);
- sglua_stack_dump("dst after xmove: ", dst);
+ /* ... */
+ lua_pushvalue(L, index);
+ /* ... table */
+ lua_getfield(L, LUA_REGISTRYINDEX, "simgrid.maestro_tables");
+ /* ... table maestrotbs */
+ lua_pushvalue(L, -2);
+ /* ... table maestrotbs table */
+ lua_pushlightuserdata(L, maestro_table_ptr);
+ /* ... table maestrotbs table tableptr */
+ lua_pushvalue(L, -1);
+ /* ... table maestrotbs table tableptr tableptr */
+ lua_pushvalue(L, -3);
+ /* ... table maestrotbs table tableptr tableptr table */
+ lua_settable(L, -5);
+ /* ... table maestrotbs table tableptr */
+ lua_settable(L, -3);
+ /* ... table maestrotbs */
+ lua_pop(L, 2);
+ /* ... */
+}
+
+/**
+ * @brief For a table in the stack of L, returns a pointer that identifies the
+ * same table in in maestro's world.
+ * @param L a Lua state
+ * @param index index of a table in the stack of L
+ * @return a pointer to maestro's copy of this table, or NULL if this table
+ * did not come from maestro
+ */
+static void* sglua_get_maestro_table_ptr(lua_State* L, int index) {
+
+ void* maestro_table_ptr = NULL;
+ /* ... */
+ lua_pushstring(L, "simgrid.maestro_tables");
+ /* ... "simgrid.maestro_tables" */
+ lua_rawget(L, LUA_REGISTRYINDEX);
+ /* ... maestrotbs */
+ lua_pushvalue(L, index);
+ /* ... maestrotbs table */
+ lua_gettable(L, -2);
+ /* ... maestrotbs tableptr/nil */
+ if (!lua_isnil(L, -1)) {
+ /* ... maestrotbs tableptr */
+ maestro_table_ptr = (void*) lua_topointer(L, -1);