示例#1
0
    const std::set<std::string>& createBitCode(ClangCompiler<Base>& clang,
                                               const std::string& version) {
        // backup output format so that it can be restored
        OStreamConfigRestore coutb(std::cout);

        if (clang.getVersion() != version) {
            auto expected = ClangCompiler<Base>::parseVersion(version);
            auto execVersion = ClangCompiler<Base>::parseVersion(clang.getVersion());
            bool error = expected.size() > execVersion.size();
            if (!error) {
                for (size_t i = 0; i < expected.size(); ++i) {
                    if (expected[i] != execVersion[i]) {
                        error = true;
                        break;
                    }
                }
            }
            if (error) {
                throw CGException("Expected a clang with version '", version, "' but found version '", clang.getVersion(), "'");
            }
        }

        const std::map<std::string, ModelCSourceGen<Base>*>& models = this->modelLibraryHelper_->getModels();
        try {
            /**
             * generate bit code
             */
            for (const auto& p : models) {
                const std::map<std::string, std::string>& modelSources = this->getSources(*p.second);

                this->modelLibraryHelper_->startingJob("", JobTimer::COMPILING_FOR_MODEL);
                clang.generateLLVMBitCode(modelSources, this->modelLibraryHelper_);
                this->modelLibraryHelper_->finishedJob();
            }

            const std::map<std::string, std::string>& sources = this->getLibrarySources();
            clang.generateLLVMBitCode(sources, this->modelLibraryHelper_);

            const std::map<std::string, std::string>& customSource = this->modelLibraryHelper_->getCustomSources();
            clang.generateLLVMBitCode(customSource, this->modelLibraryHelper_);
        } catch (...) {
            clang.cleanup();
            throw;
        }

        return clang.getBitCodeFiles();
    }
    /**
     * Compiles all models and generates a dynamic library.
     * 
     * @param compiler The compiler used to compile the sources and create
     *                 the dynamic library
     * @param loadLib Whether or not to load the dynamic library
     * @return The dynamic library if loadLib is true, nullptr otherwise
     */
    DynamicLib<Base>* createDynamicLibrary(CCompiler<Base>& compiler,
                                           bool loadLib = true) throw (CGException) {
        // backup output format so that it can be restored
        OStreamConfigRestore coutb(std::cout);

        this->modelLibraryHelper_->startingJob("", JobTimer::DYNAMIC_MODEL_LIBRARY);

        const std::map<std::string, ModelCSourceGen<Base>*>& models = this->modelLibraryHelper_->getModels();
        try {
            for (const auto& p : models) {
                const std::map<std::string, std::string>& modelSources = this->getSources(*p.second);

                this->modelLibraryHelper_->startingJob("", JobTimer::COMPILING_FOR_MODEL);
                compiler.compileSources(modelSources, true, this->modelLibraryHelper_);
                this->modelLibraryHelper_->finishedJob();
            }

            const std::map<std::string, std::string>& sources = this->getLibrarySources();
            compiler.compileSources(sources, true, this->modelLibraryHelper_);

            const std::map<std::string, std::string>& customSource = this->modelLibraryHelper_->getCustomSources();
            compiler.compileSources(customSource, true, this->modelLibraryHelper_);

            std::string libname = _libraryName;
            if (_customLibExtension != nullptr)
                libname += *_customLibExtension;
            else
                libname += system::SystemInfo<>::DYNAMIC_LIB_EXTENSION;

            compiler.buildDynamic(libname, this->modelLibraryHelper_);

        } catch (...) {
            compiler.cleanup();
            throw;
        }
        compiler.cleanup();

        this->modelLibraryHelper_->finishedJob();

        if (loadLib)
            return loadDynamicLibrary();
        else
            return nullptr;
    }
    void createStaticLibrary(CCompiler<Base>& compiler,
                             Archiver& ar,
                             bool posIndepCode) {
        // backup output format so that it can be restored
        OStreamConfigRestore coutb(std::cout);

        this->modelLibraryHelper_->startingJob("", JobTimer::STATIC_MODEL_LIBRARY);

        const std::map<std::string, ModelCSourceGen<Base>*>& models = this->modelLibraryHelper_->getModels();
        try {
            for (const auto& p : models) {
                const std::map<std::string, std::string>& modelSources = this->getSources(*p.second);

                this->modelLibraryHelper_->startingJob("", JobTimer::COMPILING_FOR_MODEL);
                compiler.compileSources(modelSources, posIndepCode, this->modelLibraryHelper_);
                this->modelLibraryHelper_->finishedJob();
            }

            const std::map<std::string, std::string>& sources = this->getLibrarySources();
            compiler.compileSources(sources, posIndepCode, this->modelLibraryHelper_);

            const std::map<std::string, std::string>& customSource = this->modelLibraryHelper_->getCustomSources();
            compiler.compileSources(customSource, posIndepCode, this->modelLibraryHelper_);

            std::string libname = _libraryName;
            if (_customLibExtension != nullptr)
                libname += *_customLibExtension;
            else
                libname += system::SystemInfo<>::STATIC_LIB_EXTENSION;

            ar.create(libname, compiler.getObjectFiles(), this->modelLibraryHelper_);
        } catch (...) {
            compiler.cleanup();
            throw;
        }
        compiler.cleanup();

        this->modelLibraryHelper_->finishedJob();
    }
示例#4
0
文件: display.c 项目: mingpen/OpenNT
void
DoStatus (
    void
    ) {
    struct lineAttr rglaStatus[10];		/* color array for status line	*/
    int 	    cch;
    int         ilaStatus  = 0;        /* index into color array       */
    int         i;
    char        *pchEndBuf;           /* save for end of buffer       */
    char        buf[512];


    /*
     * Start with filename, and file type
     */
    strcpy (buf, pFileHead->pName);
    strcat (buf, " (");
    strcpy ((char *)strend(buf), GetFileTypeName ());

    /*
     * Add other file characterisctics
     */
    if (!TESTFLAG (FLAGS (pFileHead), DOSFILE)) {
        strcat (buf," NL");
    }

    if (TESTFLAG (FLAGS (pFileHead), TEMP)) {
        strcat (buf, " temp");
    }

    if ((TESTFLAG (FLAGS (pFileHead), READONLY)) | fGlobalRO) {
        strcat (buf, " No-Edit");
    }

    if (TESTFLAG (FLAGS (pFileHead), DISKRO)) {
        strcat (buf, " RO-File");
    }

    rglaStatus[ilaStatus].attr = CINDEX(staColor);
    rglaStatus[ilaStatus++].len = (unsigned char) strlen (buf);

    if (TESTFLAG (FLAGS(pFileHead), DIRTY)) {
	strcat (buf, " modified");
	rglaStatus[ilaStatus].attr = CINDEX(errColor);
	rglaStatus[ilaStatus++].len = 9;
    }

    pchEndBuf = strend (buf);
    sprintf (strend(buf), ") Length=%ld ", pFileHead->cLines);

    /*
     * Add current location
     */
    if (fDisplayCursorLoc) {
	sprintf (strend(buf), "Cursor=(%ld,%d)", YCUR(pInsCur)+1, XCUR(pInsCur)+1);
    } else {
        sprintf (strend(buf), "Window=(%ld,%d)", YWIN(pInsCur)+1, XWIN(pInsCur)+1);
    }
    rglaStatus[ilaStatus].attr = CINDEX(staColor);
    rglaStatus[ilaStatus++].len = (unsigned char) (strend(buf) - pchEndBuf);

    /*
     * Add global state indicators
     */
    if (fInsert | fMeta | fCtrlc | fMacroRecord) {
	rglaStatus[ilaStatus].attr = CINDEX(infColor);
	rglaStatus[ilaStatus].len = 0;
	if (fInsert) {
	    strcat (buf, " insert");
	    rglaStatus[ilaStatus].len += 7;
        }
	if (fMeta) {
	    strcat (buf, " meta");
	    rglaStatus[ilaStatus].len += 5;
        }
	if (fCtrlc) {
	    strcat (buf, " cancel");
	    rglaStatus[ilaStatus].len += 7;
	    fCtrlc = FALSE;
	    FlushInput ();
        }
	if (fMacroRecord) {
	    strcat (buf, " REC");
	    rglaStatus[ilaStatus].len += 4;
        }
	ilaStatus++;
    }

    rglaStatus[ilaStatus].attr = CINDEX(staColor);
    rglaStatus[ilaStatus].len = 0xffff;
	pchEndBuf = buf;

    /*
     * if the net result is too long, eat the first part of the filename with
     * an elipses (Leave room for BC as well).
     */
    cch = strlen(buf) - (XSIZE - 4);

    if (cch > 0) {
		pchEndBuf = buf + cch;
		pchEndBuf[0] = '.';
		pchEndBuf[1] = '.';
		pchEndBuf[2] = '.';

        i = 0;

        while ( cch && i <= ilaStatus  ) {

            if ( (int)rglaStatus[i].len > cch ) {

                rglaStatus[i].len -= cch;
				cch = 0;

			} else {

                cch -= rglaStatus[i].len;
                rglaStatus[i].len = 0;

			}

            i++;
		}
	}

	fReDraw = FALSE;
    coutb (0, YSIZE+1, pchEndBuf, strlen(pchEndBuf), rglaStatus);

	fReDraw = TRUE;
	voutb (XSIZE-2, YSIZE+1, BTWorking() ? "BP" : "  ", 2, errColor);

	RSETFLAG (fDisplay,  RSTATUS);

}
示例#5
0
文件: display.c 项目: mingpen/OpenNT
flagType
DoText (
    int yLow,
    int yHigh
    ) {

	REGISTER int		yCur;
	int 				yMin = -1;
	int 				yMax = 0;

	flagType			fReturn = TRUE;

	struct lineAttr 	*plaFile = NULL;
	struct lineAttr 	*plaScr  = NULL;
	struct lineAttr 	*plaFileLine;
	struct lineAttr 	*plaScrLine;

	char				*pchFileLine = NULL;
	char				pchScrLine[ 2 * sizeof(linebuf) * (1 + sizeof(struct lineAttr))];
	int 				cchScrLine;

	// int				chkpnt = yHigh - yLow > 25 ? 20 : 5;
	int					chkpnt = yHigh - yLow > 25 ? 10 : 3;


	fReDraw = FALSE;

	plaScr = (struct lineAttr *) (pchScrLine + sizeof(linebuf));
    if (cWin > 1) {
		pchFileLine = pchScrLine + sizeof(linebuf) * (1 + sizeof(struct lineAttr));
		plaFile = (struct lineAttr *) (pchFileLine + sizeof(linebuf));
    }

    /*
     * For each line in the window, if the line is marked changed, update it.
     */
	for (yCur = yLow; yCur < yHigh; ) {

		if (TESTFLAG(fChange[yCur], FMODIFY)) {
            if (yMin == -1) {
                yMin = yCur;
            }
			yMax = yCur;

			/*
			 * get and display the line
			 */
			plaScrLine	= plaScr;
			plaFileLine = plaFile;
			cchScrLine = DisplayLine (yCur, pchScrLine, &plaScrLine, pchFileLine, &plaFileLine);
			coutb (0, yCur, pchScrLine, cchScrLine, plaScrLine);

			RSETFLAG(fChange[yCur],FMODIFY);
			/*
			 * if it is time to check, and there is a character waiting, stop
			 * the update process, and go process it
			 */
			if ( (yCur % chkpnt == 0) && TypeAhead() ) {
				fReturn = FALSE;
				break;
			}
		}
		yCur++;
	}

    if (fReturn) {
        RSETFLAG (fDisplay, RTEXT);
	}
	//
	//	Update the screen
	//
    fReDraw = TRUE;
	vout(0,0,NULL,0,0);
	return fReturn;
}