void GameInit() { GameTextures::Init(); GameMeshes::Init(); torus = GameMeshes::Get( "torus" ); bunny = GameMeshes::Get( "bunny" ); monkey = GameMeshes::Get( "monkey" ); rocks = GameMeshes::Get( "rocks" ); wall = GameMeshes::Get( "wall" ); well = GameMeshes::Get( "well" ); sword = GameMeshes::Get( "sword" ); floortile = GameMeshes::Get( "floor" ); cube = new BadMesh(); cube->SetAsCube(); cube->UVsFromBB(); // now test running some javascript js = new CTinyJS(); registerFunctions(js); js->addNative("function print(text)", &js_print, 0); try { char *buf = fileread("test.js"); js->execute(buf); free( buf ); } catch (CScriptException *e) { printf("ERROR: %s\n", e->text.c_str()); } }
int main2(int argc, char **argv) { CTinyJS *js = new CTinyJS(); /* add the functions from TinyJS_Functions.cpp */ registerFunctions(js); /* Add a native function */ js->addNative("function print(text)", &js_print, 0); js->addNative("function dump()", &js_dump, js); /* Execute out bit of code - we could call 'evaluate' here if we wanted something returned */ try { js->execute("var lets_quit = 0; function quit() { lets_quit = 1; }"); js->execute("print(\"Interactive mode... Type quit(); to exit, or print(...); to print something, or dump() to dump the symbol table!\");"); } catch (CScriptException *e) { printf("ERROR: %s\n", e->text.c_str()); } while (js->evaluate("lets_quit") == "0") { char buffer[2048]; fgets ( buffer, sizeof(buffer), stdin ); try { js->execute(buffer); } catch (CScriptException *e) { printf("ERROR: %s\n", e->text.c_str()); } } delete js; #ifdef _WIN32 #ifdef _DEBUG _CrtDumpMemoryLeaks(); #endif #endif return 0; }
TemplateManager::TemplateManager() { setLogging(false); setGlobalLogging(true); setLoggingName("TemplateManager"); // preload lua files for component checks DirectorManager::instance()->getLuaInstance(); registerTemplateObjects(); luaTemplatesInstance = new Lua(); luaTemplatesInstance->init(); templateCRCMap = new TemplateCRCMap(); clientTemplateCRCMap = new ClientTemplateCRCMap(); portalLayoutMap = new PortalLayoutMap(); floorMeshMap = new FloorMeshMap(); appearanceMap = new AppearanceMap(); registerFunctions(); registerGlobals(); loadTreArchive(); loadSlotDefinitions(); loadPlanetMapCategories(); loadAssetCustomizationManager(); }
bool Shader::load(FS::IFile& file) { lua_State* L = luaL_newstate(); luaL_openlibs(L); registerFunctions(this, &m_combintions, &getRenderer(), L); m_render_states = BGFX_STATE_DEPTH_TEST_LEQUAL; bool errors = luaL_loadbuffer(L, (const char*)file.getBuffer(), file.size(), "") != LUA_OK; errors = errors || lua_pcall(L, 0, 0, 0) != LUA_OK; if (errors) { g_log_error.log("Renderer") << getPath().c_str() << ": " << lua_tostring(L, -1); lua_pop(L, 1); return false; } if (!generateInstances()) { g_log_error.log("Renderer") << "Could not load instances of shader " << getPath().c_str(); return false; } m_size = file.size(); lua_close(L); return true; }
int main(int argc, char* argv[]){ int i; char c; int selectedFunc=-1; while( (c=getopt(argc,argv,"M:N:F:")) != -1){ switch(c){ case 'M': M = atoi(optarg); break; case 'N': N = atoi(optarg); break; case 'F': selectedFunc = atoi(optarg); break; case '?': default: printf("./tracegen failed to parse its options.\n"); exit(1); } } /* Register transpose functions */ registerFunctions(); /* Fill A with data */ initMatrix(M,N, A, B); /* Record marker addresses */ FILE* marker_fp = fopen(".marker","w"); assert(marker_fp); //fprintf(marker_fp, "%llx %llx", fprintf(marker_fp, "%lx %lx", //(unsigned long long int) &MARKER_START, //(unsigned long long int) &MARKER_END ); (unsigned long int) &MARKER_START, (unsigned long int) &MARKER_END ); fclose(marker_fp); if (-1==selectedFunc) { /* Invoke registered transpose functions */ for (i=0; i < func_counter; i++) { MARKER_START = 33; (*func_list[i].func_ptr)(M, N, A, B); MARKER_END = 34; if (!validate(i,M,N,A,B)) return i+1; } } else { MARKER_START = 33; (*func_list[selectedFunc].func_ptr)(M, N, A, B); MARKER_END = 34; if (!validate(selectedFunc,M,N,A,B)) return selectedFunc+1; } return 0; }
IPCServiceMain::IPCServiceMain(IPC::IPCManager* mang, uint32 id, DesuraId itemId) : IPC::IPCClass(mang, id, itemId) { registerFunctions(); servicemain = this; #ifndef DESURA_CLIENT m_pServiceThread = NULL; #endif }
IPCToolMain::IPCToolMain(IPC::IPCManager* mang, uint32 id, DesuraId itemId) : IPC::IPCClass(mang, id, itemId) { registerFunctions(); g_pToolMain = this; #ifndef DESURA_CLIENT m_pThread = nullptr; #endif }
void Frigid::loadConfig() { lua_State *L = luaL_newstate(); mPrefs->setLuaState(L); luaL_openlibs(L); registerFunctions(L); String iHateC = mPrefs->getConfigDir() + "quark_config.lua"; luaL_dofile(L, iHateC.toStdString().c_str()); }
bool run_test (const char *filename) { printf ("TEST %s ", filename); struct stat results; if (!stat (filename, &results) == 0) { printf ("Cannot stat file! '%s'\n", filename); return false; } int size = results.st_size; FILE *file = fopen (filename, "rb"); /* if we open as text, the number of bytes read may be > the size we read */ if (!file) { printf ("Unable to open file! '%s'\n", filename); return false; } char *buffer = new char[size + 1]; long actualRead = fread (buffer, 1, size, file); buffer[actualRead] = 0; buffer[size] = 0; fclose (file); CTinyJS s; registerFunctions (&s); registerMathFunctions (&s); s.root->addChild ("result", new CScriptVar ("0", SCRIPTVAR_INTEGER)); try { s.execute (buffer); } catch (CScriptException * e) { printf ("ERROR: %s\n", e->text.c_str ()); } bool pass = s.root->getParameter ("result")->getBool (); if (pass){ printf ("PASS\n"); } else { char fn[64]; sprintf (fn, "%s.fail.js", filename); FILE *f = fopen (fn, "wt"); if (f) { wString symbols; s.root->getJSON (symbols); fprintf (f, "%s", symbols.c_str ()); fclose (f); } printf ("FAIL - symbols written to %s\n", fn); } delete[] buffer; return pass; }
IPCBrowser::IPCBrowser(IPC::IPCManager* mang, uint32 id, DesuraId itemId) : IPC::IPCClass(mang, id, itemId) { registerFunctions(); m_pEventHandler = NULL; #ifndef DESURA_CLIENT m_pBrowser = NULL; #endif g_pIPCBrowser = this; }
bool loadPlayerScript(QString path, int player, int difficulty) { ASSERT_OR_RETURN(false, player < MAX_PLAYERS, "Player index %d out of bounds", player); QScriptEngine *engine = new QScriptEngine(); UDWORD size; char *bytes = NULL; if (!loadFile(path.toAscii().constData(), &bytes, &size)) { debug(LOG_ERROR, "Failed to read script file \"%s\"", path.toAscii().constData()); return false; } QString source = QString::fromAscii(bytes, size); free(bytes); QScriptSyntaxCheckResult syntax = QScriptEngine::checkSyntax(source); ASSERT_OR_RETURN(false, syntax.state() == QScriptSyntaxCheckResult::Valid, "Syntax error in %s line %d: %s", path.toAscii().constData(), syntax.errorLineNumber(), syntax.errorMessage().toAscii().constData()); // Remember internal, reserved names QScriptValueIterator it(engine->globalObject()); while (it.hasNext()) { it.next(); internalNamespace.insert(it.name(), 1); } QScriptValue result = engine->evaluate(source, path); ASSERT_OR_RETURN(false, !engine->hasUncaughtException(), "Uncaught exception at line %d, file %s: %s", engine->uncaughtExceptionLineNumber(), path.toAscii().constData(), result.toString().toAscii().constData()); // Special functions engine->globalObject().setProperty("setTimer", engine->newFunction(js_setTimer)); engine->globalObject().setProperty("queue", engine->newFunction(js_queue)); engine->globalObject().setProperty("removeTimer", engine->newFunction(js_removeTimer)); engine->globalObject().setProperty("include", engine->newFunction(js_include)); engine->globalObject().setProperty("bind", engine->newFunction(js_bind)); // Special global variables engine->globalObject().setProperty("me", player, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("selectedPlayer", selectedPlayer, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("gameTime", gameTime, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("difficulty", difficulty, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("mapName", game.map, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("baseType", game.base, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("alliancesType", game.alliance, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("powerType", game.power, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("maxPlayers", game.maxPlayers, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("scavengers", game.scavengers, QScriptValue::ReadOnly | QScriptValue::Undeletable); // Regular functions registerFunctions(engine); // Register script scripts.push_back(engine); return true; }
OpticLua::OpticLua(std::string lua) { luaState = luaL_newstate(); luaL_openlibs(luaState); if(luaL_dostring(luaState, lua.c_str()) == 1) { std::string error = lua_tostring(luaState, -1); lua_pop(luaState, 1); throw OpticLuaException(error); } registerFunctions(); }
bool NpcScriptInterface::initState() { luaState = g_luaEnvironment.getLuaState(); if (!luaState) { return false; } registerFunctions(); lua_newtable(luaState); eventTableRef = luaL_ref(luaState, LUA_REGISTRYINDEX); runningEventId = EVENT_ID_USER; return true; }
int main(int , char **) { CTinyJS *js = new CTinyJS(); /* add the functions from TinyJS_Functions.cpp */ registerFunctions(js); registerStringFunctions(js); registerMathFunctions(js); /* Add a native function */ js->addNative("function print(text)", &js_print, 0); // js->addNative("function dump()", &js_dump, js); /* Execute out bit of code - we could call 'evaluate' here if we wanted something returned */ try { js->execute("var lets_quit = 0; function quit() { lets_quit = 1; }"); js->execute("print(\"Interactive mode... Type quit(); to exit, or print(...); to print something, or dump() to dump the symbol table!\");"); } catch (CScriptException *e) { printf("%s\n", e->toString().c_str()); delete e; } int lineNumber = 0; while (js->evaluate("lets_quit") == "0") { char buffer[2048]; fgets ( buffer, sizeof(buffer), stdin ); try { js->execute(buffer, "console.input", lineNumber++); } catch (CScriptException *e) { printf("%s\n", e->toString().c_str()); delete e; } } delete js; #ifdef _WIN32 #ifdef _DEBUG // _CrtDumpMemoryLeaks(); /* no dump momoryleaks here _CrtSetDbgFlag(..) force dump memoryleake after call of all global deconstructors */ _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif #endif return 0; }
ObjectManager::ObjectManager() : Mutex("ObjectManager"), Logger("ObjectManager") { luaMutex.lock(); if (luaInstance == NULL) { luaInstance = new Lua(); luaInstance->init(); info("loading object templates..."); registerFunctions(); luaInstance->runFile("scripts/object/clientmain.lua"); registerObjectTypes(); } luaMutex.unlock(); objectMap = new ObjectMap(); zone = NULL; }
bool Shader::getShaderCombinations(Renderer& renderer, const char* shader_content, ShaderCombinations* output) { lua_State* L = luaL_newstate(); luaL_openlibs(L); registerFunctions(nullptr, output, &renderer, L); bool errors = luaL_loadbuffer(L, shader_content, stringLength(shader_content), "") != LUA_OK; errors = errors || lua_pcall(L, 0, 0, 0) != LUA_OK; if (errors) { g_log_error.log("Renderer") << lua_tostring(L, -1); lua_pop(L, 1); lua_close(L); return false; } lua_close(L); return true; }
int setup_env(int * argc, char *** argv) { #ifdef _PARALLEL /* Set up MPI environment */ MPI_Init(argc, argv); MPI_Comm_rank(MPI_COMM_WORLD, &env_rank); MPI_Comm_size(MPI_COMM_WORLD, &env_size); #endif /* _PARALLEL */ /* Set up mboard enviromnent */ if (MB_Env_Init() != MB_SUCCESS) return FAIL; /* allocate memory for partition data */ partData = malloc(sizeof(double[4]) * env_size); if (createBoards() != OK) return FAIL; if (registerFunctions() != OK) return FAIL; if (assignFunctionsToBoards() != OK) return FAIL; return OK; }
bool OverloadApp::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, CefProcessId source_process, CefRefPtr<CefProcessMessage> message) { std::string functionName = message->GetName().ToString(); CefRefPtr<CefListValue> arguments = message->GetArgumentList(); if (functionName == IPC_REGISTER_FUNCTION_KEY) { registerFunctions(arguments); } else if (functionName == IPC_SYNCHRONIZE_VARIANT_KEY) { registerVariant(arguments->GetString(0), arguments->GetValue(1)); } else if (functionName == IPC_EXECUTE_CALLBACK_KEY) { if (_v8Handler != NULL) { _v8Handler->executeJavascriptCallback(arguments); } } return true; }
int main (int argc, char ** argv) { long *input, *output; long i, nElements; nElements = N_ELEMENTS; initialize (&argc, &argv, &numProcs, &myId); input = (long *) malloc (sizeof (long) * nElements); output = (long *) malloc (sizeof (long) * nElements); #ifdef INPUT_ONE for (i = 0; i < nElements; i++) input [i] = i; #else for (i = 0; i < nElements; i++) input [i] = 1; #endif registerFunctions (tally_init, accum); registerPrintFunction (print); registerStoreResultFn (result_store); #ifdef USE_MPI_SCAN registerDifferenceFunction (difference); registerMpiOpFn (wrap_accum, 1); genScan (input, nElements, sizeof (long)); #else genScanManual (input, nElements, sizeof (long), COMMUTATIVE); #endif finalize (); return 0; }
bool loadPlayerScript(QString path, int player, int difficulty) { ASSERT_OR_RETURN(false, player < MAX_PLAYERS, "Player index %d out of bounds", player); QScriptEngine *engine = new QScriptEngine(); UDWORD size; char *bytes = NULL; if (!loadFile(path.toAscii().constData(), &bytes, &size)) { debug(LOG_ERROR, "Failed to read script file \"%s\"", path.toAscii().constData()); return false; } QString source = QString::fromAscii(bytes, size); free(bytes); QScriptSyntaxCheckResult syntax = QScriptEngine::checkSyntax(source); ASSERT_OR_RETURN(false, syntax.state() == QScriptSyntaxCheckResult::Valid, "Syntax error in %s line %d: %s", path.toAscii().constData(), syntax.errorLineNumber(), syntax.errorMessage().toAscii().constData()); // Special functions engine->globalObject().setProperty("setTimer", engine->newFunction(js_setTimer)); engine->globalObject().setProperty("queue", engine->newFunction(js_queue)); engine->globalObject().setProperty("removeTimer", engine->newFunction(js_removeTimer)); engine->globalObject().setProperty("include", engine->newFunction(js_include)); engine->globalObject().setProperty("bind", engine->newFunction(js_bind)); // Special global variables //== \item[version] Current version of the game, set in \emph{major.minor} format. engine->globalObject().setProperty("version", "3.2", QScriptValue::ReadOnly | QScriptValue::Undeletable); //== \item[selectedPlayer] The player ontrolled by the client on which the script runs. engine->globalObject().setProperty("selectedPlayer", selectedPlayer, QScriptValue::ReadOnly | QScriptValue::Undeletable); //== \item[gameTime] The current game time. Updated before every invokation of a script. engine->globalObject().setProperty("gameTime", gameTime, QScriptValue::ReadOnly | QScriptValue::Undeletable); //== \item[difficulty] The currently set campaign difficulty, or the current AI's difficulty setting. It will be one of //== EASY, MEDIUM, HARD or INSANE. engine->globalObject().setProperty("difficulty", difficulty, QScriptValue::ReadOnly | QScriptValue::Undeletable); //== \item[mapName] The name of the current map. engine->globalObject().setProperty("mapName", game.map, QScriptValue::ReadOnly | QScriptValue::Undeletable); //== \item[baseType] The type of base that the game starts with. It will be one of CAMP_CLEAN, CAMP_BASE or CAMP_WALLS. engine->globalObject().setProperty("baseType", game.base, QScriptValue::ReadOnly | QScriptValue::Undeletable); //== \item[alliancesType] The type of alliances permitted in this game. It will be one of NO_ALLIANCES, ALLIANCES or ALLIANCES_TEAMS. engine->globalObject().setProperty("alliancesType", game.alliance, QScriptValue::ReadOnly | QScriptValue::Undeletable); //== \item[powerType] The power level set for this game. engine->globalObject().setProperty("powerType", game.power, QScriptValue::ReadOnly | QScriptValue::Undeletable); //== \item[maxPlayers] The number of active players in this game. engine->globalObject().setProperty("maxPlayers", game.maxPlayers, QScriptValue::ReadOnly | QScriptValue::Undeletable); //== \item[scavengers] Whether or not scavengers are activated in this game. engine->globalObject().setProperty("scavengers", game.scavengers, QScriptValue::ReadOnly | QScriptValue::Undeletable); //== \item[mapWidth] Width of map in tiles. engine->globalObject().setProperty("mapWidth", mapWidth, QScriptValue::ReadOnly | QScriptValue::Undeletable); //== \item[mapHeight] Height of map in tiles. engine->globalObject().setProperty("mapHeight", mapHeight, QScriptValue::ReadOnly | QScriptValue::Undeletable); //== \item[scavengerPlayer] Index of scavenger player. (3.2+ only) engine->globalObject().setProperty("scavengerPlayer", scavengerPlayer(), QScriptValue::ReadOnly | QScriptValue::Undeletable); // Regular functions registerFunctions(engine); // Remember internal, reserved names QScriptValueIterator it(engine->globalObject()); while (it.hasNext()) { it.next(); internalNamespace.insert(it.name(), 1); } // We need to always save the 'me' special variable. //== \item[me] The player the script is currently running as. engine->globalObject().setProperty("me", player, QScriptValue::ReadOnly | QScriptValue::Undeletable); QScriptValue result = engine->evaluate(source, path); ASSERT_OR_RETURN(false, !engine->hasUncaughtException(), "Uncaught exception at line %d, file %s: %s", engine->uncaughtExceptionLineNumber(), path.toAscii().constData(), result.toString().toAscii().constData()); // We also need to save the special 'scriptName' variable. //== \item[scriptName] Base name of the script that is running. QFileInfo basename(path); engine->globalObject().setProperty("scriptName", basename.baseName(), QScriptValue::ReadOnly | QScriptValue::Undeletable); // Register script scripts.push_back(engine); debug(LOG_SAVE, "Created script engine %d for player %d from %s", scripts.size() - 1, player, path.toUtf8().constData()); return true; }
extern "C" int DECLSPEC luaopen_luamcuctrl( lua_State * L ) { createMeta( L ); registerFunctions( L ); return 0; }
Style::Style() : QCleanlooksStyle() { setObjectName(QLatin1String("Bobcat")); registerFunctions(); }
int RThread::initialize () { RK_TRACE (RBACKEND); // we create a fake RCommand to capture all the output/errors during startup current_command = new RCommand (i18n ("R Startup"), RCommand::App, i18n ("R Startup")); int argc = 2; char* argv[2] = { qstrdup ("--slave"), qstrdup ("--no-save") }; startR (argc, argv); for (--argc; argc >= 0; --argc) { delete argv[argc]; } connectCallbacks (); RKWardRError error; int status = 0; runCommandInternal ("library (\"rkward\")\n", &error); if (error) status |= LibLoadFail; int c; QString *paths = getCommandAsStringVector ("library.dynam (\"rkward\", \"rkward\")[[\"path\"]]\n", &c, &error); if ((error) || (c != 1)) { status |= LibLoadFail; } else { if (!registerFunctions (paths[0].local8Bit ())) status |= LibLoadFail; } delete [] paths; // find out about standard library locations QString *standardliblocs = getCommandAsStringVector (".libPaths ()\n", &c, &error); if (error) status |= OtherFail; for (int i = 0; i < c; ++i) { RKSettingsModuleRPackages::defaultliblocs.append (standardliblocs[i]); } delete [] standardliblocs; // apply user configurable run time options QStringList commands = RKSettingsModuleR::makeRRunTimeOptionCommands () + RKSettingsModuleRPackages::makeRRunTimeOptionCommands (); for (QStringList::const_iterator it = commands.begin (); it != commands.end (); ++it) { runCommandInternal ((*it).local8Bit (), &error); if (error) { status |= OtherFail; RK_DO (qDebug ("error in initialization call '%s'", (*it).latin1()), RBACKEND, DL_ERROR); } } // error sink and help browser runCommandInternal ("options (error=quote (.rk.do.error ()))\n", &error); if (error) status |= SinkFail; /* runCommandInternal (".rk.init.handlers ()\n", &error); if (error) status |= SinkFail; */ runCommandInternal ("options (htmlhelp=TRUE); options (browser=\"dcop " + kapp->dcopClient ()->appId () + " rkwardapp openHTMLHelp \")", &error); if (error) status |= OtherFail; // TODO: error-handling? MUTEX_LOCK; flushOutput (); MUTEX_UNLOCK; QCustomEvent *event = new QCustomEvent (RCOMMAND_OUT_EVENT); event->setData (current_command); qApp->postEvent (RKGlobals::rInterface (), event); return status; }
ScriptFunctions::ScriptFunctions(NWNEngine &engine) : _engine(&engine) { registerFunctions(); }
/* * eval_perf - Evaluate the performance of the registered transpose functions */ void eval_perf(unsigned int s, unsigned int E, unsigned int b) { int i,flag; unsigned int len, hits, misses, evictions; unsigned long long int marker_start, marker_end, addr; char buf[1000], cmd[255]; char filename[128], tmpname[512]; registerFunctions(); /* Open the complete trace file */ FILE* full_trace_fp; FILE* part_trace_fp; /* Evaluate the performance of each registered transpose function */ for (i=0; i<func_counter; i++) { if (strcmp(func_list[i].description, SUBMIT_DESCRIPTION) == 0 ) results.funcid = i; /* remember which function is the submission */ printf("\nFunction %d (%d total)\nStep 1: Validating and generating memory traces\n",i,func_counter); /* Use valgrind to generate the trace */ sprintf(tmpname, "/tmp/cs154p3-%u.tmp", (unsigned int)getuid()); sprintf(cmd, "valgrind --tool=lackey --trace-mem=yes --log-fd=1 -v ./tracegen -M %d -N %d -F %d > %s", M, N,i, tmpname); flag=WEXITSTATUS(system(cmd)); if (0!=flag) { printf("Validation error at function %d! Run ./tracegen -M %d -N %d -F %d for details.\nSkipping performance evaluation for this function.\n",flag-1,M,N,i); continue; } /* Get the start and end marker addresses */ FILE* marker_fp = fopen(".marker", "r"); assert(marker_fp); fscanf(marker_fp, "%llx %llx", &marker_start, &marker_end); fclose(marker_fp); func_list[i].correct=1; /* Save the correctness of the transpose submission */ if (results.funcid == i ) { results.correct = 1; } full_trace_fp = fopen(tmpname, "r"); assert(full_trace_fp); /* Filtered trace for each transpose function goes in a separate file */ sprintf(filename, "trace.f%d", i); part_trace_fp = fopen(filename, "w"); assert(part_trace_fp); /* Locate trace corresponding to the trans function */ flag = 0; while (fgets(buf, 1000, full_trace_fp) != NULL) { /* We are only interested in memory access instructions */ if (buf[0]==' ' && buf[2]==' ' && (buf[1]=='S' || buf[1]=='M' || buf[1]=='L' )) { sscanf(buf+3, "%llx,%u", &addr, &len); /* If start marker found, set flag */ if (addr == marker_start) flag = 1; /* Valgrind creates many spurious accesses to the stack that have nothing to do with the students code. At the moment, we are ignoring all stack accesses by using the simple filter of recording accesses to only the low 32-bit portion of the address space. At some point it would be nice to try to do more informed filtering so that would eliminate the valgrind stack references while include the student stack references. */ if (flag && addr < 0xffffffff) { fputs(buf, part_trace_fp); } /* if end marker found, close trace file */ if (addr == marker_end) { flag = 0; fclose(part_trace_fp); break; } } } fclose(full_trace_fp); /* Run the reference simulator */ printf("Step 2: Evaluating performance (s=%d, E=%d, b=%d)\n", s, E, b); char cmd[255]; sprintf(cmd, "./csim-ref -s %u -E %u -b %u -t trace.f%d > /dev/null", s, E, b, i); system(cmd); /* Collect results from the reference simulator */ FILE* in_fp = fopen(".csim_results","r"); assert(in_fp); fscanf(in_fp, "%u %u %u", &hits, &misses, &evictions); fclose(in_fp); func_list[i].num_hits = hits; func_list[i].num_misses = misses; func_list[i].num_evictions = evictions; printf("func %u (%s): hits:%u, misses:%u, evictions:%u\n", i, func_list[i].description, hits, misses, evictions); /* If it is transpose_submit(), record number of misses */ if (results.funcid == i) { results.misses = misses; } } }
IPCUninstallBranch::IPCUninstallBranch(IPC::IPCManager* mang, uint32 id, DesuraId itemId) : IPC::IPCClass(mang, id, itemId) { registerFunctions(); m_pThread = NULL; }
Functions::Functions(Game &game) : _game(&game) { registerFunctions(); }
PaloFunctionNodeFactory::PaloFunctionNodeFactory() { if (!isRegistered) { registerFunctions(); } }
IPCUpdateApp::IPCUpdateApp(IPC::IPCManager* mang, uint32 id, DesuraId itemId) : IPC::IPCClass(mang, id, itemId) { registerFunctions(); m_pThread = nullptr; }
ScriptFunctions::ScriptFunctions() { registerFunctions(); }