Ejemplo n.º 1
0
//
// getHostName()
//
const char* InetSocketAddress::getHostName()
throw()
{
    if (isUnresolved())
    {
        return NULL;
    }

    //return _addr.getHostName();
    return _addr->getHostName();
}
Ejemplo n.º 2
0
int Scanner::getNextToken(ScannerToken &t, Location &l) {
  int tokid;
  bool la = !m_lookahead.empty();
  tokid = fetchToken(t, l);
  if (LIKELY(!isUnresolved(tokid))) {
    // In the common case, we don't have to perform any resolution
    // and we can just return the token
    if (UNLIKELY(la)) {
      // If we pulled a lookahead token, we need to remove it from
      // the lookahead store
      m_lookahead.popFront();
    }
    return tokid;
  }

  if (!la) {
    // If this token didn't come from the lookahead store, we
    // need to stash it there
    TokenStore::iterator it = m_lookahead.appendNew();
    LookaheadToken ltd = { t, l, tokid };
    *it = ltd;
  }

  switch (tokid) {
  case T_UNRESOLVED_NEWTYPE:
  case T_UNRESOLVED_TYPE: {
    auto pos = m_lookahead.begin();
    auto typePos = pos;
    nextLookahead(pos);
    if (isValidClassConstantName(pos->t)) {
      typePos->t = tokid == T_UNRESOLVED_TYPE ? T_TYPE : T_NEWTYPE;
    } else {
      typePos->t = T_STRING;
    }
    break;
  }
  case T_UNRESOLVED_LT: {
    // Look at subsequent tokens to determine if the '<' character
    // is the start of a type list
    auto pos = m_lookahead.begin();
    auto ltPos = pos;
    nextLookahead(pos);
    ++m_lookaheadLtDepth;
    bool isTypeList = tryParseTypeList(pos);
    --m_lookaheadLtDepth;
    if (isTypeList && pos->t == '>') {
      ltPos->t = T_TYPELIST_LT;
      pos->t = T_TYPELIST_GT;
    } else {
      ltPos->t = '<';
    }
    break;
  }
  case T_UNRESOLVED_OP: {
    // Look at subsequent tokens to determine if the '(' character
    // is the start of a lambda expression
    auto pos = m_lookahead.begin();
    auto opPos = pos;
    nextLookahead(pos);
    if (pos->t != ')' && pos->t != T_LAMBDA_CP) {
      if (!tryParseNonEmptyLambdaParams(pos) || pos->t != ')') {
        opPos->t = '(';
        break;
      }
    }
    auto cpPos = pos;
    nextLookahead(pos);
    if (pos->t == ':') {
      nextLookahead(pos);
      if (!tryParseNSType(pos)) {
        opPos->t = '(';
        break;
      }
    }
    if (pos->t == T_LAMBDA_ARROW) {
      opPos->t = T_LAMBDA_OP;
      cpPos->t = T_LAMBDA_CP;
    } else {
      opPos->t = '(';
    }
    break;
  }
  default: always_assert(0);
  }

  tokid = fetchToken(t, l);
  // We pulled a lookahead token, we need to remove it from the
  // lookahead store
  m_lookahead.popFront();
  return tokid;
}