コード例 #1
0
ファイル: eventtype.cpp プロジェクト: Zekom/kcachegrind
QString EventType::parsedFormula()
{
  QString res;

  if (!parseFormula()) return res;

  for (int i=0; i<ProfileCostArray::MaxRealIndex;i++) {
    int c = _coefficient[i];
    if (c == 0) continue;

    if (!res.isEmpty()) {
      res += ' ';
      if (c>0) res += "+ ";
    }
    if (c<0) { res += "- "; c = -c; }
    res += QString::number(c);

    EventType* t = _set->type(i);
    if (!t) continue;

    if (!t->name().isEmpty())
      res += QString(" * %1").arg(t->name());
  }

  return res;
}
コード例 #2
0
ファイル: parser.cpp プロジェクト: wfwt/jszb
static int parseAST(Parser *p)
{
#ifdef LOG_PARSE
	info("开始解析AST\n");
#endif
	p->ast = parseFormula(p);
	return p->ast ? 0 : -1;
}
コード例 #3
0
ファイル: Formula.c プロジェクト: xaberus/spreadsheet
Object * newFormula(Collector * c, Buffer * value) {
	Tokenizer tt;

	tokenizerInit(&tt, value);

	Object * result = parseFormula(c, &tt);

	if (tt.bp != tt.be) return NULL;
	return result;
}
コード例 #4
0
ファイル: eventtype.cpp プロジェクト: Zekom/kcachegrind
SubCost EventType::subCost(ProfileCostArray* c)
{
  if (_realIndex != ProfileCostArray::InvalidIndex)
    return c->subCost(_realIndex);

  if (!_parsed) {
    if (!parseFormula()) return 0;
  }
  SubCost res = 0;

  int rc = _set->realCount();
  for (int i = 0;i<rc;i++)
    if (_coefficient[i] != 0)
      res += _coefficient[i] * c->subCost(i);

  return res;
}
コード例 #5
0
ファイル: eventtype.cpp プロジェクト: Zekom/kcachegrind
int EventType::histCost(ProfileCostArray* c, double total, double* hist)
{
  if (total == 0.0) return 0;

  if (!_parsed) {
    if (!parseFormula()) return 0;
  }

  int rc = _set->realCount();
  for (int i = 0;i<rc;i++) {
    if (_coefficient[i] != 0)
      hist[i] = _coefficient[i] * c->subCost(i) / total;
    else
      hist[i] = 0.0;
  }

  return rc;
}
コード例 #6
0
std::string ReversePolandNotation::performCalculation(const std::string &formula) const
{
	return evaluateFormula(parseFormula(formula));
}