Esempio n. 1
0
//===========================================================================
// Compile
//===========================================================================
void Compile(char *fileName)
{
	FILE *file;
	int length;

	// Try to first open the file "as is".
	strcpy(sourceFileName, fileName);
	if((file = fopen(sourceFileName, "rb")) == NULL)
	{
		// OK, what about adding an extension?
		strcat(sourceFileName, ".tx");
		if((file = fopen(sourceFileName, "rb")) == NULL)
		{
			perror(fileName);
			return;
		}
	}
	printf("Compiling %s...\n", sourceFileName);

	// Load in the defs.
	fseek(file, 0, SEEK_END);
	length = ftell(file);
	rewind(file);
	sourcePos = source = new unsigned char[length + 1];
    if(!fread(source, length, 1, file))
    {
        perror(fileName);
        return;
    }
	source[length] = 0;
	fclose(file);

	// Let's compile it!
	InitCompiler();
	if(!DoCompile())
	{
		printf("Compilation of %s was aborted!\n", sourceFileName);
	}
	CloseCompiler();

	// Free the buffer, we don't need it any more.
	delete [] source;
}
Esempio n. 2
0
gs_device::gs_device(const gs_init_data *data)
	: curSwapChain         (&defaultSwap),
	  curToplogy           (D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED)
{
	ComPtr<IDXGIAdapter1> adapter;

	matrix4_identity(&curProjMatrix);
	matrix4_identity(&curViewMatrix);
	matrix4_identity(&curViewProjMatrix);

	memset(&viewport, 0, sizeof(viewport));

	for (size_t i = 0; i < GS_MAX_TEXTURES; i++) {
		curTextures[i] = NULL;
		curSamplers[i] = NULL;
	}

	InitCompiler();
	InitFactory(data->adapter, adapter.Assign());
	InitDevice(data, adapter);
	device_set_render_target(this, NULL, NULL);
}
Esempio n. 3
0
static void DoRun(System *sys)
{
    ParseContext *c;
    sys->freeNext = sys->freeSpace;
    if (!(c = InitCompiler(sys, MAXOBJECTS)))
        VM_printf("insufficient memory\n");
    else {
        ImageHdr *image;
        BufSeekN(0);
        c->getLine = EditGetLine;
        if ((image = Compile(c)) != NULL) {
            Interpreter *i = (Interpreter *)sys->freeNext;
            size_t stackSize = (sys->freeTop - sys->freeNext - sizeof(Interpreter)) / sizeof(VMVALUE);
            if (stackSize <= 0)
                VM_printf("insufficient memory\n");
            else {
                InitInterpreter(i, stackSize);
                Execute(i, image);
            }
        }
    }
}