void GenerateForwardParserRule::operator()(QPair<QString, Model::SymbolItem*> const &__it)
{
  Model::SymbolItem *sym = __it.second;
  out << "bool" << " " << "parse" << sym->mCapitalizedName << "(";

  GenerateParseMethodSignature gen_signature(out, 0);
  gen_signature(sym);

  out << ");" << endl;
}
Beispiel #2
0
/**
 * Create a new certificate.
 */
EXP_FUNC int STDCALL ssl_x509_create(SSL_CTX *ssl_ctx, uint32_t options, const char * dn[], uint8_t **cert_data)
{
    int ret = X509_OK, offset = 0, seq_offset;
    /* allocate enough space to load a new certificate */
    uint8_t *buf = (uint8_t *)alloca(ssl_ctx->rsa_ctx->num_octets*2 + 512);
    uint8_t sha_dgst[SHA1_SIZE];
    int seq_size = pre_adjust_with_size(ASN1_SEQUENCE, 
                                    &seq_offset, buf, &offset);

    if ((ret = gen_tbs_cert(dn, ssl_ctx->rsa_ctx, buf, &offset, sha_dgst)) < 0)
        goto error;

    gen_signature_alg(buf, &offset);
    gen_signature(ssl_ctx->rsa_ctx, sha_dgst, buf, &offset);
    adjust_with_size(seq_size, seq_offset, buf, &offset);
    *cert_data = (uint8_t *)malloc(offset); /* create the exact memory for it */
    memcpy(*cert_data, buf, offset);

error:
    return ret < 0 ? ret : offset;
}
void GenerateParserRule::operator()(QPair<QString, Model::SymbolItem*> const &__it)
{
  mNames.clear();
  Model::SymbolItem *sym = __it.second;
  CodeGenerator cg(out, &mNames, sym);

  out << "bool Parser::parse" << sym->mCapitalizedName << "(";

  GenerateParseMethodSignature gen_signature(out, &mNames);
  gen_signature(sym);

  out << ")" << endl
      << "{" << endl;

  if (globalSystem.generateAst)
    {
      if(isOperatorSymbol(sym))
        out << "QVector<OperatorStackItem> opStack;" << endl;
      else
      {
        out << "*yynode = create<" << sym->mCapitalizedName << "Ast" << ">();" << endl << endl
            << "(*yynode)->startToken = tokenStream->index() - 1;" << endl;
        //Generate initialization for this ast nodes token-members using -1 as invalid value
        GenerateTokenVariableInitialization gentokenvar( out );
        gentokenvar(sym);
        out << endl;
      }
    }

  World::Environment::iterator it = globalSystem.env.find(sym);
  GenerateLocalDeclarations gen_locals(out, &mNames);
  while (it != globalSystem.env.end())
    {
      Model::EvolveItem *e = (*it);
      if (it.key() != sym)
        break;

      ++it;
      gen_locals(e->mDeclarations);
    }

  it = globalSystem.env.find(sym);
  bool initial = true;
  while (it != globalSystem.env.end())
    {
      Model::EvolveItem *e = (*it);
      if (it.key() != sym)
        break;

      ++it;

      if (!initial)
        out << "else ";

      cg(e);
      initial = false;
    }

  out << "else" << endl << "{ return false; }" << endl
      << endl;


  if (globalSystem.generateAst)
    {
      if(isOperatorSymbol(sym))
      {
        out << "AstNode *olast, *last = 0;"
               "while(!opStack.empty())\n"
               "{"
               "olast = last;"
               "last = opStack.last().n;"
               "if(olast)\n"
               "last->endToken = olast->endToken;"
               "opStack.pop_back();"
               "}" << endl;
      }
      else
      {
        out << "(*yynode)->endToken = tokenStream->index() - 2;" << endl
            << endl;
      }
    }

  out << "return true;" << endl
      << "}" << endl
      << endl;
}