コード例 #1
0
ファイル: symbolTable.cpp プロジェクト: jirkadanek/Strongtalk
void symbolTable::add(symbolOop s) {
  assert(s->is_symbol(),
         "adding something that's not a symbol to the symbol table");
  assert(s->is_old(), "all symbols should be tenured");
  int hashValue = hash((char*) s->bytes(), s->length());
  basic_add(s, hashValue);
}
コード例 #2
0
static bool print_selector_with_arguments(prettyPrintStream*       output, 
                                          symbolOop                selector,
                                          GrowableArray<astNode*>* arguments,
                                          bool                     split) {
  if (selector->is_binary()) {
    // binary send
    output->print(selector->as_string());
    output->space();
    astNode* arg = arguments->at(0);
    bool wrap = should_wrap(1, arg);
    if (wrap) output->print("(");
    bool result = arg->print(output);
    if (wrap) output->print(")");
    return result;
  }

  int arg = arguments->length();

  if (arg == 0) {
    output->print(selector->as_string());
    return false;
  }

  for (int index = 1; index <= selector->length(); index++) {
    int c = selector->byte_at(index);
    output->print_char(c);
    if (c == ':') {
      output->space();
      astNode* a = arguments->at(--arg);
      bool wrap = should_wrap(2, a);
      if (wrap) output->print("(");
      a->print(output); 
      if (wrap) output->print(")");
         
      if (index < selector->length()) {
      	if (split) output->newline();
        else       output->space();
      }
    }
  }
  return split;
}
コード例 #3
0
ファイル: symbolTable.cpp プロジェクト: jirkadanek/Strongtalk
bool symbolTable::is_present(symbolOop sym) {
  char* name = (char*) sym->bytes();
  int   len  = sym->length();
  int hashValue = hash(name, len);
  symbolTableEntry* bucket = bucketFor(hashValue);
  if (bucket->is_empty()) return false;
  if (bucket->is_symbol())
    return bucket->get_symbol()->equals(name, len);
  for (symbolTableLink* l = bucket->get_link(); l; l = l->next)
    if (l->symbol->equals(name, len)) return true;
  return false;
}
コード例 #4
0
ファイル: symbolTable.cpp プロジェクト: jirkadanek/Strongtalk
void symbolTable::add_symbol(symbolOop s) {
  basic_add(s, hash((char*) s->bytes(), s->length()));
}