internal override bool Build(ref CodeNode _this, int depth, Dictionary<string, VariableDescriptor> variables, _BuildState state, CompilerMessageCallback message, FunctionStatistics statistic, Options opts) { depth = System.Math.Max(1, depth); Parser.Build(ref body, depth, variables, state | _BuildState.InLoop, message, statistic, opts); Parser.Build(ref condition, 2, variables, state | _BuildState.InLoop, message, statistic, opts); try { if (allowRemove && (opts & Options.SuppressUselessExpressionsElimination) == 0 && (condition is Constant || (condition as Expressions.Expression).IsContextIndependent)) { if ((bool)condition.Evaluate(null)) _this = new InfinityLoop(body, labels); else if (labels.Length == 0) _this = body; condition.Eliminated = true; } } #if PORTABLE catch {
protected override EP_VP1 Visit(InfinityLoop node) { node.Body.Visit(this); return(this); }
internal protected virtual T Visit(InfinityLoop node) { return(Visit(node as CodeNode)); }
internal override bool Build(ref CodeNode _this, int depth, Dictionary<string, VariableDescriptor> variables, _BuildState state, CompilerMessageCallback message, FunctionStatistics statistic, Options opts) { depth = System.Math.Max(1, depth); Parser.Build(ref body, depth, variables, state | _BuildState.Conditional | _BuildState.InLoop, message, statistic, opts); Parser.Build(ref condition, 2, variables, state | _BuildState.InLoop, message, statistic, opts); if ((opts & Options.SuppressUselessExpressionsElimination) == 0 && condition is ToBool) { if (message == null) message(MessageLevel.Warning, new CodeCoordinates(0, condition.Position, 2), "Useless conversion. Remove double negation in condition"); condition = (condition as Expression).first; } try { if (allowRemove && (condition is Constant || (condition is Expression && (condition as Expression).IsContextIndependent))) { if ((bool)condition.Evaluate(null)) { if ((opts & Options.SuppressUselessExpressionsElimination) == 0) _this = new InfinityLoop(body, labels); } else if ((opts & Options.SuppressUselessStatementsElimination) == 0) { _this = null; Eliminated = true; body.Eliminated = true; } condition.Eliminated = true; } else if ((opts & Options.SuppressUselessExpressionsElimination) == 0 && ((condition is Json && (condition as Json).Fields.Length == 0) || (condition is ArrayExpression && (condition as ArrayExpression).Elements.Count == 0))) { _this = new InfinityLoop(body, labels); condition.Eliminated = true; } } #if PORTABLE catch {