Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0006010 [Quercus] minor always 06-02-16 12:00 06-02-16 12:00
Reporter matthiasblaesing View Status public  
Assigned To
Priority normal Resolution open  
Status new   Product Version 4.0.36
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);
Additional Information
Attached Files

- Relationships

There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
06-02-16 12:00 matthiasblaesing New Issue


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
26 total queries executed.
24 unique queries executed.
Powered by Mantis Bugtracker