Beispiel #1
0
void Struct::CompleteDefinition() {
    if (completed_) {
        return;
    }
    if (!field_num_to_name.empty()) {
        return;
    }

    for (size_t i = 0; i < decls.size(); ++i) {
        decls[i]->verify_types();

        Type *decl_type;
        if (decls[i]->type_expr) {
            if (decls[i]->type_expr->type == Err ||
                    decls[i]->type_expr->type == Void ||
                    decls[i]->type_expr->type->is_parametric_struct()) {
                decl_type = Err;
            } else {
                decl_type = Evaluate(decls[i]->type_expr).as_val->GetType();
            }
        } else {
            decl_type = decls[i]->init_val->type;
        }

        insert_field(decls[i]->identifier->token, decl_type, decls[i]->init_val);
    }
    completed_ = true;
}
Beispiel #2
0
Datei: ref.cpp Projekt: att/uwin
void reference::set_date(string &d)
{
  if (d.length() == 0)
    delete_field('D');
  else
    insert_field('D', d);
}
Beispiel #3
0
/* Parse and insert output fields from format string */
void parse_format_string(char *str) {
        char *name, *tmp, *i;
        int num_nodes = 0;
        size_t len;

#ifdef DEBUG
        ASSERT(str);
#endif

        len = strlen(str);
        if (len == 0)
                LOG_DIE("Empty format string provided");

        /* Make a temporary copy of the string so we don't modify the original */
        if ((tmp = str_duplicate(str)) == NULL)
                LOG_DIE("Cannot allocate memory for format string buffer");

        for (i = tmp; (name = strtok(i, ",")); i = NULL) {
                /* Normalize input field text */
                name = str_strip_whitespace(name);
                name = str_tolower(name);
                len = strlen(name);

                if (len == 0) continue;
                if (insert_field(name, len)) num_nodes++;
        }

        free(tmp);

        if (num_nodes == 0)
                LOG_DIE("No valid fields found in format string");

#ifdef DEBUG
        int j, num_buckets = 0, num_chain, max_chain = 0;
        FORMAT_NODE *node;

        for (j = 0; j < HASHSIZE; j++) {
                if (fields[j]) num_buckets++;

                num_chain = 0;
                for (node = fields[j]; node != NULL; node = node->next) num_chain++;
                if (num_chain > max_chain) max_chain = num_chain;
        }

        PRINT("----------------------------");
        PRINT("Hash buckets:       %d", HASHSIZE);
        PRINT("Nodes inserted:     %d", num_nodes);
        PRINT("Buckets in use:     %d", num_buckets);
        PRINT("Hash collisions:    %d", num_nodes - num_buckets);
        PRINT("Longest hash chain: %d", max_chain);
        PRINT("----------------------------");
#endif

        return;
}
static inline void
insert_fields (aarch64_insn *code, aarch64_insn value, aarch64_insn mask, ...)
{
  uint32_t num;
  const aarch64_field *field;
  enum aarch64_field_kind kind;
  va_list va;

  va_start (va, mask);
  num = va_arg (va, uint32_t);
  assert (num <= 5);
  while (num--)
    {
      kind = va_arg (va, enum aarch64_field_kind);
      field = &fields[kind];
      insert_field (kind, code, value, mask);
      value >>= field->width;
    }
  va_end (va);
}