« Return to Thread: [janino-dev] [jira] Created: (JANINO-117) UnparseVisitor does not handle Byte or Short Literals

[janino-dev] [jira] Reopened: (JANINO-117) UnparseVisitor does not handle Byte or Short Literals

by JIRA jira@codehaus.org :: Rate this Message:

Reply to Author | View in Thread


     [ http://jira.codehaus.org/browse/JANINO-117?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Fowles reopened JANINO-117:
--------------------------------


I would strongly urge you to reconsider this choice.  While Java does not allow byte literals directly, making your AST support them increases the expressive power of your library, without exposing any bugs.

In fact, this ability greatly simplifies targeting Janino's AST from a different compiler, which is exactly what we are doing.

> UnparseVisitor does not handle Byte or Short Literals
> -----------------------------------------------------
>
>                 Key: JANINO-117
>                 URL: http://jira.codehaus.org/browse/JANINO-117
>             Project: Janino
>          Issue Type: Bug
>            Reporter: Matt Fowles
>            Assignee: Arno Unkrig
>             Fix For: 2.5.15
>
>         Attachments: literals.diff
>
>
> The following test will fail with a RuntimeException.  While parsed java cannot create a literal Byte or Short value, it is fairly easy to create them directly from the AST, and handling them is quite simple.
> {code}
>     public void testLiterals() throws Exception {
>         Object[][] tests = new Object[][] {
>                 { new Java.Literal(null, new Short((short)1)), "((short)1)" },
>                 { new Java.Literal(null, new Byte((byte)1)),   "((byte)1)"  },
>         };
>         for(int i = 0; i < tests.length; ++i) {
>             Atom expr = (Atom) tests[i][0];
>             String expected = (String) tests[i][1];
>            
>             StringWriter sw = new StringWriter();
>             UnparseVisitor uv = new UnparseVisitor(sw);
>             expr.accept(uv);
>             Assert.assertEquals(expected, sw.toString());
>         }
>     }
> {code}

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: [janino-dev] [jira] Created: (JANINO-117) UnparseVisitor does not handle Byte or Short Literals