Ejemplo n.º 1
0
void CaseInsensitiveHashTable<T>::reindex() {
  for (size_t i = 0; i < entries_.size(); ++i) {
    T* entry = &entries_[i];
    entry->index = i;
    add_index(entry);
  }
}
Ejemplo n.º 2
0
  Address2 bytecode_impl(Register reg) { 
#if !ENABLE_THUMB_GP_TABLE
    return add_index(gp, reg, lsl, 2);
#else
    return sub_index(gp, reg, lsl, 2);
#endif
  }
Ejemplo n.º 3
0
 /// for setDeferHash where you've left some gaps (default constructed elements in vals_)
 void rehash_except_pow2(I capacityPowerOf2, T const& except = T()) {
   init_empty_hash(capacityPowerOf2);
   for (I vali = 0, valn = vals_.size(); vali < valn; ++vali) {
     T const& val = vals_[vali];
     if (val != except) add_index(vali, val);
   }
   check_index();
 }
Ejemplo n.º 4
0
void SyntaxAnalyzer::op3()
{
	if (cur->type==number) {
		PolizInt* tmp = new PolizInt(atoi(cur->lex));
		add_poliz_list(tmp);
		next();
	} else
	if (cur->type==variable) {
		PolizString* tmp = new PolizString(cur->lex);
		add_poliz_list(tmp);
		next();
		if (strcmp(cur->lex, "[")==0) {
			next();
			expression();
			if (strcmp(cur->lex, "]")!=0)
				throw Exeption("']' expected", cur->num_str, cur->lex);
			next();
			add_index();
		} else 
			add_nul_index();
		PolizVar* tmp2 = new PolizVar;
		add_poliz_list(tmp2);
	}
	else
	if (cur->type==function_without_param) {
		PolizFunNoParam* tmp = new PolizFunNoParam(cur->lex);
		add_poliz_list(tmp);
		next();
	}
	else
	if (cur->type==function_with_param) {
		PolizFunParam* tmp = new PolizFunParam(cur->lex);
		next();
		if (strcmp(cur->lex, "(")!=0)
			throw Exeption("'(' expected in funct",
				cur->num_str, cur->lex);
		next();
		expression();
		if (strcmp(cur->lex, ")")!=0)
			throw Exeption("')' expected in funct",
				cur->num_str, cur->lex);
		next();
		add_poliz_list(tmp);
	}
	else
	{
		if (strcmp(cur->lex, "(")!=0)
			throw Exeption("'(' expected", cur->num_str, cur->lex);
		next();
		expression();
		if (strcmp(cur->lex, ")")!=0)
			throw Exeption("')' expected", cur->num_str, cur->lex);
		next();
	}
}
Ejemplo n.º 5
0
size_t CaseInsensitiveHashTable<T>::add(const T& entry) {
  size_t index = entries_.size();
  size_t capacity = entries_.capacity();
  if (index >= capacity) {
    resize(2 * capacity);
  }
  entries_.push_back(entry);
  T* back = &entries_.back();
  back->index = index;
  add_index(back);
  return index;
}
Ejemplo n.º 6
0
INDEX *get_indices(DOC *head, char *str)
{
    INDEX list;
    DOC *p;
    list.next = NULL;
    for (p = head->next; p != NULL; p = p->next)
    {
        if (strstr(p->body, str) != NULL)
        {
            add_index(&list, p->id);
        }
    }
    
    return list.next;
}
Ejemplo n.º 7
0
int write_mail(string who, object mail) {
   string filename;
   object usr;

   filename = get_filename(who);
   if (mail->save_me(DATA_DIR + "/" + who + "/" + filename)) {
      if (add_index(who,mail,filename)) {

         if (usr = USER_D->find_player(who)) {
            usr->message("You have new email.\n");
         }
         return 1;
      } else {
         return 0;
      }
   } else {
      return 0;
   }
}
Ejemplo n.º 8
0
void SyntaxAnalyzer::assignment_statement()
{
	if (cur->type == assignment) {
		add_nul_index();
		next();
	} else
	if (strcmp(cur->lex, "[")==0) {
		next();
		expression();
		if (strcmp(cur->lex, "]")!=0)
			throw Exeption("']' expected", cur->num_str, cur->lex);
		next();
		if (cur->type != assignment)
			throw Exeption("':=' expected", cur->num_str, cur->lex);
		next();
		add_index();
	}
	else
		throw Exeption("':=' or index expected",cur->num_str, cur->lex);
	expression();
	if (strcmp(cur->lex,";")!=0)
		throw Exeption("';' expected", cur->num_str, cur->lex);
	next();
}
Ejemplo n.º 9
0
bool PhraseLargeTable3::load_text(FILE * infile){
    char pinyin[256];
    char phrase[256];
    phrase_token_t token;
    size_t freq;

    while (!feof(infile)) {
        int num = fscanf(infile, "%255s %255s %u %ld",
                         pinyin, phrase, &token, &freq);

        if (4 != num)
            continue;

        if (feof(infile))
            break;

        glong phrase_len = g_utf8_strlen(phrase, -1);
        ucs4_t * new_phrase = g_utf8_to_ucs4(phrase, -1, NULL, NULL, NULL);
        add_index(phrase_len, new_phrase, token);

        g_free(new_phrase);
    }
    return true;
}
Ejemplo n.º 10
0
void InterpreterStubs::generate_interpreter_fill_in_tags() {
  Segment seg(this, code_segment, "Interpreter fill in tags");

  Register param_size = tmp0; // must be preserved
  Register callinfo   = tmp1;

  {
      bind_local("interpreter_fill_in_tags");
      comment("%s: size of parameters",       reg_name(tmp0));
      comment("%s: call info from call size", reg_name(tmp1));
      comment("");
      comment("Must preserve lr, %s (method), and %s (parameter size)", 
              reg_name(r0), reg_name(tmp0));

      Label loop_entry;

      // tos_val = r0 must be preserved
      Register arg_index  = tmp2;
      Register one_reg    = tmp3;
      Register tag_address = JavaStackDirection < 0 ? tmp4 : jsp;

      mov_imm(one_reg, 1 << CallInfo::format1_tag_start);
      sub(arg_index, param_size, one, set_CC);
      report_fatal("shouldn't be called on no arguments", lt);

      if (JavaStackDirection < 0) { 
        comment("Tag address of last argument");
        add(tag_address, jsp, imm(BytesPerWord));
      } else { 
        comment("jsp points to tag address of last argument");
      }

    bind(loop_entry);
      comment("test the bit in the call info");
      tst(callinfo, reg_shift(one_reg, lsl, arg_index));

      mov(tos_tag, imm(obj_tag), ne);
      mov(tos_tag, imm(int_tag), eq);
      if (JavaStackDirection < 0) { 
        str(tos_tag, add_index(tag_address, arg_index, lsl, 3));
      } else {
        str(tos_tag, sub_index(tag_address, arg_index, lsl, 3));
      }
      sub(arg_index, arg_index, one, set_CC);
      b(loop_entry, ge);
      mov(pc, reg(locals));
  }
  {
    Register bit_offset  = tmp1; // callinfo not needed
    Register one_reg     = tmp2;
    Register tag_address = tmp3;
    Register x1          = tmp4;
    Register x2          = tmp5;
    Register index       = tos_tag;
    Label loop;

    bind_local("interpreter_fill_in_extended_tags");
       comment("Total number of tags");
       if (HARDWARE_LITTLE_ENDIAN) {
         ldrh(bit_offset, imm_index3(lr, -2 * BytesPerWord));
       } else {
         ldrh(bit_offset, imm_index3(lr, -2 * BytesPerWord + 2));
       }

       comment("Tag address of first argument");
       if (JavaStackDirection < 0) {
         add(tag_address, jsp, imm_shift(param_size, lsl, 3));
       } else { 
         sub(tag_address, jsp, imm_shift(param_size, lsl, 3));
       }
       // tag_address points to the last address of the previous stack
       add_imm(tag_address, tag_address,
               JavaFrame::arg_offset_from_sp(-1) + BytesPerWord);

       comment("Index of last argument");
       sub(index, param_size, one);    

       comment("Bit number of first argument");
       sub(bit_offset, bit_offset, reg(param_size));
       mov(bit_offset, imm_shift(bit_offset, lsl, 2));
       add(bit_offset, bit_offset, imm(32 + 32 + 16));

       comment("A useful constant");
       mov(one_reg, one);

    bind(loop);
       comment("Get the bit offset for this argument");
       add(x1, bit_offset, imm_shift(index, lsl, 2));

       comment("Get the appropriate word");
       mov(x2, imm_shift(x1, lsr, 5));
       ldr(x2, sub_index(lr, x2, lsl, 2));

       comment("Pick out the nybble");
       andr(x1, x1, imm(31));
       mov(x2, reg_shift(x2, lsr, x1));
       andr(x2, x2, imm(15), set_CC);

       comment("Convert the nybble into a stack type");
       sub(x2, x2, one,                     ne);
       mov(x2, reg_shift(one_reg, lsl, x2), ne);
       if (JavaStackDirection < 0) {
         str(x2, sub_index(tag_address, index, lsl, 3));
       } else {
         str(x2, add_index(tag_address, index, lsl, 3));
       }
       comment("Update the info");
       sub(index, index, one, set_CC);
       b(loop, ge);
       mov(pc, reg(locals));
  }
}
Ejemplo n.º 11
0
static gboolean
xmms_cue_browse (xmms_xform_t *xform,
                 const gchar *url,
                 xmms_error_t *error)
{
	gchar line[XMMS_XFORM_MAX_LINE_SIZE];
	cue_track track;
	gchar *p;

	g_return_val_if_fail (xform, FALSE);

	memset (&track, 0, sizeof (cue_track));

	if (!xmms_xform_read_line (xform, line, error)) {
		xmms_error_set (error, XMMS_ERROR_INVAL, "error reading cue-file!");
		return FALSE;
	}

	do {
		p = skip_white_space (line);
		if (g_ascii_strncasecmp (p, "FILE", 4) == 0) {
			if (track.file[0]) {
				add_track (xform, &track);
			}
			p = skip_to_char (p, '"');
			p ++;
			save_to_char (p, '"', track.file);
		} else if (g_ascii_strncasecmp (p, "TRACK", 5) == 0) {
			p = skip_to_char (p, ' ');
			p = skip_white_space (p);
			p = skip_to_char (p, ' ');
			p = skip_white_space (p);
			if (g_ascii_strncasecmp (p, "AUDIO", 5) == 0) {
				cue_track *t = g_new0 (cue_track, 1);
				track.tracks = g_list_prepend (track.tracks, t);
			}
		} else if (g_ascii_strncasecmp (p, "INDEX", 5) == 0) {
			cue_track *t = g_list_nth_data (track.tracks, 0);
			if (!t) {
				continue;
			}
			p = skip_to_char (p, ' ');
			p = skip_white_space (p);
			p = skip_to_char (p, ' ');
			p = skip_white_space (p);
			add_index (t, p);
		} else if (g_ascii_strncasecmp (p, "TITLE", 5) == 0) {
			cue_track *t = g_list_nth_data (track.tracks, 0);

			p = skip_to_char (p, '"');
			p ++;

			if (!t) {
				save_to_char (p, '"', track.album);
			} else {
				save_to_char (p, '"', t->title);
			}
		} else if (g_ascii_strncasecmp (p, "PERFORMER", 9) == 0) {
			cue_track *t = g_list_nth_data (track.tracks, 0);

			p = skip_to_char (p, '"');
			p ++;

			if (!t) {
				save_to_char (p, '"', track.artist);
			} else {
				save_to_char (p, '"', t->artist);
			}
		}
	} while (xmms_xform_read_line (xform, line, error));

	if (track.file[0]) {
		add_track (xform, &track);
	}

	xmms_error_reset (error);

	return TRUE;
}
Ejemplo n.º 12
0
void MPIDI_OFI_index_datatypes()
{
    static bool needs_init = true;
    int index = 0;

    if (!needs_init)
        return;

    add_index(MPI_CHAR, &index);
    add_index(MPI_UNSIGNED_CHAR, &index);
    add_index(MPI_SIGNED_CHAR, &index);
    add_index(MPI_BYTE, &index);
    add_index(MPI_WCHAR, &index);
    add_index(MPI_SHORT, &index);
    add_index(MPI_UNSIGNED_SHORT, &index);
    add_index(MPI_INT, &index);
    add_index(MPI_UNSIGNED, &index);
    add_index(MPI_LONG, &index);        /* count=10 */
    add_index(MPI_UNSIGNED_LONG, &index);
    add_index(MPI_FLOAT, &index);
    add_index(MPI_DOUBLE, &index);
    add_index(MPI_LONG_DOUBLE, &index);
    add_index(MPI_LONG_LONG, &index);
    add_index(MPI_UNSIGNED_LONG_LONG, &index);
    add_index(MPI_PACKED, &index);
    add_index(MPI_LB, &index);
    add_index(MPI_UB, &index);
    add_index(MPI_2INT, &index);        /* count=20 */

    /* C99 types */
    add_index(MPI_INT8_T, &index);
    add_index(MPI_INT16_T, &index);
    add_index(MPI_INT32_T, &index);
    add_index(MPI_INT64_T, &index);
    add_index(MPI_UINT8_T, &index);
    add_index(MPI_UINT16_T, &index);
    add_index(MPI_UINT32_T, &index);
    add_index(MPI_UINT64_T, &index);
    add_index(MPI_C_BOOL, &index);
    add_index(MPI_C_FLOAT_COMPLEX, &index);     /* count=30 */
    add_index(MPI_C_DOUBLE_COMPLEX, &index);
    add_index(MPI_C_LONG_DOUBLE_COMPLEX, &index);

    /* address/offset/count types */
    add_index(MPI_AINT, &index);
    add_index(MPI_OFFSET, &index);
    add_index(MPI_COUNT, &index);       /* count=35 */

    /* Fortran types (count=23) */
#ifdef HAVE_FORTRAN_BINDING
    add_index(MPI_COMPLEX, &index);
    add_index(MPI_DOUBLE_COMPLEX, &index);
    add_index(MPI_LOGICAL, &index);
    add_index(MPI_REAL, &index);
    add_index(MPI_DOUBLE_PRECISION, &index);    /* count=40 */
    add_index(MPI_INTEGER, &index);
    add_index(MPI_2INTEGER, &index);
#ifdef MPICH_DEFINE_2COMPLEX
    add_index(MPI_2COMPLEX, &index);
    add_index(MPI_2DOUBLE_COMPLEX, &index);
#endif
    add_index(MPI_2REAL, &index);
    add_index(MPI_2DOUBLE_PRECISION, &index);
    add_index(MPI_CHARACTER, &index);
    add_index(MPI_REAL4, &index);
    add_index(MPI_REAL8, &index);
    add_index(MPI_REAL16, &index);      /* count=50 */
    add_index(MPI_COMPLEX8, &index);
    add_index(MPI_COMPLEX16, &index);
    add_index(MPI_COMPLEX32, &index);
    add_index(MPI_INTEGER1, &index);
    add_index(MPI_INTEGER2, &index);
    add_index(MPI_INTEGER4, &index);
    add_index(MPI_INTEGER8, &index);

    if (MPI_INTEGER16 == MPI_DATATYPE_NULL)
        index++;
    else
        add_index(MPI_INTEGER16, &index);

#endif
    add_index(MPI_FLOAT_INT, &index);
    add_index(MPI_DOUBLE_INT, &index);  /* count=60 */
    add_index(MPI_LONG_INT, &index);
    add_index(MPI_SHORT_INT, &index);
    add_index(MPI_LONG_DOUBLE_INT, &index);

    /* check if static dt_size is correct */
    MPIR_Assert(MPIDI_OFI_DT_SIZES == index);

    /* do not generate map when atomics are not enabled */
    if (MPIDI_OFI_ENABLE_ATOMICS)
        create_dt_map();

    /* only need to do this once */
    needs_init = false;
}
Ejemplo n.º 13
0
 void set(I i, Key const& val, bool mustBeNew = true) {
   grow(vals_, i) = val;
   add_index(i, vals_[i]);
 }
Ejemplo n.º 14
0
 void rehash_pow2(I capacityPowerOf2) {
   init_empty_hash(capacityPowerOf2);
   setGrowAt(capacityPowerOf2);
   for (I vali = 0, valn = vals_.size(); vali < valn; ++vali) add_index(vali, vals_[vali]);
   check_index();
 }