void parse(Xbyak::CodeGenerator &gen, FILE *input, int membuf[MEMSIZE]) { gen.push(gen.ebx); Xbyak::Reg32 memreg = gen.ebx; Xbyak::Reg32 eax = gen.eax; Xbyak::Address mem = gen.dword[memreg]; gen.mov(memreg, (int) membuf); std::stack<int> labelStack; int labelNum = 0; int ch; while((ch=getc(input)) != EOF) { switch (ch) { case '+': gen.inc(mem); break; case '-': gen.dec(mem); break; case '>': gen.add(memreg, 4); break; case '<': gen.add(memreg, -4); break; case ',': gen.call((void*) getchar); gen.mov(mem, gen.eax); break; case '.': gen.push(mem); gen.call((void*) putchar); gen.pop(gen.eax); break; case '[': gen.L(toLabel('L', labelNum)); gen.mov(gen.eax, mem); gen.test(gen.eax, gen.eax); gen.jz(toLabel('R', labelNum), Xbyak::CodeGenerator::T_NEAR); labelStack.push(labelNum); ++labelNum; break; case ']': int beginNum = labelStack.top(); labelStack.pop(); gen.jmp(toLabel('L', beginNum), Xbyak::CodeGenerator::T_NEAR); gen.L(toLabel('R', beginNum)); break; } } gen.pop(gen.ebx); gen.ret(); }
bool executeIfOpenFOAMVersionBiggerEqualFunctionObject::condition() { #define TOSTRING(x) string(#x) label foamVersionPatch=-1; if(TOSTRING(FOAM_VERSION4SWAK_PATCH)!="x") { foamVersionPatch=toLabel(TOSTRING(FOAM_VERSION4SWAK_PATCH)); } if(majorVersion_>FOAM_VERSION4SWAK_MAJOR) { return false; } else if(majorVersion_<FOAM_VERSION4SWAK_MAJOR) { return true; } else if(minorVersion_>FOAM_VERSION4SWAK_MINOR) { return false; } else if(minorVersion_<FOAM_VERSION4SWAK_MINOR) { return true; } else if(foamVersionPatch<0) { return true; } else { return patchVersion_<=foamVersionPatch; } #undef TOSTRING }
void executeIfOpenFOAMVersionBiggerEqualFunctionObject::readData(const dictionary& dict) { majorVersion_=toLabel(string(dict.lookup("majorVersion"))); minorVersion_=toLabel(string(dict.lookup("minorVersion"))); patchVersion_=toLabel(dict.lookupOrDefault<string>("patchVersion","")); }