void Simple::generateCondition(vpz::AtomicModel& model, vpz::Conditions& conditions) { std::string conditionName((fmt("cond_DE_%1%") % model.getName()).str()); if (conditions.exist(conditionName)) { vpz::Condition& condition(conditions.get(conditionName)); mNameValue.deletePorts(condition); mMapping.deletePorts(condition); mTimeStep.deletePorts(condition); mParameters.deletePorts(condition); mNameValue.assign(condition); mMapping.assign(condition); mTimeStep.assign(condition); mParameters.assign(condition); } else { vpz::Condition condition(conditionName); mNameValue.assign(condition); mMapping.assign(condition); mTimeStep.assign(condition); mParameters.assign(condition); conditions.add(condition); } std::vector < std::string > cond(model.conditions()); if (std::find(cond.begin(), cond.end(), conditionName) == cond.end()) { cond.push_back(conditionName); model.setConditions(cond); } }
const char* ARMv7DOpcodeMiscIfThenT1::format() { char opName[6]; opName[0] = 'i'; opName[1] = 't'; unsigned condition = firstCondition(); unsigned maskBits = mask(); unsigned blockLength = 0; for (unsigned i = 0; i < 4; ++i) { if (maskBits & (1 << i)) { blockLength = 4 - i; break; } } startITBlock(blockLength, condition); for (unsigned i = 1; i < blockLength; ++i) { unsigned currMaskBit = (maskBits >> (4-i)) & 0x1; opName[i + 1] = (currMaskBit ^ (condition & 1)) ? 'e' : 't'; saveITConditionAt(i, (condition & ~1) | currMaskBit); } opName[blockLength + 1] = '\0'; appendInstructionNameNoITBlock(opName); appendString(conditionName(condition)); return m_formatBuffer; }
void ARMv7DOpcode::appendInstructionName(const char* instructionName, bool addS) { if (!inITBlock() && !addS) { appendInstructionNameNoITBlock(instructionName); return; } const char sevenSpaces[8] = " "; unsigned length = strlen(instructionName); bufferPrintf(" %s", instructionName); if (inITBlock()) { const char* condition = conditionName(m_currentITCondition); length += strlen(condition); appendString(condition); } else if (addS) { length++; appendCharacter('s'); } if (length >= 7) length = 6; appendString(sevenSpaces + length); }
const char* ARMv7DOpcodeConditionalBranchT3::format() { if (condition() < 0xe) bufferPrintf(" b%-6.6s", conditionName(condition())); else appendInstructionName("b"); appendPCRelativeOffset(offset() + 2); return m_formatBuffer; }
const char* ARMv7DOpcodeBranchConditionalT1::format() { if (condition() == 0xe) return defaultFormat(); if (condition() == 0xf) { appendInstructionName("svc"); appendUnsignedImmediate(offset()); return m_formatBuffer; } bufferPrintf(" b%-6.6s", conditionName(condition())); appendPCRelativeOffset(static_cast<int32_t>(offset()) + 2); return m_formatBuffer; }
bool Simple::modify(vpz::AtomicModel& model, vpz::Dynamic& dynamic, vpz::Conditions& conditions, vpz::Observables& observables, const std::string& conf, const std::string& buffer) { std::string namespace_; std::string classname; Parameters::Parameters_t parameters; Parameters::ExternalVariables_t externalVariables; parseConf(conf, classname, namespace_, parameters, externalVariables); parseFunctions(buffer); std::string conditionName((fmt("cond_DE_%1%") % model.getName()).str()); build(true); if (not conditions.exist(conditionName)) { vpz::Condition condition(conditionName); Simple::fillFields(condition); mParameters.fillFields(parameters, externalVariables); } else { Simple::fillFields(conditions.get(conditionName)); mParameters.fillFields(conditions.get(conditionName), parameters, externalVariables); } backup(); if (m_dialog->run() == Gtk::RESPONSE_ACCEPT) { generate(model, dynamic, conditions, observables, classname, namespace_); m_dialog->hide_all(); destroy(); return true; } m_dialog->hide_all(); destroy(); return false; }
bool Simple::create(vpz::AtomicModel& model, vpz::Dynamic& dynamic, vpz::Conditions& conditions, vpz::Observables& observables, const std::string& classname, const std::string& namespace_) { std::string conditionName((fmt("cond_DE_%1%") % model.getName()).str()); build(true); if (not conditions.exist(conditionName)) { vpz::Condition condition(conditionName); Simple::fillFields(condition); } else { Simple::fillFields(conditions.get(conditionName)); } mIncludes = ""; mComputeFunction = "virtual double compute(const vd::Time& /*time*/)\n" \ "{ return 0; }\n"; mInitValueFunction = "virtual double initValue(const vd::Time& /*time*/)\n" \ "{ return 0; }\n"; mUserFunctions = ""; if (m_dialog->run() == Gtk::RESPONSE_ACCEPT) { generate(model, dynamic, conditions, observables, classname, namespace_); m_dialog->hide_all(); destroy(); return true; } m_dialog->hide_all(); destroy(); return false; }