Project

General

Profile

6410.patch

BlockManager returnNormal - Marian Edu, 04/29/2024 02:49 AM

Download (2.6 KB)

View differences:

src/com/goldencode/p2j/util/BlockManager.java
9413 9413
      else if (rtype == ReturnType.NORMAL && wa.tm.getBlockType() == BlockType.FUNCTION)
9414 9414
      {
9415 9415
         // otherwise, check if this return can skip the exception throw
9416

  
9417
         Object thisProc = wa.pm._thisProcedure();
9418
         String clsName = null;
9419
         if (thisProc instanceof _BaseObject_) 
9416
         CalleeInfo calinfo = wa.pm.peekCalleeInfo();
9417
         Class<?> cls = calinfo != null ? calinfo.getExecuting() : null;
9418
         
9419
         if (cls == null)
9420 9420
         {
9421
            clsName = thisProc.getClass().getName();
9422
         }
9423
         else if (thisProc.getClass() == Object.class)
9424
         {
9425
            // this case handles static OO method calls - for this, FWD uses a surrogate java.lang.Object 
9426
            // instance to be used as THIS-PROCEDURE; THIS-PROCEDURE is how FWD internally identifies the
9427
            // context of the current call (and for static calls there is no 'instance', thus the 
9428
            // java.lang.Object surrogate).
9429
            Class<? extends _BaseObject_> cls = ObjectOps.getStaticClass(thisProc);
9430
            clsName = cls.getName();
9421
            Object thisProc = wa.pm._thisProcedure();
9422
            
9423
            if (thisProc instanceof _BaseObject_) 
9424
            {
9425
               cls = thisProc.getClass();
9426
            }
9427
            else if (thisProc.getClass() == Object.class)
9428
            {
9429
               // this case handles static OO method calls - for this, FWD uses a surrogate java.lang.Object 
9430
               // instance to be used as THIS-PROCEDURE; THIS-PROCEDURE is how FWD internally identifies the
9431
               // context of the current call (and for static calls there is no 'instance', thus the 
9432
               // java.lang.Object surrogate).
9433
               cls = ObjectOps.getStaticClass(thisProc);
9434
            }
9431 9435
         }
9432 9436
         
9433
         // TODO: replace this test with cls.isAnnotation(LegacyResource.class) ?
9434
         if (clsName != null && clsName.startsWith("com.goldencode.p2j.oo"))
9437
         if (!cls.isAnnotationPresent(LegacyResource.class))
9435 9438
         {
9436
            // WARNING: the p2o.oo code is not refactored to use 'storeReturnValue' or Java return statements
9437
            // instead, this code uses and expects for the returnNormal call to exit the block.
9438
         }
9439
         else
9440
         {
9441
            return;
9439
           return;
9442 9440
         }
9443 9441
      }
9444 9442