QString GBuildMakefileGenerator::writeOne(QString filename, QString pathtoremove) { QString s(""); QString origfilename(filename); s += filename.remove(pathtoremove); if (filename.endsWith(Option::h_ext.first()) && mocable(origfilename)) { QString corename(filename.section(QDir::separator(), -1)); corename.remove(Option::h_ext.first()); corename.append(Option::cpp_ext.first()); corename.prepend(Option::h_moc_mod); s += "\t[MOC/Qt Header]\n"; s += "\t-o "; s += "work/"; s += pathtoremove; s += QDir::separator(); s += corename; s += "\n"; } else if (filename.section(QDir::separator(), -1).startsWith("qrc_")) { QString tmpstr(filename.section("/", -1).section(".", 0, -1).remove("qrc_").remove(".cpp")); s += "\n\t:depends="; s += tmpstr; s += ".qrc"; s += "\n"; } else if (filename.endsWith(Option::cpp_ext.first()) && mocable(origfilename)) { QString tmpstr(filename.section("/", -1)); QString filepath(pathtoremove); if (!project->values("QT_SOURCE_TREE").isEmpty()) { filepath.remove(project->values("QT_SOURCE_TREE").first()); filepath.remove(0, 1); } s += "\n\t:preexecShellSafe='${QT_BUILD_DIR}/bin/moc "; s += "-nn "; s += varGlue("DEFINES", "-D", " -D", " "); s += varGlue("INCLUDEPATH", "-I", " -I", " "); s += filepath; s += filename; s += " -o "; tmpstr.replace(Option::cpp_ext.first(), Option::cpp_moc_ext); s += "work/"; s += pathtoremove; s += QDir::separator(); s += tmpstr; s += "\n"; } else s += "\n"; return s; }
/* * If the luac command line includes multiple files or has the -f option * then luac generates a main function to reference all sub-main prototypes. * This is one of two types: * Type 0 The standard luac combination main * Type 1 A lookup wrapper that facilitates indexing into the generated protos */ static const Proto* combine(lua_State* L, int n, int type) { if (n==1 && type == 0) return toproto(L,-1); else { int i; Instruction *pc; Proto* f=luaF_newproto(L); setptvalue2s(L,L->top,f); incr_top(L); f->source=luaS_newliteral(L,"=(" PROGNAME ")"); f->p=luaM_newvector(L,n,Proto*); f->sizep=n; for (i=0; i<n; i++) f->p[i]=toproto(L,i-n-1); pc=0; if (type == 0) { /* * Type 0 is as per the standard luac, which is just a main routine which * invokes all of the compiled functions sequentially. This is fine if * they are self registering modules, but useless otherwise. */ f->numparams = 0; f->maxstacksize = 1; f->sizecode = 2*n + 1 ; f->sizek = 0; f->code = luaM_newvector(L, f->sizecode , Instruction); f->k = luaM_newvector(L,f->sizek,TValue); for (i=0, pc = f->code; i<n; i++) { *pc++ = CREATE_ABx(OP_CLOSURE,0,i); *pc++ = CREATE_ABC(OP_CALL,0,1,1); } *pc++ = CREATE_ABC(OP_RETURN,0,1,0); } else { /* * The Type 1 main() is a lookup which takes a single argument, the name to * be resolved. If this matches root name of one of the compiled files then * a closure to this file main is returned. Otherwise the Unixtime of the * compile and the list of root names is returned. */ if (n > LFIELDS_PER_FLUSH) { #define NO_MOD_ERR_(n) ": Number of modules > " #n #define NO_MOD_ERR(n) NO_MOD_ERR_(n) usage(LUA_QL("-f") NO_MOD_ERR(LFIELDS_PER_FLUSH)); } f->numparams = 1; f->maxstacksize = n + 3; f->sizecode = 5*n + 5 ; f->sizek = n + 1; f->sizelocvars = 0; f->code = luaM_newvector(L, f->sizecode , Instruction); f->k = luaM_newvector(L,f->sizek,TValue); for (i=0, pc = f->code; i<n; i++) { /* if arg1 == FnameA then return function (...) -- funcA -- end end */ setsvalue2n(L,f->k+i,corename(L, f->p[i]->source)); *pc++ = CREATE_ABC(OP_EQ,0,0,RKASK(i)); *pc++ = CREATE_ABx(OP_JMP,0,MAXARG_sBx+2); *pc++ = CREATE_ABx(OP_CLOSURE,1,i); *pc++ = CREATE_ABC(OP_RETURN,1,2,0); } setnvalue(f->k+n, (lua_Number) time(NULL)); *pc++ = CREATE_ABx(OP_LOADK,1,n); *pc++ = CREATE_ABC(OP_NEWTABLE,2,luaO_int2fb(i),0); for (i=0; i<n; i++) *pc++ = CREATE_ABx(OP_LOADK,i+3,i); *pc++ = CREATE_ABC(OP_SETLIST,2,i,1); *pc++ = CREATE_ABC(OP_RETURN,1,3,0); *pc++ = CREATE_ABC(OP_RETURN,0,1,0); } lua_assert((pc-f->code) == f->sizecode); return f; } }