Mantis - Quercus
|
|||||
Viewing Issue Advanced Details | |||||
|
|||||
ID: | Category: | Severity: | Reproducibility: | Date Submitted: | Last Update: |
6010 | minor | always | 06-02-16 12:00 | 06-02-16 12:00 | |
|
|||||
Reporter: | matthiasblaesing | Platform: | |||
Assigned To: | OS: | ||||
Priority: | normal | OS Version: | |||
Status: | new | Product Version: | 4.0.36 | ||
Product Build: | Resolution: | open | |||
Projection: | none | ||||
ETA: | none | Fixed in Version: | |||
|
|||||
Summary: | 0006010: [PATCH] Implementation of try-finally | ||||
Description: |
I noticed, that try-finally is not yet supported in quercus. I had a look at a parser structure and implemented the necessary changes. I'd appretiate it, if you could integrate it into the codebase. --------------------------------------------------------------------------- # This patch file was generated by NetBeans IDE # It uses platform neutral UTF-8 encoding and \n newlines. --- a/modules/quercus/src/com/caucho/quercus/statement/TryStatement.java +++ b/modules/quercus/src/com/caucho/quercus/statement/TryStatement.java @@ -49,6 +49,7 @@ public class TryStatement extends Statement { protected final Statement _block; protected final ArrayList<Catch> _catchList = new ArrayList<Catch>(); + protected Statement finallyBlock = null; public TryStatement(Location location, Statement block) { @@ -66,6 +67,13 @@ block.setParent(this); } + public void setFinally(Statement block) + { + finallyBlock = block; + + finallyBlock.setParent(this); + } + public Value execute(Env env) { try { @@ -145,8 +153,12 @@ throw (QuercusException) e; else throw new QuercusException(e); + } finally { + if(finallyBlock != null) { + finallyBlock.execute(env); } } + } public static class Catch { private final StringValue _id; # This patch file was generated by NetBeans IDE # It uses platform neutral UTF-8 encoding and \n newlines. --- a/modules/quercus/src/com/caucho/quercus/parser/QuercusParser.java +++ b/modules/quercus/src/com/caucho/quercus/parser/QuercusParser.java @@ -181,6 +181,8 @@ private final static int INSTEADOF = 579; private final static int EMPTY = 580; + private final static int FINALLY = 581; + private final static int LAST_IDENTIFIER_LEXEME = 1024; private final static IntMap _insensitiveReserved = new IntMap(); @@ -1728,6 +1730,15 @@ token = parseToken(); } + if (token == FINALLY) { + + block = parseStatement(); + + stmt.setFinally(block); + + token = parseToken(); + } + _peekToken = token; return stmt; @@ -6580,6 +6591,7 @@ _insensitiveReserved.put("throw", THROW); _insensitiveReserved.put("try", TRY); _insensitiveReserved.put("catch", CATCH); + _insensitiveReserved.put("finally", FINALLY); _insensitiveReserved.put("interface", INTERFACE); _insensitiveReserved.put("trait", TRAIT); _insensitiveReserved.put("insteadof", INSTEADOF); |
||||
Steps To Reproduce: | |||||
Additional Information: | |||||
Relationships | |||||
Attached Files: |
There are no notes attached to this issue. |