system/src/sc/lang/java/BodyTypeDeclaration.java
private void updateInstFromBody(Object inst, SyncManager.SyncContext syncCtx, ExecutionContext ctx, SemanticNodeList<Statement> toUpdate) {
      if (toUpdate == null)
         return;
      for (Statement st : toUpdate) {
         if (st instanceof OverrideAssignment) {
            // TODO: check if there is an @Sync annotation here?  The client sends down: "override @Sync propName;" to fetch a property.
            OverrideAssignment ost = (OverrideAssignment) st;
            syncCtx.updateProperty(inst, ost.propertyName, false, true);
         }
         else if (st instanceof PropertyAssignment) {
            String propName = ((PropertyAssignment) st).propertyName;
            Object instType = DynUtil.getSType(inst);
            // Do a security check to be sure we're allowed to update this property
            if (syncCtx != null && ctx.allowSetProperty(instType, propName)) {
               if (st.isStatic()) {
                  updateStaticProperty(st, ctx);
               }
               else {
                  initInstance(st, inst, ctx, InitInstanceType.Init);
               }
            }
            else {
               System.err.println("Not allowed to set unsynchronized property from scn: " + DynUtil.getTypeName(instType, true) + "." + propName);
            }
         }
         else if (st instanceof BodyTypeDeclaration) {
            BodyTypeDeclaration td = (BodyTypeDeclaration) st;
            // Get type name here - pass it in as the outer instance for the enclosed object tag.

            td.updateRuntimeType(ctx, syncCtx, inst);
         }
         else if (st instanceof FieldDefinition) {
            FieldDefinition field = (FieldDefinition) st;
            SyncManager.SyncState oldState = null;
            if (syncCtx != null)
               oldState = SyncManager.setSyncState(SyncManager.SyncState.RecordingChanges);
            field.updateRuntimeType(inst, syncCtx, ctx);
            if (syncCtx != null)
               SyncManager.setSyncState(oldState);

         }
         else if (st instanceof BlockStatement) {
            BlockStatement bs = (BlockStatement) st;

            if (bs.staticEnabled)
               System.err.println("*** Static block statements not implemented in updateInstFromBody");
            else
               bs.execForObj(inst, ctx);
         }
         else {
            // TODO: implement sub-types, methods etc.
            System.err.println("*** Warning - unimplemented update in updateInstFromBody");
         }
      }
   }
/* TODO: remove this - before we used to use an initial pass to first record the other side's values but that's now done with the thread local variable
   public void updatePreviousValues(Object inst, SyncManager.SyncContext syncCtx, ExecutionContext eCtx) {
      updatePreviousFromBody(inst, syncCtx, eCtx, body);
      updatePreviousFromBody(inst, syncCtx, eCtx, hiddenBody);
   }

   private void updatePreviousFromBody(Object inst, SyncManager.SyncContext syncCtx, ExecutionContext eCtx, SemanticNodeList<Statement> toUpdate) {
      if (toUpdate == null)
         return;
      for (Statement st:toUpdate) {
         if (st instanceof PropertyAssignment) {
            if (st.isStatic()) {
               System.err.println("*** not syncing static properties");
            }
            else {
               PropertyAssignment pa = (PropertyAssignment) st;
               if (pa.initializer != null) {
                  Object initVal = pa.initializer.eval(null, eCtx);
                  syncCtx.addPreviousValue(inst, pa.propertyName, initVal, true);
               }
            }
         }
      }
   }
   */
remove this - before we used to use an initial pass to first record the other side's values but that's now done with the thread local variable
public void updatePreviousValues(Object inst, SyncManager.SyncContext syncCtx, ExecutionContext eCtx) {
updatePreviousFromBody(inst, syncCtx, eCtx, body);
updatePreviousFromBody(inst, syncCtx, eCtx, hiddenBody);
}


remove this - before we used to use an initial pass to first record the other side ' s values but that ' s now done with the thread local variable public void updatePreviousValues ( Object inst SyncManager . SyncContext syncCtx ExecutionContext eCtx ) { updatePreviousFromBody ( inst syncCtx eCtx body ) ; updatePreviousFromBody ( inst syncCtx eCtx hiddenBody ) ; }
private void updateInstFromBody(Object inst, SyncManager.SyncContext syncCtx, ExecutionContext ctx, SemanticNodeList<Statement> toUpdate) {
      if (toUpdate == null)
         return;
      for (Statement st : toUpdate) {
         if (st instanceof OverrideAssignment) {
            OverrideAssignment ost = (OverrideAssignment) st;
            syncCtx.updateProperty(inst, ost.propertyName, false, true);
         }
         else if (st instanceof PropertyAssignment) {
            String propName = ((PropertyAssignment) st).propertyName;
            Object instType = DynUtil.getSType(inst);
            if (syncCtx != null && ctx.allowSetProperty(instType, propName)) {
               if (st.isStatic()) {
                  updateStaticProperty(st, ctx);
               }
               else {
                  initInstance(st, inst, ctx, InitInstanceType.Init);
               }
            }
            else {
               System.err.println("Not allowed to set unsynchronized property from scn: " + DynUtil.getTypeName(instType, true) + "." + propName);
            }
         }
         else if (st instanceof BodyTypeDeclaration) {
            BodyTypeDeclaration td = (BodyTypeDeclaration) st;
            td.updateRuntimeType(ctx, syncCtx, inst);
         }
         else if (st instanceof FieldDefinition) {
            FieldDefinition field = (FieldDefinition) st;
            SyncManager.SyncState oldState = null;
            if (syncCtx != null)
               oldState = SyncManager.setSyncState(SyncManager.SyncState.RecordingChanges);
            field.updateRuntimeType(inst, syncCtx, ctx);
            if (syncCtx != null)
               SyncManager.setSyncState(oldState);
         }
         else if (st instanceof BlockStatement) {
            BlockStatement bs = (BlockStatement) st;
            if (bs.staticEnabled)
               System.err.println("*** Static block statements not implemented in updateInstFromBody");
            else
               bs.execForObj(inst, ctx);
         }
         else {
            System.err.println("*** Warning - unimplemented update in updateInstFromBody");
         }
      }
   }
private void updateInstFromBody ( Object inst , SyncManager . SyncContext syncCtx , ExecutionContext ctx , SemanticNodeList < Statement > toUpdate ) { if ( toUpdate == null ) return ; for ( Statement st : toUpdate ) { if ( st instanceof OverrideAssignment ) { OverrideAssignment ost = ( OverrideAssignment ) st ; syncCtx . updateProperty ( inst , ost . propertyName , false , true ) ; } else if ( st instanceof PropertyAssignment ) { String propName = ( ( PropertyAssignment ) st ) . propertyName ; Object instType = DynUtil . getSType ( inst ) ; if ( syncCtx != null && ctx . allowSetProperty ( instType , propName ) ) { if ( st . isStatic ( ) ) { updateStaticProperty ( st , ctx ) ; } else { initInstance ( st , inst , ctx , InitInstanceType . Init ) ; } } else { System . err . println ( "Not allowed to set unsynchronized property from scn: " + DynUtil . getTypeName ( instType , true ) + "." + propName ) ; } } else if ( st instanceof BodyTypeDeclaration ) { BodyTypeDeclaration td = ( BodyTypeDeclaration ) st ; td . updateRuntimeType ( ctx , syncCtx , inst ) ; } else if ( st instanceof FieldDefinition ) { FieldDefinition field = ( FieldDefinition ) st ; SyncManager . SyncState oldState = null ; if ( syncCtx != null ) oldState = SyncManager . setSyncState ( SyncManager . SyncState . RecordingChanges ) ; field . updateRuntimeType ( inst , syncCtx , ctx ) ; if ( syncCtx != null ) SyncManager . setSyncState ( oldState ) ; } else if ( st instanceof BlockStatement ) { BlockStatement bs = ( BlockStatement ) st ; if ( bs . staticEnabled ) System . err . println ( "*** Static block statements not implemented in updateInstFromBody" ) ; else bs . execForObj ( inst , ctx ) ; } else { System . err . println ( "*** Warning - unimplemented update in updateInstFromBody" ) ; } } }
TODO: remove this - before we used to use an initial pass to first record the other side's values but that's now done with the thread local variable
public void updatePreviousValues(Object inst, SyncManager.SyncContext syncCtx, ExecutionContext eCtx) {
updatePreviousFromBody(inst, syncCtx, eCtx, body);
updatePreviousFromBody(inst, syncCtx, eCtx, hiddenBody);
}
TODO : remove this - before we used to use an initial pass to first record the other side ' s values but that ' s now done with the thread local variable public void updatePreviousValues ( Object inst SyncManager . SyncContext syncCtx ExecutionContext eCtx ) { updatePreviousFromBody ( inst syncCtx eCtx body ) ; updatePreviousFromBody ( inst syncCtx eCtx hiddenBody ) ; }
// TODO: check if there is an @Sync annotation here?  The client sends down: "override @Sync propName;" to fetch a property. // Do a security check to be sure we're allowed to update this property // Get type name here - pass it in as the outer instance for the enclosed object tag. // TODO: implement sub-types, methods etc.