void backprop::process_block (basic_block bb) { for (gimple_stmt_iterator gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi)) { tree lhs = gimple_get_lhs (gsi_stmt (gsi)); if (lhs && TREE_CODE (lhs) == SSA_NAME) process_var (lhs); } for (gphi_iterator gpi = gsi_start_phis (bb); !gsi_end_p (gpi); gsi_next (&gpi)) process_var (gimple_phi_result (gpi.phi ())); }
bool MsdpNetwork::run_plugins_msdp(const tbyte* data, int len) { //OUTPUT_BYTES(data, len, len, "PLUGINS MSDP"); // translate msdp data into lua table lua_newtable(L); cursor c; c.p = data; c.e = data + len; while (c.p != c.e) { if (!process_var(c)) { lua_pop(L, 1); return false; } if (!process_val(c)) { lua_pop(L, 1); return false; } } // run plugins tortilla::getPluginsManager()->processPluginsMethod("msdp", 1); return true; }
bool MsdpNetwork::process_val(cursor& c) { const tbyte* p = c.p; if (p == c.e || *p != MSDP_VAL) return false; const tbyte* b = p+1; if (b == c.e) { lua_pushstring(L, ""); lua_settable(L, -3); c.p = b; return true; } if (*b >= ' ') { while (b != c.e && *b >= ' ') b++; if (b != c.e && *b != MSDP_VAR && *b != MSDP_VAL && *b != MSDP_ARRAY_CLOSE && *b != MSDP_TABLE_CLOSE) return false; std::string value((const char*)(p+1), b-p-1); if (m_utf8_encoding) { lua_pushstring(L, value.c_str()); } else { std::string newval; const char* b0 = value.c_str(); const tbyte* b = (const tbyte*)b0; const tbyte* e = b + value.length(); while (b != e) { const tbyte *p = b; while (p!=e && *p!=0xff) p++; if (p==e) break; p++; if (p==e) break; newval.append((const char*)b, p-b); if (*p == 0xff) { p++; } b = p; } newval.append((const char*)b); TA2W ws(newval.c_str()); luaT_pushwstring(L, ws); } lua_settable(L, -3); c.p = b; return true; } else if (*b == MSDP_ARRAY_OPEN) { c.p = b+1; if (c.p == c.e) return false; int index = 1; // index for array's vars lua_newtable(L); // table for array while(true) { lua_pushinteger(L, index++); if (!process_val(c)) { lua_pop(L, 2); return false; } if (*c.p != MSDP_VAL && *c.p != MSDP_ARRAY_CLOSE) { lua_pop(L, 2); return false; } if (*c.p == MSDP_ARRAY_CLOSE) { lua_settable(L, -3); c.p++; return true; } } } else if (*b == MSDP_TABLE_OPEN) { c.p = b+1; if (c.p == c.e) return false; lua_newtable(L); // table for table while (true) { if (!process_var(c)) { lua_pop(L, 1); return false; } if (!process_val(c)) { lua_pop(L, 2); return false; } if (*c.p != MSDP_VAR && *c.p != MSDP_TABLE_CLOSE) { lua_pop(L, 2); return false; } if (*c.p == MSDP_TABLE_CLOSE) { lua_settable(L, -3); c.p++; return true; } } } else if (*b == MSDP_VAL || *b == MSDP_VAR) { lua_pushstring(L, ""); lua_settable(L, -3); c.p = b; return true; } return false; }