Esempio n. 1
0
void checkEnvironmentVars()
{
	/* If there hasn't been a classpath defined manually via the command line, check if there is an according environment variable and set this. */
	if( classpath == NULL )
	{
		char* envClasspath= getenv( PURA_CLASSPATH_ENVIRONMENT_VARIABLE_NAME );
		
		if( envClasspath != NULL )
		{
			if( strlen(envClasspath) <= 255 )
			{
				classpath= envClasspath;
				logVerbose( "Using environment variable classpath: %s\n", envClasspath );
			}
			else
			{
				error( "Classpath is too long!" );
			}
		}
		else
		{
			/* neither command line parameter, nor environment variable => use default */
			classpath= ".";
			logVerbose( "No classpath defined. Using local directory as default.\n" );
		}
	}
}
Esempio n. 2
0
void stack_free( Stack* stack )
{
	logVerbose( "Freeing up stack.\n" );

	mm_staticFree( stack->basePointer );
	mm_staticFree( stack );
}
Esempio n. 3
0
void TAdvanced::getData(TPreferences* pref) {

	requires_restart = false;
	pref->actions_to_run = actionsToRun();

    restartIfStringChanged(pref->player_additional_options,
                           playerAdditionalArguments(),
                           "player_additional_options");
    if (pref->isMPlayer()) {
        pref->mplayer_additional_options = pref->player_additional_options;
    } else {
        pref->mpv_additional_options = pref->player_additional_options;
    }
    restartIfStringChanged(pref->player_additional_video_filters,
                           playerAdditionalVideoFilters(),
                           "player_additional_video_filters");
    restartIfStringChanged(pref->player_additional_audio_filters,
                           playerAdditionalAudioFilters(),
                           "player_additional_audio_filters");

    // Log
    pref->log_level = logLevel();
    Log4Qt::LogManager::rootLogger()->setLevel(pref->log_level);
    Log4Qt::LogManager::qtLogger()->setLevel(pref->log_level);
    restartIfBoolChanged(pref->log_verbose,
        pref->log_level <= Log4Qt::Level::DEBUG_INT && logVerbose(),
        "log_verbose");
    pref->log_window_max_events = log_window_max_events_spinbox->value();
}
Esempio n. 4
0
std::string gravUtil::findFile( std::string file )
{
    for ( std::vector<std::string>::iterator i = resourceDirList.begin();
            i != resourceDirList.end(); ++i )
    {
        std::string full = (*i) + file;
        wxString fullwx = wxString( full.c_str(), wxConvUTF8 );
        logVerbose( "gravUtil::findFile: checking %s...\n", full.c_str() );
        if ( wxFile::Exists( fullwx.c_str() ) )
        {
            logVerbose( "gravUtil::findFile: success!\n" );
            return full;
        }
    }
    logError( "gravUtil::findFile: file %s not found\n", file.c_str() );
    return "";
}
Esempio n. 5
0
int main(int argc, char **argv)
{
	logError("Test error logging");
	logWarning("Friendly warning: %s", "the cake is a lie");
	logDebug("Debug is fine, I guess");
	logInfo("'%c' is number %d !", 'A', 1);
	logVerbose("Blah blah blah");

	return 0;
}
Esempio n. 6
0
StackFrame* stack_popFrame( Stack* stack )
{
	/* remove stack frame and re-establish the previous one */
	StackFrame* sf= stack->currentFrame;
	stack->frameCount--;
	stack->currentFrame= sf->prevStackFrame;
	stack->stackPointer= (slot*)sf;
	
	logVerbose( "\tPopping stack frame off the stack. Back at frame %i, height %i bytes.\n", stack->frameCount, stack_getSize(stack) );
	return stack->currentFrame;
}
Esempio n. 7
0
Stack* stack_create( uint32 stackSize )
{
	logVerbose( "Creating stack with a size of %i bytes.\n", stackSize );
	
	Stack* stack= mm_staticMalloc( sizeof(Stack) );
	
	stack->basePointer= mm_staticMalloc( stackSize );
	stack->frameCount= 0;
	stack->maxSize= stackSize;
	
	return stack;
}
Esempio n. 8
0
	void Graphics2552::rotateToNormal(ofVec3f normal) {
		normal.normalize();

		float rotationAmount;
		ofVec3f rotationAngle;
		ofQuaternion rotation;

		ofVec3f axis(0, 0, 1);
		rotation.makeRotate(axis, normal);
		rotation.getRotate(rotationAmount, rotationAngle);
		logVerbose("ofRotate " + ofToString(rotationAmount));
		ofRotate(rotationAmount, rotationAngle.x, rotationAngle.y, rotationAngle.z);
	}
Esempio n. 9
0
int main( int argcnt, const char** args )
{
	logVerbose("%i", __GNUC__);
	/* first of all, verify type size assumptions */
	types_testTypes();
	
	/*logVerbose( "Parsing VM parameters...\n" );*/
	handleParameters( argcnt, args );
	checkEnvironmentVars();

	logInfo( "Pura Experimental Java Virtual Machine v%s - (c) 2007 Daniel Klein\n", STR_VERSION );

	ma_init();
	heap_init();
	interpreter_start( mainClass );
	mm_printStatistics();

	return 0;
}
Esempio n. 10
0
/* Pushes a new stack frame onto the stack and handles any possible parameters. */ 
StackFrame* stack_pushFrame( Stack* stack, Class* cls, method_info* methodInfo )
{
	/* make sure that we do have enough space left on the stack */
	int expectedSize= sizeof(StackFrame) + methodInfo->code->max_locals*sizeof(slot) + methodInfo->code->max_stack*sizeof(slot);

	if( stack_getSize(stack) + expectedSize > stack->maxSize )
		error( "Stack overflow error!\n" );
		/* TODO: Print stack trace here! */

	/* Copy the parameters to their new destination first, so that we can overwrite them on the old position. But we have to copy them in reverse oder, so that we
		don't overwrite any parameter, no matter how many we have. */
	if( methodInfo->parameterSlotCount > 0 )
	{
		slot* newLocals= (slot*)( ((byte*)(stack->stackPointer - 1)) + sizeof(StackFrame) ); /* - parameterSlotCount + parameterSlotCount */
		slot* prevOperands= stack->stackPointer - 1;

		int i;
		for( i= 0; i < methodInfo->parameterSlotCount; i++ )
		{
			*newLocals= *prevOperands;
			newLocals--;
			prevOperands--;
		}
	}
	
	/* allocate stack frame */
	StackFrame* sf= (StackFrame*)( ((slot*)stack->stackPointer) - methodInfo->parameterSlotCount );
	
	/* initialize stack frame */
	sf->prevStackFrame= stack->currentFrame;
	sf->currentClass= cls;
	sf->methodInfo= methodInfo;
	sf->pc= (byte*)0xFFFFFFFF; /* This value is only for debugging purposes. Otherwise pc is unused until the next method call. */
	
	/* adjust stack info */
	stack->stackPointer= ((slot*)(sf+1))+methodInfo->code->max_locals;
	stack->currentFrame= sf;
	stack->frameCount++;
	
	logVerbose( "\tPushing new stack frame.\n\tFrame number %i, size %i bytes, %i parameter slots, stack is now %i bytes high.\n", stack->frameCount, expectedSize, methodInfo->parameterSlotCount, stack_getSize(stack) );
	return sf;
}
Esempio n. 11
0
/* Creates an initial stack frame, so that a parameter can be passed to the main method. The parameter has to be manually pushed after this method finnishes. */
StackFrame* stack_createInitialStackFrame( Stack* stack )
{
	logVerbose( "Pushing initial stack frame.\n" );
	
	/* allocate initial stack frame */
	StackFrame* sf= (StackFrame*)stack->basePointer;
	
	/* initialize stack frame */
	sf->currentClass= NULL;
	sf->prevStackFrame= NULL;
	sf->methodInfo= NULL;
	sf->pc= (byte*)0xFFFFFFFF; /* This is only used for storing the pc if another method is called. The initial value is for easier debugging. */
	
	/* adjust stack info */
	stack->stackPointer= (slot*)(sf+1);
	stack->currentFrame= sf;
	stack->frameCount++;
	
	return sf;
}
Esempio n. 12
0
void LSCompiler::linkRootAssembly(const utString& sjson)
{
    json_error_t jerror;
    json_t       *json = json_loadb((const char *)sjson.c_str(), sjson.length(), 0, &jerror);

    lmAssert(json, "Error linking assembly");

    json_t *ref_array = json_object_get(json, "references");
    lmAssert(json, "Error linking assembly, can't get executable references");

    for (UTsize i = 0; i < rootBuildDependencies.size(); i++)
    {
        BuildInfo *buildInfo     = rootBuildDependencies.at(i);
        utString  assemblySource = buildInfo->getOutputDir() + platform_getFolderDelimiter() + buildInfo->getAssemblyName() + ".loomlib";

        utArray<unsigned char> rarray;
        lmAssert(utFileStream::tryReadToArray(assemblySource, rarray), "Unable to load library assembly %s", assemblySource.c_str());

        utBase64 base64 = utBase64::encode64(rarray);

        for (size_t j = 0; j < json_array_size(ref_array); j++)
        {
            json_t   *jref = json_array_get(ref_array, j);
            utString jname = json_string_value(json_object_get(jref, "name"));
            if (buildInfo->getAssemblyName() == jname)
            {
                logVerbose("Linking: %s", jname.c_str());

                json_object_set(jref, "binary", json_string(base64.getBase64().c_str()));
                json_object_set(jref, "uid", json_string(readAssemblyUID(rarray)));
                break;
            }
        }
    }

    // filter the reference array by the import assemblies
    utStack<int> filter;
    for (size_t j = 0; j < json_array_size(ref_array); j++)
    {
        json_t   *jref = json_array_get(ref_array, j);
        utString jname = json_string_value(json_object_get(jref, "name"));

        bool found = false;

        // always find the System assembly, so we don't have to explicitly import from it
        if (jname == "System")
        {
            found = true;
        }

        for (UTsize k = 0; k < importedAssemblies.size() && !found; k++)
        {
            if (importedAssemblies.at(k)->getName() == jname)
            {
                found = true;
                break;
            }
        }

        if (!found)
        {
            filter.push((int)j);
        }
    }

    while (filter.size())
    {
        json_array_remove(ref_array, filter.pop());
    }

    for (UTsize i = 0; i < rootLibDependencies.size(); i++)
    {
        utString libName = rootLibDependencies.at(i);

        for (size_t j = 0; j < json_array_size(ref_array); j++)
        {
            json_t   *jref = json_array_get(ref_array, j);
            utString jname = json_string_value(json_object_get(jref, "name"));

            if (libName != jname)
            {
                continue;
            }

            log("Linking: %s", libName.c_str());

            utString delim   = platform_getFolderDelimiter();
            utString libPath = sdkPath + delim + "libs" + delim + libName + ".loomlib";

            utArray<unsigned char> rarray;

            if (libName == "System" && embeddedSystemAssembly)
            {
                size_t embeddedSystemAssemblyLength = strlen(embeddedSystemAssembly);
                rarray.resize((int)(embeddedSystemAssemblyLength + 1));
                memcpy(&rarray[0], embeddedSystemAssembly, embeddedSystemAssemblyLength + 1);
            }
            else
            {
                lmAssert(utFileStream::tryReadToArray(libPath, rarray), "Unable to load library assembly %s at %s", libName.c_str(), libPath.c_str());    
            }

            utBase64 base64 = utBase64::encode64(rarray);
            json_object_set(jref, "binary", json_string(base64.getBase64().c_str()));
            json_object_set(jref, "uid", json_string(readAssemblyUID(rarray)));

            break;
        }
    }

    json_object_set(json, "executable", json_true());

    utString execSource = rootBuildInfo->getOutputDir() + utString(platform_getFolderDelimiter()) + rootBuildInfo->getAssemblyName() + ".loom";

    // generate binary assembly for executable
    BinWriter::writeExecutable(execSource.c_str(), json);

    log("Compile Successful: %s\n", execSource.c_str());
}
Esempio n. 13
0
void LSCompiler::processTypes(ModuleBuildInfo *mbi)
{
    // process the fully qualified type information
    for (UTsize j = 0; j < mbi->getNumSourceFiles(); j++)
    {
        utString filename = mbi->getSourceFilename(j);

        CompilationUnit *cunit = mbi->getCompilationUnit(filename);

        logVerbose("Type Qualifying Visitor %s", cunit->filename.c_str());

        TypeQualifyVisitor tqv(vm);
        tqv.visit(cunit);
    }

    // process the member types, so everything is available once
    // we get to the method code
    for (UTsize j = 0; j < mbi->getNumSourceFiles(); j++)
    {
        utString        filename = mbi->getSourceFilename(j);
        CompilationUnit *cunit   = mbi->getCompilationUnit(filename);

        logVerbose("Type Member Visitor %s", cunit->filename.c_str());

        MemberTypeVisitor mtv(vm, cunit);
        mtv.processMemberTypes();
    }

    // generate type info for method code
    for (UTsize j = 0; j < mbi->getNumSourceFiles(); j++)
    {
        utString        filename = mbi->getSourceFilename(j);
        CompilationUnit *cunit   = mbi->getCompilationUnit(filename);

        logVerbose("Type Visitor %s", cunit->filename.c_str());

        TypeVisitor tv(vm);
        tv.visit(cunit);
    }

    // if we have any compiler errors, dump them and exit
    if (LSCompilerLog::getNumErrors())
    {
        LSCompilerLog::dump();
        exit(EXIT_FAILURE);
    }

    // validate types
    for (UTsize j = 0; j < mbi->getNumSourceFiles(); j++)
    {
        utString filename = mbi->getSourceFilename(j);

        CompilationUnit *cunit = mbi->getCompilationUnit(filename);

        logVerbose("Type Validating %s", cunit->filename.c_str());

        for (UTsize k = 0; k < cunit->classDecls.size(); k++)
        {
            TypeValidator tv(vm, cunit, cunit->classDecls.at(k));
            tv.validate();
        }
    }

    // if we have any compiler errors, dump them and exit
    if (LSCompilerLog::getNumErrors())
    {
        LSCompilerLog::dump();
        exit(EXIT_FAILURE);
    }
}
Esempio n. 14
0
	void Process()
	{
		PathListIt it = paths.begin();
		while (it != paths.end()) {
			getFolderContent(*it);
			++it;
		}
		logInfo(L"Files to process:\t%8llu\n", data.size());

		logDebug(L"");
		std::sort(data.begin(), data.end(), CompareBySizeAndTime);
		std::pair<FilesListIt, FilesListIt> bounds;
		FilesListIt srch = data.begin();
		while (srch != data.end()) {
			logCounter(L"Files left:\t%8llu", std::distance(srch, data.end()));
			bounds = std::equal_range(srch, data.end(), *srch, CompareBySize);
			if (std::distance(bounds.first, bounds.second) == 1) {
				++Statistics::getInstance()->filesFoundUnique;
				data.erase(bounds.first);
			} else {
				while (srch != bounds.second) {
					FilesListIt it = srch;
					++it;
					shared_ptr<File>& f1 = *srch;
					while (it != bounds.second) {
						shared_ptr<File>& f2 = *it;
						AutoUTF buf1(f1->path());
						AutoUTF buf2(f2->path());
						{
							ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN);
							logDebug(L"Comparing files [size = %I64u]:\n", f1->size());
						}
						logDebug(L"  %s\n", buf1.c_str());
						logDebug(L"  %s\n", buf2.c_str());
						++Statistics::getInstance()->fileCompares;
						f1->refresh();
						f2->refresh();
						if (AttrMustMatch && f1->attr() != f2->attr()) {
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
								logDebug(L"  Attributes of files do not match, skipping\n");
							}
							Statistics::getInstance()->fileMetaDataMismatch++;
							++it;
							break;
						}
						if (TimeMustMatch && f1->mtime() != f2->mtime()) {
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
								logDebug(L"  Modification timestamps of files do not match, skipping\n");
							}
							Statistics::getInstance()->fileMetaDataMismatch++;
							++it;
							break;
						}
						if (!isSameVolume(*f1, *f2)) {
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
								logDebug(L"  Files ignored - on different volumes\n");
							}
							++Statistics::getInstance()->filesOnDifferentVolumes;
							++it;
							break;
						}
						if (f1 == f2) {
							++Statistics::getInstance()->fileAlreadyLinked;
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_GREEN);
								logDebug(L"  Files ignored - already linked\n");
							}
							++it;
							break;
						}
						if (f1->size() > FirstBlock) {
							if (!f1->LoadHashMini()) {
								break;
							}
							if (!f2->LoadHashMini()) {
								it = data.erase(it);
								continue;
							}
						} else {
							if (!f1->LoadHashFull()) {
								break;
							}
							if (!f2->LoadHashFull()) {
								it = data.erase(it);
								continue;
							}
						}
						if (isIdentical(*f1, *f2)) {
							++Statistics::getInstance()->fileContentSame;
							if (logLevel == LOG_VERBOSE) {
								{
									ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN);
									logVerbose(L"Comparing files [size = %I64u]:\n", f1->size());
								}
								logVerbose(L"  %s\n", buf1.c_str());
								logVerbose(L"  %s\n", buf2.c_str());
							}
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
								logVerbose(L"  Files are equal, hard link possible\n");
							}
							if (hardlink) {
								f1->hardlink(*f2);
							}
							Statistics::getInstance()->FreeSpaceIncrease += f1->size();
							it = data.erase(it);
						} else {
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
								logDebug(L"  Files differ in content (hash)\n");
							}
							Statistics::getInstance()->hashComparesHit1++;
							++it;
						}
					}
					srch = data.erase(srch);
				}
			}
			srch = bounds.second;
		}
		logCounter(L"                              ");
	}