public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary <string, VariableDescriptor> variables, CodeContext codeContext, InternalCompilerMessageCallback message, FunctionInfo stats, Options opts) { expressionDepth = System.Math.Max(1, expressionDepth); Parser.Build(ref body, expressionDepth, variables, codeContext | CodeContext.InLoop, message, stats, opts); Parser.Build(ref condition, 2, variables, codeContext | CodeContext.InLoop | CodeContext.InExpression, message, stats, opts); try { if (allowRemove && (opts & Options.SuppressUselessExpressionsElimination) == 0 && (condition is Constant || (condition as Expressions.Expression).ContextIndependent)) { if ((bool)condition.Evaluate(null)) { _this = new InfinityLoop(body, labels); } else if (labels.Length == 0) { _this = body; } condition.Eliminated = true; } } #if (PORTABLE || NETCORE) catch {
public override bool Build(ref CodeNode _this, int expressionDepth, Dictionary <string, VariableDescriptor> variables, CodeContext codeContext, InternalCompilerMessageCallback message, FunctionInfo stats, Options opts) { expressionDepth = System.Math.Max(1, expressionDepth); Parser.Build(ref body, expressionDepth, variables, codeContext | CodeContext.Conditional | CodeContext.InLoop, message, stats, opts); Parser.Build(ref condition, 2, variables, codeContext | CodeContext.InLoop | CodeContext.InExpression, message, stats, opts); if ((opts & Options.SuppressUselessExpressionsElimination) == 0 && condition is ConvertToBoolean) { if (message != null) { message(MessageLevel.Warning, condition.Position, 2, "Useless conversion. Remove double negation in condition"); } condition = (condition as Expression)._left; } try { if (allowRemove && (condition is Constant || (condition is Expression && (condition as Expression).ContextIndependent))) { Eliminated = true; if ((bool)condition.Evaluate(null)) { if ((opts & Options.SuppressUselessExpressionsElimination) == 0 && body != null) { _this = new InfinityLoop(body, labels); } } else if ((opts & Options.SuppressUselessStatementsElimination) == 0) { _this = null; if (body != null) { body.Eliminated = true; } } condition.Eliminated = true; } else if ((opts & Options.SuppressUselessExpressionsElimination) == 0 && ((this.condition is Expressions.ObjectDefinition && (this.condition as Expressions.ObjectDefinition).FieldNames.Length == 0) || (this.condition is ArrayDefinition && (this.condition as ArrayDefinition).Elements.Length == 0))) { _this = new InfinityLoop(this.body, this.labels); this.condition.Eliminated = true; } } #if (PORTABLE || NETCORE) catch {