Exemple #1
0
BOOL CSxSParser::ParseFile(LPCTSTR szFilePath)
{
    CPEResource res;
    if(!res.Open(szFilePath))
        return FALSE;

    LPVOID pData = NULL;
    DWORD dwLength = 0;
    if(!res.GetManifest(pData, dwLength))
        return FALSE;

    if(pData == NULL)
        return TRUE;

    CStringA strManifest;
    LPSTR pManifest = strManifest.GetBufferSetLength(dwLength);
    memcpy(pManifest, pData, dwLength);
    strManifest.ReleaseBuffer();

    int nStart = 0;
    CStringA strAssembly = Util::GetToken(strManifest, "<dependentAssembly>", "</dependentAssembly>", nStart);
    for(; !strAssembly.IsEmpty(); strAssembly = Util::GetToken(strManifest, "<dependentAssembly>", "</dependentAssembly>", nStart))
    {
        CSxSItem item;

        if(!ParseAssembly(strAssembly, item))
            return FALSE;

        item.listFiles.Add(szFilePath);
        AddAssemblyItem(item);
    }

    return TRUE;
}
void CodeGeneratorTest::ParseC(const char *Code) {
  char codefile[] = "ccode.XXXXXX.c";
  int fd = mkstemps(codefile, 2);

  writeFile(codefile, Code);

  std::string command = "./clang -S -emit-llvm '" + std::string(codefile) + "'";
  int result = system(command.c_str());
  EXPECT_EQ(result, 0);
  if (result != 0)
    throw std::runtime_error("clang returned a non-zero status.");

  close(fd);

  std::string assemblyfile = std::string(codefile).substr(0, strlen(codefile)-2) + ".ll";
  std::string assembly = readFile(assemblyfile);

  writeFile("assembly-current.ll", assembly);

  remove(codefile);
  remove(assemblyfile.c_str());

  ParseAssembly(assembly.c_str());
}