static reachable_type_t* add_nominal(reachable_method_stack_t** s, reachable_types_t* r, uint32_t* next_type_id, ast_t* type) { const char* type_name = genname_type(type); reachable_type_t* t = reach_type(r, type_name); if(t != NULL) return t; t = add_reachable_type(r, type, type_name); AST_GET_CHILDREN(type, pkg, id, typeparams); ast_t* typeparam = ast_child(typeparams); while(typeparam != NULL) { add_type(s, r, next_type_id, typeparam); typeparam = ast_sibling(typeparam); } ast_t* def = (ast_t*)ast_data(type); switch(ast_id(def)) { case TK_INTERFACE: case TK_TRAIT: add_types_to_trait(s, r, t); break; case TK_PRIMITIVE: add_traits_to_type(s, r, t); add_special(s, t, type, "_init"); add_special(s, t, type, "_final"); break; case TK_STRUCT: case TK_CLASS: add_traits_to_type(s, r, t); add_special(s, t, type, "_final"); add_fields(s, r, next_type_id, type); break; case TK_ACTOR: add_traits_to_type(s, r, t); add_special(s, t, type, "_event_notify"); add_special(s, t, type, "_final"); add_fields(s, r, next_type_id, type); break; default: {} } if(t->type_id == 0) t->type_id = ++(*next_type_id); return t; }
/** * gom_command_builder_build_select: * @builder: (in): A #GomCommandBuilder. * * Builds a #GomCommand that will select all the rows matching the current * query params. * * Returns: (transfer full): A #GomCommand. */ GomCommand * gom_command_builder_build_select (GomCommandBuilder *builder) { GomCommandBuilderPrivate *priv; GomResourceClass *klass; GomCommand *command; GString *str; g_return_val_if_fail(GOM_IS_COMMAND_BUILDER(builder), NULL); priv = builder->priv; klass = g_type_class_ref(priv->resource_type); str = g_string_new("SELECT "); add_fields(str, klass); add_from(str, klass); add_joins(str, klass); add_m2m(str, klass, priv->m2m_table, priv->m2m_type); add_where(str, priv->m2m_type, priv->m2m_table, priv->filter); add_limit(str, priv->limit); add_offset(str, priv->offset); command = g_object_new(GOM_TYPE_COMMAND, "adapter", priv->adapter, "sql", str->str, NULL); bind_params(command, priv->filter); g_type_class_unref(klass); g_string_free(str, TRUE); return command; }
void sinsp_table::add_row(bool merging) { uint32_t j; sinsp_table_field key(m_fld_pointers[0].m_val, m_fld_pointers[0].m_len, m_fld_pointers[0].m_cnt); if(m_type == sinsp_table::TT_TABLE) { // // This is a table. Do a proper key lookup and update the entry // auto it = m_table->find(key); if(it == m_table->end()) { // // New entry // key.m_val = key.m_val; key.m_cnt = 1; m_vals = (sinsp_table_field*)m_buffer->reserve(m_vals_array_sz); for(j = 1; j < m_n_fields; j++) { uint32_t vlen = get_field_len(j); m_vals[j - 1].m_val = m_fld_pointers[j].m_val; m_vals[j - 1].m_len = vlen; m_vals[j - 1].m_cnt = m_fld_pointers[j].m_cnt; } (*m_table)[key] = m_vals; } else { // // Existing entry // m_vals = it->second; for(j = 1; j < m_n_fields; j++) { if(merging) { add_fields(j, &m_fld_pointers[j], m_postmerge_extractors[j]->m_merge_aggregation); } else { add_fields(j, &m_fld_pointers[j], m_premerge_extractors[j]->m_aggregation); } } } } else { // // We are in list mode. Just appen the row to the end of the sample // if(m_paused) { return; } sinsp_sample_row row; // // This is a list. Create the new entry and push it back. // key.m_val = key.m_val; key.m_cnt = 1; row.m_key = key; m_vals = (sinsp_table_field*)m_buffer->reserve(m_vals_array_sz); for(j = 1; j < m_n_fields; j++) { uint32_t vlen = get_field_len(j); m_vals[j - 1].m_val = m_fld_pointers[j].m_val; m_vals[j - 1].m_len = vlen; m_vals[j - 1].m_cnt = 1; row.m_values.push_back(m_vals[j - 1]); } m_full_sample_data.push_back(row); } }
static reach_type_t* add_nominal(reach_t* r, ast_t* type, pass_opt_t* opt) { reach_type_t* t = reach_type(r, type); if(t != NULL) return t; t = add_reach_type(r, type); ast_t* def = (ast_t*)ast_data(type); t->underlying = ast_id(def); AST_GET_CHILDREN(type, pkg, id, typeparams); ast_t* typeparam = ast_child(typeparams); while(typeparam != NULL) { add_type(r, typeparam, opt); typeparam = ast_sibling(typeparam); } switch(ast_id(def)) { case TK_INTERFACE: case TK_TRAIT: add_types_to_trait(r, t, opt); break; case TK_PRIMITIVE: add_traits_to_type(r, t, opt); add_special(r, t, type, "_init", opt); add_special(r, t, type, "_final", opt); break; case TK_STRUCT: case TK_CLASS: add_traits_to_type(r, t, opt); add_special(r, t, type, "_final", opt); add_fields(r, t, opt); break; case TK_ACTOR: add_traits_to_type(r, t, opt); add_special(r, t, type, "_event_notify", opt); add_special(r, t, type, "_final", opt); add_fields(r, t, opt); break; default: {} } if(t->type_id == (uint32_t)-1) t->type_id = r->next_type_id++; if(ast_id(def) != TK_PRIMITIVE) return t; if(strcmp(ast_name(pkg), "$0")) return t; const char* name = ast_name(id); if(name[0] == 'I') { if(!strcmp(name, "I8")) t->mangle = "c"; else if(!strcmp(name, "I16")) t->mangle = "s"; else if(!strcmp(name, "I32")) t->mangle = "i"; else if(!strcmp(name, "I64")) t->mangle = "w"; else if(!strcmp(name, "I128")) t->mangle = "q"; else if(!strcmp(name, "ILong")) t->mangle = "l"; else if(!strcmp(name, "ISize")) t->mangle = "z"; } else if(name[0] == 'U') { if(!strcmp(name, "U8")) t->mangle = "C"; else if(!strcmp(name, "U16")) t->mangle = "S"; else if(!strcmp(name, "U32")) t->mangle = "I"; else if(!strcmp(name, "U64")) t->mangle = "W"; else if(!strcmp(name, "U128")) t->mangle = "Q"; else if(!strcmp(name, "ULong")) t->mangle = "L"; else if(!strcmp(name, "USize")) t->mangle = "Z"; } else if(name[0] == 'F') { if(!strcmp(name, "F32")) t->mangle = "f"; else if(!strcmp(name, "F64")) t->mangle = "d"; } else if(!strcmp(name, "Bool")) { t->mangle = "b"; } return t; }
TableDef(int string_fields, int double_fields, int int_fields) { add_fields(INT, int_fields + 1); add_fields(STRING, string_fields); add_fields(DOUBLE, double_fields); table_name = "test_" + boost::lexical_cast<std::string>(rand() % 1000000); }