system/src/sc/lang/java/ClassDeclaration.java
public void addUncompiledPropertyAssignments(TypeDeclaration outer, SemanticNodeList<Statement> assignments) {
      Object baseTypeObj = getDerivedTypeDeclaration();
      while (baseTypeObj instanceof ModifyDeclaration)
         baseTypeObj = ((ModifyDeclaration)baseTypeObj).getDerivedTypeDeclaration();

      // If this is a class, we have all of its assignments compiled in, but if it is a declaration we may need to include those
      // here.
      if (baseTypeObj instanceof ClassDeclaration) {

         ClassDeclaration baseType = (ClassDeclaration) baseTypeObj;
         baseType = (ClassDeclaration) baseType.getTransformedResult();
         /* If our base type is not the compiled class itself, we also need to collect its property assignments */
         if (baseType.getClassDeclarationForType() != baseType)
            baseType.addUncompiledPropertyAssignments(outer, assignments);
      }
      String varName = CTypeUtil.decapitalizePropertyName(typeName);
      skippedClassVarName = varName;

      // TODO: should we eliminate double-initializations here?  We do reorder initializers anyway when we
      // set them on the field definition so it seems like we could reorder them here... or even sort them
      // based on dependencies?
      for (int x = 0; x < 2; x++) {
         List<Statement> theBody = x == 0 ? body : hiddenBody;
         if (theBody == null)
            continue;

         for (int i = 0; i < theBody.size(); i++) {
            Statement s = theBody.get(i);
            if (s instanceof PropertyAssignment) {
               PropertyAssignment assign = (PropertyAssignment) s;
               // this is a constructor property which will have already been initialized before the object is created so don't do this twice
               if (assign.constructorProp)
                  continue;
               Expression newAssign = assign.convertToAssignmentExpression(varName, true, assign.operator, false);
               newAssign.parentNode = assign.parentNode;
               ParseUtil.initAndStartComponent(newAssign);
               // Need to call this after we've copied the expression (and resolved references) since assign is possibly inherited.
               // For AssignmentExpressions' the lhs already has been redone so we only do the rhs.
               if (newAssign instanceof AssignmentExpression) {
                  ((AssignmentExpression) newAssign).rhs.changeExpressionsThis(this, outer, varName);
               }
               else {
                  newAssign.changeExpressionsThis(this, outer, varName);
               }

               // Convert {"a", "b"} to new String[] {"a", "b"}
               TransformUtil.convertArrayInitializerToNewExpression(newAssign);
               assignments.add(newAssign);
            }
         }
      }
   }
/**
    * This is the code which implements an important optimization.  For any inner classes which do not have
    * any fields or methods, we skip generating the class.  Since you can still derive from them and add
    * property assignments, we need to merge those all together into the constructor for that type.
    */
This is the code which implements an important optimization.  For any inner classes which do not have
any fields or methods, we skip generating the class.  Since you can still derive from them and add
property assignments, we need to merge those all together into the constructor for that type.
This is the code which implements an important optimization . For any inner classes which do not have any fields or methods we skip generating the class . Since you can still derive from them and add property assignments we need to merge those all together into the constructor for that type .
public void addUncompiledPropertyAssignments(TypeDeclaration outer, SemanticNodeList<Statement> assignments) {
      Object baseTypeObj = getDerivedTypeDeclaration();
      while (baseTypeObj instanceof ModifyDeclaration)
         baseTypeObj = ((ModifyDeclaration)baseTypeObj).getDerivedTypeDeclaration();
      if (baseTypeObj instanceof ClassDeclaration) {
         ClassDeclaration baseType = (ClassDeclaration) baseTypeObj;
         baseType = (ClassDeclaration) baseType.getTransformedResult();
         /* If our base type is not the compiled class itself, we also need to collect its property assignments */
         if (baseType.getClassDeclarationForType() != baseType)
            baseType.addUncompiledPropertyAssignments(outer, assignments);
      }
      String varName = CTypeUtil.decapitalizePropertyName(typeName);
      skippedClassVarName = varName;
      for (int x = 0; x < 2; x++) {
         List<Statement> theBody = x == 0 ? body : hiddenBody;
         if (theBody == null)
            continue;
         for (int i = 0; i < theBody.size(); i++) {
            Statement s = theBody.get(i);
            if (s instanceof PropertyAssignment) {
               PropertyAssignment assign = (PropertyAssignment) s;
               if (assign.constructorProp)
                  continue;
               Expression newAssign = assign.convertToAssignmentExpression(varName, true, assign.operator, false);
               newAssign.parentNode = assign.parentNode;
               ParseUtil.initAndStartComponent(newAssign);
               if (newAssign instanceof AssignmentExpression) {
                  ((AssignmentExpression) newAssign).rhs.changeExpressionsThis(this, outer, varName);
               }
               else {
                  newAssign.changeExpressionsThis(this, outer, varName);
               }
               TransformUtil.convertArrayInitializerToNewExpression(newAssign);
               assignments.add(newAssign);
            }
         }
      }
   }
public void addUncompiledPropertyAssignments ( TypeDeclaration outer , SemanticNodeList < Statement > assignments ) { Object baseTypeObj = getDerivedTypeDeclaration ( ) ; while ( baseTypeObj instanceof ModifyDeclaration ) baseTypeObj = ( ( ModifyDeclaration ) baseTypeObj ) . getDerivedTypeDeclaration ( ) ; if ( baseTypeObj instanceof ClassDeclaration ) { ClassDeclaration baseType = ( ClassDeclaration ) baseTypeObj ; baseType = ( ClassDeclaration ) baseType . getTransformedResult ( ) ; /* If our base type is not the compiled class itself, we also need to collect its property assignments */ if ( baseType . getClassDeclarationForType ( ) != baseType ) baseType . addUncompiledPropertyAssignments ( outer , assignments ) ; } String varName = CTypeUtil . decapitalizePropertyName ( typeName ) ; skippedClassVarName = varName ; for ( int x = 0 ; x < 2 ; x ++ ) { List < Statement > theBody = x == 0 ? body : hiddenBody ; if ( theBody == null ) continue ; for ( int i = 0 ; i < theBody . size ( ) ; i ++ ) { Statement s = theBody . get ( i ) ; if ( s instanceof PropertyAssignment ) { PropertyAssignment assign = ( PropertyAssignment ) s ; if ( assign . constructorProp ) continue ; Expression newAssign = assign . convertToAssignmentExpression ( varName , true , assign . operator , false ) ; newAssign . parentNode = assign . parentNode ; ParseUtil . initAndStartComponent ( newAssign ) ; if ( newAssign instanceof AssignmentExpression ) { ( ( AssignmentExpression ) newAssign ) . rhs . changeExpressionsThis ( this , outer , varName ) ; } else { newAssign . changeExpressionsThis ( this , outer , varName ) ; } TransformUtil . convertArrayInitializerToNewExpression ( newAssign ) ; assignments . add ( newAssign ) ; } } } }
This is the code which implements an important optimization.
This is the code which implements an important optimization .
// If this is a class, we have all of its assignments compiled in, but if it is a declaration we may need to include those // here. // TODO: should we eliminate double-initializations here?  We do reorder initializers anyway when we // set them on the field definition so it seems like we could reorder them here... or even sort them // based on dependencies? // this is a constructor property which will have already been initialized before the object is created so don't do this twice // Need to call this after we've copied the expression (and resolved references) since assign is possibly inherited. // For AssignmentExpressions' the lhs already has been redone so we only do the rhs. // Convert {"a", "b"} to new String[] {"a", "b"}