void Command::writeAssembly()
{
  std::ofstream file;
  file.open(m_filename);
  if (!file.is_open()) {
    std::cerr<<"Error: unable to open output file!";
    exit(2);
  }
  file <<"/**"<<std::endl;
  file <<" *"<<m_filename<<std::endl;
  file <<" *"<<std::endl;
  file <<" * Generated by Bench Cookie Compiler!"<<std::endl;
  file <<" * Bench Cookie is... Experimental. Don't be mad."<<std::endl;
  file <<" */"<<std::endl;

  doBSS(file);

  file<<std::endl;

  doData(file);

  file<<std::endl<<std::endl;
  file<<"\t.text"<<std::endl;
  file<<"\t.global main"<<std::endl;
  file<<"\t.global printf"<<std::endl;
  file<<"\t.global scanf"<<std::endl;
  file<<"\t.global malloc"<<std::endl;

  doMain(file);

  /**
   * Free locals
   *
   * @todo Free locals when last used.
   *       Maybe change file to a list
   *       and search for last usage?
   */
  file<<"\t@ Free local vars"<<std::endl;
  for (int x = 0; x < m_int_declarations.size(); ++x) {
    file<<"\tldr %r0, =locals"<<std::endl;
    file<<"\tldr %r0, [%r0, #"<<4 * x<<"]"<<std::endl;
    file<<"\tbl free"<<std::endl<<std::endl;
  }

  file<<"\t@ locals are free"<<std::endl<<std::endl;

  file<<std::endl;
  file<<"\tmov %r0, $0"<<std::endl;
  /**
   * @DrewBarthel: printf is a toilet.
   */
  file<<"\tbl fflush"<<std::endl;
  file<<"\tmov %r7, $1"<<std::endl;

  /** Toilet has been flushed **/

  file<<"\tswi $0"<<std::endl;
  file<<"\t.end"<<std::endl;
  file.close();
}// allocate enough space for drew-sized strings.
Ejemplo n.º 2
0
int main(int argc, const char *argv[])
{
    InitModuleObjects();
    queryStderrLogMsgHandler()->setMessageFields(0);
    unsigned exitCode = doMain(argc, argv);
    releaseAtoms();
    exit(exitCode);
}
int main(int argc, char **argv)
{
    doMain(argc, argv);

    glutMainLoop();

    return 0;
}
int main (int argc, char **argv)
{
    doMain(argc, argv);

    OSG::osgExit();

    return 0;
}
Ejemplo n.º 5
0
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
    doMain(argc, argv);

    // GLUT main loop
    glutMainLoop();

    return 0;
}
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
    if(doMain(argc, argv) != 0)
        return 1;

    // GLUT main loop
    glutMainLoop();

    return 0;
}
Ejemplo n.º 7
0
//
// main entry point
//
int main(int argc, char *argv[])
{
    int ret = doMain(argc, argv);

    glutMainLoop();

    cleanup();

    osgExit();

    return ret;
}
Ejemplo n.º 8
0
int main() {
    
	IwGxInit();
	IwResManagerInit();
 
	doMain();
	
	IwResManagerTerminate();
	IwGxTerminate();
		
	return 0;
}
Ejemplo n.º 9
0
int main(int argc, char *argv[])
{
	
#if TARGET_OS_MAC
	#if USE_TIMEBOMB
		CheckDate();
	#endif /* USE_TIMEBOMB */
	return FskCocoaMain(kFskMainNetwork | kFskMainServer, argc, argv);
#else
	int err = (int)doMain(kFskMainNetwork | kFskMainServer, argc, argv);
#if TARGET_OS_LINUX
	fprintf(stderr, "successfully exited with error code %d.\n", err);
#endif
	return err;
#endif
}
Ejemplo n.º 10
0
int main(int argc, char *argv[])
{
    doMain(argc, argv);

    // GLUT main loop
    glutMainLoop();

    //
    // Clean up the global held data
    //
    cleanup();

    OSG::osgExit();

    return 0;
}
int main (int argc, char **argv)
{
    doMain(argc, argv);

    fprintf(stderr, "Create hdrroot %p %d %d \n",
            hdrroot.get(),
            hdrroot->getRefCount(),
            hdrroot->getWeakRefCount());

    fprintf(stderr, "Create root %p %d %d \n",
            root.get(),
            root->getRefCount(),
            root->getWeakRefCount());

    // run...
    glutMainLoop();

    return 0;
}
Ejemplo n.º 12
0
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	int argc, i;
	UInt16 **argvUnicode;
	UInt8 **argvUTF8;
	int result;
	HANDLE startupCheck;
	UInt16 *moduleFileName, *mutexName;
	DWORD lastError;
	const UInt16 *kMutexBaseName = L"Fsk-startup-check-";

#if USE_TIMEBOMB
	if (!CheckDate())
		return -1;
#endif

	FskMainSetHInstance(hInstance);

	argvUnicode = CommandLineToArgvW(GetCommandLineW(), &argc);
	argvUTF8 = (UInt8 **)calloc(sizeof(UInt16 *), argc);
	for (i= 0; i< argc; i++) {
		int charCount = wcslen(argvUnicode[i]);
		argvUTF8[i] = malloc((charCount + 1) * 3);
		WideCharToMultiByte(CP_UTF8, 0, argvUnicode[i], charCount + 1, argvUTF8[i], (charCount + 1) * 3, NULL, NULL);
	}
	GlobalFree(argvUnicode);

	moduleFileName = (UInt16 *)malloc(sizeof(UInt16) * 520);
	GetModuleFileNameW(0, moduleFileName, 512);
	mutexName = malloc((1 + wcslen(moduleFileName) + wcslen(kMutexBaseName)) * 2);
	wcscpy(mutexName, kMutexBaseName);
	wcscat(mutexName, wcsrchr(moduleFileName, '\\') + 1);
	free(moduleFileName);
	startupCheck = CreateMutexW(0, true, mutexName);
	lastError = GetLastError();
	free(mutexName);
	
   for (i = 0; i < argc; i++){
      if(strcmp(argvUTF8[i],"-new-instance")==0) {
         lastError=0;
         break;
      }
	}
	switch (lastError) {
		case 0:
			result = doMain(kFskMainNetwork | kFskMainServer, argc, argvUTF8);
			break;

		case ERROR_ALREADY_EXISTS: {
			char *fileList;
			UInt32 fileListSize;

			result = 0;
			FskUtilsSetArgs(argc, argvUTF8);
			fileList = FskUtilsGetFileArgs(&fileListSize);
			if (NULL != fileList) {
				char *fileName;
				HANDLE hMapFile;
				char number[64];
				SInt32 val;
				
				val = FskRandom() ^ GetTickCount();
				FskStrNumToStr(val, number, sizeof(number));
				fileName = FskStrDoCat("FskFileOpen-", number);

				hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, fileListSize, fileName);
				if ((NULL != hMapFile) && (INVALID_HANDLE_VALUE != hMapFile)) {
					unsigned char *pBuf = MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, fileListSize);
					if (NULL != pBuf) {
						memmove(pBuf, fileList, fileListSize);
						UnmapViewOfFile(pBuf);
						PostMessage(FindWindow("projectf-utils", NULL), RegisterWindowMessage("FskOpenFiles"), 0, val);
					}
					CloseHandle(hMapFile);
				}
				FskMemPtrDispose(fileName);
			}
			}
			break;

		default:
			result = -1;
			break;
	}

	CloseHandle(startupCheck);

	for (i = 0; i < argc; i++)
		free(argvUTF8[i]);
	free(argvUTF8);

	return result;
}