private static Expression GenerateMultipliedStringIfNotTooLong(OpChain original, Expression left, Expression right) { string stringValue = ((left as StringConstant) ?? (right as StringConstant)).Value; int intValue = ((left as IntegerConstant) ?? (right as IntegerConstant)).Value; // don't consolidate this operation if it's going to make the file size blow up. if (intValue * stringValue.Length <= 50) { string output = ""; while (intValue > 0) { output += stringValue; --intValue; } return(new StringConstant(original.FirstToken, output, original.Owner)); } return(original); }
public static OpChain Build(IList <Expression> expressions, IList <Token> ops, Node owner) { int expressionIndex = 0; int opIndex = 0; Expression left = expressions[expressionIndex++]; Expression right = expressions[expressionIndex++]; Token op = ops[opIndex++]; OpChain boc = new OpChain(left, op, right, owner); while (expressionIndex < expressions.Count) { right = expressions[expressionIndex++]; op = ops[opIndex++]; boc = new OpChain(boc, op, right, owner); } return(boc); }