/// <summary> /// Handles the AST node visit. /// </summary> /// <param name="astNode">AST node.</param> public override void Visit(NumericOpAstNode astNode) { MetricExpressions arguments = new MetricExpressions(); astNode.Arguments.ForEach(arg => arguments.Add(MasterExporter.ToMetricExpression(arg))); switch (astNode.Operator) { case Traits.NumericOperator.PLUS: { ExpressionData = new MetricPlus(arguments); break; } case Traits.NumericOperator.MINUS: { if (arguments.Count == 1) { ExpressionData = new MetricUnaryMinus(arguments[0]); } else { ExpressionData = new MetricMinus(arguments[0], arguments[1]); } break; } case Traits.NumericOperator.MUL: { ExpressionData = new MetricMultiply(arguments); break; } case Traits.NumericOperator.DIV: { ExpressionData = new MetricDivide(arguments[0], arguments[1]); break; } default: { Debug.Assert(false); break; } } }
/// <summary> /// Handles the AST node visit. /// </summary> /// <param name="astNode">AST node.</param> public override void Visit(ProblemMetricAstNode astNode) { ProblemData.Metric = new Metric(astNode.OptimizationSpecifier, MasterExporter.ToMetricExpression(astNode.MetricExpression)); }