system/src/sc/lang/java/ExecutionContext.java
public Object findThisType(Object enclType) {
      Object thisObj;
      /*
      for (int i = currentObjects.size()-1; i >= 0; i--) {
         thisObj = currentObjects.get(i);
         if (ModelUtil.isAssignableFrom(enclType, DynUtil.getType(thisObj))) {
            return thisObj;
         }
      }
      */
      thisObj = getCurrentObject();
      if (thisObj == null)
         return null;
      Object pType = DynUtil.getType(thisObj);

      while (pType != null && !ModelUtil.isAssignableFrom(enclType, pType)) {
         Object outerObj = null;
         if (system != null)
            outerObj = system.getOuterInstance(thisObj);
         if (outerObj == null)
            outerObj = DynObject.getParentInstance(thisObj);
         thisObj = outerObj;

         if (thisObj == null)
            break;

         // Pull the current type off the object, do not use the enclosing type as it might not match the instance's type hierarchy.  You can extend an inner class at a different level of the hierarchy of the same outer class.
         pType = DynUtil.getType(thisObj);
         // Get the most specific type for this type, in case it was modified etc.
         pType = ModelUtil.resolve(pType, true);
      }
      if (thisObj == null) {
         System.err.println("Unable to resolve 'this' object referring to type: " + enclType + " context includes: " + currentObjTypesToString());
      }
      return thisObj;
   }
/**
    * In Java, you can refer to a "this" construct up on the stack: "EnclosingType.this".  When you construct
    * an inner class, similarly it fills in the wrapping outer type automatically.  This method implements
    * that lookup.
    */
In Java, you can refer to a "this" construct up on the stack: "EnclosingType.this".  When you construct
an inner class, similarly it fills in the wrapping outer type automatically.  This method implements
that lookup.
In Java you can refer to a " this " construct up on the stack : " EnclosingType . this " . When you construct an inner class similarly it fills in the wrapping outer type automatically . This method implements that lookup .
public Object findThisType(Object enclType) {
      Object thisObj;
      /*
      for (int i = currentObjects.size()-1; i >= 0; i--) {
         thisObj = currentObjects.get(i);
         if (ModelUtil.isAssignableFrom(enclType, DynUtil.getType(thisObj))) {
            return thisObj;
         }
      }
      */
      thisObj = getCurrentObject();
      if (thisObj == null)
         return null;
      Object pType = DynUtil.getType(thisObj);
      while (pType != null && !ModelUtil.isAssignableFrom(enclType, pType)) {
         Object outerObj = null;
         if (system != null)
            outerObj = system.getOuterInstance(thisObj);
         if (outerObj == null)
            outerObj = DynObject.getParentInstance(thisObj);
         thisObj = outerObj;
         if (thisObj == null)
            break;
         pType = DynUtil.getType(thisObj);
         pType = ModelUtil.resolve(pType, true);
      }
      if (thisObj == null) {
         System.err.println("Unable to resolve 'this' object referring to type: " + enclType + " context includes: " + currentObjTypesToString());
      }
      return thisObj;
   }
public Object findThisType ( Object enclType ) { Object thisObj ; /*
      for (int i = currentObjects.size()-1; i >= 0; i--) {
         thisObj = currentObjects.get(i);
         if (ModelUtil.isAssignableFrom(enclType, DynUtil.getType(thisObj))) {
            return thisObj;
         }
      }
      */ thisObj = getCurrentObject ( ) ; if ( thisObj == null ) return null ; Object pType = DynUtil . getType ( thisObj ) ; while ( pType != null && ! ModelUtil . isAssignableFrom ( enclType , pType ) ) { Object outerObj = null ; if ( system != null ) outerObj = system . getOuterInstance ( thisObj ) ; if ( outerObj == null ) outerObj = DynObject . getParentInstance ( thisObj ) ; thisObj = outerObj ; if ( thisObj == null ) break ; pType = DynUtil . getType ( thisObj ) ; pType = ModelUtil . resolve ( pType , true ) ; } if ( thisObj == null ) { System . err . println ( "Unable to resolve 'this' object referring to type: " + enclType + " context includes: " + currentObjTypesToString ( ) ) ; } return thisObj ; }
In Java, you can refer to a "this" construct up on the stack: "EnclosingType.this".
In Java you can refer to a " this " construct up on the stack : " EnclosingType . this " .
// Pull the current type off the object, do not use the enclosing type as it might not match the instance's type hierarchy.  You can extend an inner class at a different level of the hierarchy of the same outer class. // Get the most specific type for this type, in case it was modified etc.