eval method
- Contexts context
override
Implementation
@override
Node eval(Contexts context) {
var doubleParen = false;
final inParenthesis =
parens && (context.math != MathConstants.strictLegacy || !parensInOp);
final mathOn = context.isMathOn();
Node returnValue;
if (inParenthesis) context.inParenthesis();
if (value.length > 1) {
returnValue = Expression(value.map((Node e) => e?.eval(context)).toList(),
noSpacing: noSpacing);
} else if (value.length == 1) {
if (value.first.parens && !value.first.parensInOp && !context.inCalc) {
doubleParen = true;
}
returnValue = value.first.eval(context);
} else {
returnValue = this;
}
if (inParenthesis) context.outOfParenthesis();
if (parens &&
parensInOp &&
!mathOn &&
!doubleParen &&
returnValue is! Dimension) {
returnValue = Paren(returnValue);
}
return returnValue;
// 3.5.3 20180707
// Expression.prototype.eval = function (context) {
// var returnValue,
// mathOn = context.isMathOn(),
// inParenthesis = this.parens &&
// (context.math !== MATH.STRICT_LEGACY || !this.parensInOp),
// doubleParen = false;
// if (inParenthesis) {
// context.inParenthesis();
// }
// if (this.value.length > 1) {
// returnValue = new Expression(this.value.map(function (e) {
// if (!e.eval) {
// return e;
// }
// return e.eval(context);
// }), this.noSpacing);
// } else if (this.value.length === 1) {
// if (this.value[0].parens && !this.value[0].parensInOp && !context.inCalc) {
// doubleParen = true;
// }
// returnValue = this.value[0].eval(context);
// } else {
// returnValue = this;
// }
// if (inParenthesis) {
// context.outOfParenthesis();
// }
// if (this.parens && this.parensInOp && !mathOn && !doubleParen
// && (!(returnValue instanceof Dimension))) {
// returnValue = new Paren(returnValue);
// }
// return returnValue;
// };
}