本文整理汇总了C++中ASTNode::getLeftChild方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTNode::getLeftChild方法的具体用法?C++ ASTNode::getLeftChild怎么用?C++ ASTNode::getLeftChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTNode
的用法示例。
在下文中一共展示了ASTNode::getLeftChild方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkUnary
/**
* Checks that the function has only one argument
*/
void NumberArgsMathCheck::checkUnary(const Model& m,
const ASTNode& node, const SBase & sb)
{
if (node.getNumChildren() != 1)
{
logMathConflict(node, sb);
}
else
{
checkMath(m, *node.getLeftChild(), sb);
}
}
示例2: if
/**
* Checks that the arguments of the branches of a piecewise are consistent
*
* If not, an error message is logged.
*/
void
PiecewiseValueMathCheck::checkPiecewiseArgs (const Model& m, const ASTNode& node,
const SBase & sb)
{
unsigned int numChildren = node.getNumChildren();
/* arguments must return consistent types */
for (unsigned int n = 0; n < numChildren; n += 2)
{
if (returnsNumeric(m, node.getChild(n)) &&
!returnsNumeric(m, node.getLeftChild()))
{
logMathConflict(node, sb);
}
else if (node.getChild(n)->isBoolean() &&
!node.getLeftChild()->isBoolean())
{
logMathConflict(node, sb);
}
}
}
示例3: if
/**
* Checks that the arguments to eq or neq are consistent
* i.e. have same type both boolean or both numeric
*
* If an inconsistency is found, an error message is logged.
*/
void
EqualityArgsMathCheck::checkArgs (const Model& m,
const ASTNode& node,
const SBase & sb)
{
/* check that node has two children */
if (node.getNumChildren() != 2)
{
return;
}
/* arguments must return consistent value types */
if (returnsNumeric(m, node.getLeftChild()) &&
!returnsNumeric(m, node.getRightChild()))
{
logMathConflict(node, sb);
}
else if (node.getLeftChild()->isBoolean() &&
!node.getRightChild()->isBoolean())
{
logMathConflict(node, sb);
}
}
示例4: UnitDefinition
/*
* Checks that the units of the delay function are consistent
*
* If inconsistent units are found, an error message is logged.
*/
void
ArgumentsUnitsCheck::checkUnitsFromDelay (const Model& m,
const ASTNode& node,
const SBase & sb, bool inKL, int reactNo)
{
/* check that node has two children */
if (node.getNumChildren() != 2)
{
return;
}
if (!m.getSBMLNamespaces()->getNamespaces())
{
#if 0
cout << "[DEBUG] XMLNS IS NULL" << endl;
#endif
}
/* delay(x, t)
* no restrictions on units of x
* but t must have units of time
*/
UnitDefinition *time = new UnitDefinition(m.getSBMLNamespaces());
Unit *unit = new Unit(m.getSBMLNamespaces());
unit->setKind(UNIT_KIND_SECOND);
unit->initDefaults();
UnitDefinition * tempUD;
time->addUnit(unit);
UnitFormulaFormatter *unitFormat = new UnitFormulaFormatter(&m);
tempUD = unitFormat->getUnitDefinition(node.getRightChild(), inKL, reactNo);
if (!unitFormat->getContainsUndeclaredUnits())
{
if (!UnitDefinition::areEquivalent(time, tempUD))
{
logInconsistentDelay(node, sb);
}
}
delete time;
delete tempUD;
delete unit;
delete unitFormat;
checkUnits(m, *node.getLeftChild(), sb, inKL, reactNo);
}
示例5: getFieldname
/**
* @return the error message to use when logging constraint violations.
* This method is called by logFailure.
*
* Returns a message that the given @p id and its corresponding object are
* in conflict with an object previously defined.
*/
const string
PiecewiseValueMathCheck::getMessage (const ASTNode& node, const SBase& object)
{
ostringstream msg;
//msg << getPreamble();
char * left = SBML_formulaToString(node.getLeftChild());
msg << "\nThe piecewise formula ";
msg << "in the " << getFieldname() << " element of the " << getTypename(object);
msg << " returns arguments" ;
msg << " which have different value types from the first element '";
msg << left << "'.";
safe_free(left);
return msg.str();
}
示例6: createExampleInvolvingUnits
//.........这里部分代码省略.........
//
// <math xmlns=\"http://www.w3.org/1998/Math/MathML\">
// <apply>
// <times/>
// <apply>
// <divide/>
// <apply>
// <times/>
// <ci> vm </ci>
// <ci> s1 </ci>
// </apply>
// <apply>
// <plus/>
// <ci> km </ci>
// <ci> s1 </ci>
// </apply>
// </apply>
// <ci> cell </ci>
// </apply>
// </math>
//---------------------------------------------------------------------------
//
// In the following code, ASTNode objects, which construct an ASTNode tree
// of the above math, are created and added in the order of preorder traversal
// of the tree (i.e. the order corresponds to the nested structure of the above
// MathML elements), and thus the following code maybe a bit more efficient but
// maybe a bit difficult to read.
//
ASTNode* astMath = new ASTNode(AST_TIMES);
astMath->addChild(new ASTNode(AST_DIVIDE));
ASTNode* astDivide = astMath->getLeftChild();
astDivide->addChild(new ASTNode(AST_TIMES));
ASTNode* astTimes = astDivide->getLeftChild();
astTimes->addChild(new ASTNode(AST_NAME));
astTimes->getLeftChild()->setName("vm");
astTimes->addChild(new ASTNode(AST_NAME));
astTimes->getRightChild()->setName("s1");
astDivide->addChild(new ASTNode(AST_PLUS));
ASTNode* astPlus = astDivide->getRightChild();
astPlus->addChild(new ASTNode(AST_NAME));
astPlus->getLeftChild()->setName("km");
astPlus->addChild(new ASTNode(AST_NAME));
astPlus->getRightChild()->setName("s1");
astMath->addChild(new ASTNode(AST_NAME));
astMath->getRightChild()->setName("cell");
//---------------------------------------------
//
// set the Math element
//
//------------------------------------------------
kl->setMath(astMath);
delete astMath;
示例7: dim
/**
* Checks that the units of the power function are consistent
*
* If inconsistent units are found, an error message is logged.
*
* The two arguments to power, which are of the form power(a, b)
* with the meaning a^b, should be as follows:
* (1) if the second argument is an integer,
* then the first argument can have any units;
* (2) if the second argument b is a rational number n/m,
* it must be possible to derive the m-th root of (a{unit})n,
* where {unit} signifies the units associated with a;
* otherwise, (3) the units of the first argument must be “dimensionless”.
* The second argument (b) should always have units of “dimensionless”.
*
*/
void
PowerUnitsCheck::checkUnitsFromPower (const Model& m,
const ASTNode& node,
const SBase & sb, bool inKL, int reactNo)
{
/* check that node has 2 children */
if (node.getNumChildren() != 2)
{
return;
}
double value;
UnitDefinition dim(m.getSBMLNamespaces());
Unit unit(m.getSBMLNamespaces());
unit.setKind(UNIT_KIND_DIMENSIONLESS);
unit.initDefaults();
dim.addUnit(&unit);
UnitFormulaFormatter *unitFormat = new UnitFormulaFormatter(&m);
UnitDefinition *tempUD = NULL;
UnitDefinition *unitsArg1, *unitsArgPower;
unitsArg1 = unitFormat->getUnitDefinition(node.getLeftChild(), inKL, reactNo);
unsigned int undeclaredUnits =
unitFormat->getContainsUndeclaredUnits();
ASTNode *child = node.getRightChild();
unitFormat->resetFlags();
unitsArgPower = unitFormat->getUnitDefinition(child, inKL, reactNo);
unsigned int undeclaredUnitsPower =
unitFormat->getContainsUndeclaredUnits();
// The second argument (b) should always have units of “dimensionless”.
// or it has undeclared units that we assume are correct
if (undeclaredUnitsPower == 0 && !UnitDefinition::areEquivalent(&dim, unitsArgPower))
{
logNonDimensionlessPowerConflict(node, sb);
}
// The first argument is dimensionless then it doesnt matter
// what the power is
if (undeclaredUnits == 0 && !UnitDefinition::areEquivalent(&dim, unitsArg1))
{
// if not argument needs to be an integer or a rational
unsigned int isInteger = 0;
unsigned int isRational = 0;
unsigned int isExpression = 0;
/* power must be an integer
* but need to check that it is not a real
* number that is integral
* i.e. mathml <cn> 2 </cn> will record a "real"
*/
if (child->isRational())
{
isRational = 1;
}
else if (child->isInteger())
{
isInteger = 1;
}
else if (child->isReal())
{
if (ceil(child->getReal()) == child->getReal())
{
isInteger = 1;
}
}
else if (child->getNumChildren() > 0)
{
// power might itself be an expression
tempUD = unitFormat->getUnitDefinition(child, inKL, reactNo);
UnitDefinition::simplify(tempUD);
if (tempUD->isVariantOfDimensionless())
{
SBMLTransforms::mapComponentValues(&m);
double value = SBMLTransforms::evaluateASTNode(child);
SBMLTransforms::clearComponentValues();
//.........这里部分代码省略.........