Merge pull request #64 from shannah/fix_rt_str

Fixed issue with null strings in $rt_str.
This commit is contained in:
Alexey Andreev 2015-02-20 15:22:14 +03:00
commit 869f252b69

View File

@ -225,6 +225,9 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
private void renderRuntimeString() throws IOException {
MethodReference stringCons = new MethodReference(String.class, "<init>", char[].class, void.class);
writer.append("function $rt_str(str) {").indent().softNewLine();
writer.append("if (str===null){").indent().softNewLine();
writer.append("return null;").softNewLine();
writer.outdent().append("}").softNewLine();
writer.append("var characters = $rt_createCharArray(str.length);").softNewLine();
writer.append("var charsBuffer = characters.data;").softNewLine();
writer.append("for (var i = 0; i < str.length; i = (i + 1) | 0) {").indent().softNewLine();