Exemple #1
0
void TypeCompiler::visitName(NameAST *node)
{

  NameCompiler name_cc(m_session, m_visitor);
  name_cc.run(node);
  m_type = name_cc.qualifiedName();
  m_templateArgs = name_cc.templateArguments();
}
void DeclaratorCompiler::run(DeclaratorAST *node)
{
  _M_id.clear();
  _M_parameters.clear();
  _M_array.clear();
  _M_function = false;
  _M_reference = false;
  _M_variadics = false;
  _M_indirection = 0;

  if (node)
    {
      NameCompiler name_cc(_M_binder);

      DeclaratorAST *decl = node;
      while (decl && decl->sub_declarator)
        decl = decl->sub_declarator;

      Q_ASSERT (decl != 0);

      name_cc.run(decl->id);
      _M_id = name_cc.name();
      _M_function = (node->parameter_declaration_clause != 0);
      if (node->parameter_declaration_clause && node->parameter_declaration_clause->ellipsis)
        _M_variadics = true;

      visitNodes(this, node->ptr_ops);
      visit(node->parameter_declaration_clause);

      if (const ListNode<ExpressionAST*> *it = node->array_dimensions)
        {
          it->toFront();
          const ListNode<ExpressionAST*> *end = it;

          do
            {
              QString elt;
              if (ExpressionAST *expr = it->element)
                {
                  const Token &start_token = _M_token_stream->token((int) expr->start_token);
                  const Token &end_token = _M_token_stream->token((int) expr->end_token);

                  elt += QString::fromUtf8(&start_token.text[start_token.position],
                                           (int) (end_token.position - start_token.position)).trimmed();
                }

              _M_array.append (elt);

              it = it->next;
            }
          while (it != end);
        }
    }
}
Exemple #3
0
void TypeCompiler::visitParameterDeclaration(ParameterDeclarationAST* node)
{
    TypeCompiler tc(m_session, m_visitor);
    tc.run(node->type_specifier, node->declarator);
    NameCompiler name_cc(m_session, m_visitor);
    if (tc.type().isFunctionPointer() && node->declarator && node->declarator->sub_declarator)
        name_cc.run(node->declarator->sub_declarator->id);
    else if (node->declarator)
        name_cc.run(node->declarator->id);
    m_realType.appendParameter(Parameter(name_cc.name(), Type::registerType(tc.type())));
}
Exemple #4
0
void TypeCompiler::run(const DeclaratorAST* declarator)
{
    if (declarator->ptr_ops)
        run(declarator->ptr_ops);
    
    if (declarator->array_dimensions) {
        const ListNode<ExpressionAST*>* it = declarator->array_dimensions->toFront(), *end = it;
        int dim = 0;
        m_realType.setArrayDimensions(declarator->array_dimensions->count());
        do {
            PrimaryExpressionAST* primary = ast_cast<PrimaryExpressionAST*>(it->element);
            if (primary) {
                QByteArray token = m_session->token_stream->token(primary->token).symbolByteArray();
                bool ok = false;
                int length = token.toInt(&ok);
                if (ok) {
                    m_realType.setArrayLength(dim++, length);
                } else {
                    m_realType.setPointerDepth(m_realType.pointerDepth() + 1);
                }
            } else {
                m_realType.setPointerDepth(m_realType.pointerDepth() + 1);
            }
            it = it->next;
        } while (it != end);
        if (dim != m_realType.arrayDimensions()) {
            m_realType.setArrayDimensions(dim);
        }
    }
    
    NameCompiler name_cc(m_session, m_visitor);
    name_cc.run(declarator->id);
    if (declarator->parameter_declaration_clause && declarator->sub_declarator && name_cc.qualifiedName().isEmpty()) {
        m_realType.setIsFunctionPointer(true);
        visit(declarator->parameter_declaration_clause);
    }
}
void TypeCompiler::visitName(NameAST *node) {
    NameCompiler name_cc(_M_binder);
    name_cc.run(node);
    _M_type = name_cc.qualifiedName();
}
Exemple #6
0
void TypeCompiler::visitName(NameAST *node)
{
  NameCompiler name_cc(m_session);
  name_cc.run(node);
  m_type = name_cc.qualifiedName();
}