system/src/sc/lang/sc/PropertyAssignment.java
public boolean transform(ILanguageModel.RuntimeType runtime) {
      if (runtime == ILanguageModel.RuntimeType.JAVA) {
         // Skip the list and go to the declaration
         BodyTypeDeclaration decl = (BodyTypeDeclaration) parentNode.getParentNode();

         // TODO: we should pass this down from the parent node to avoid the N*N
         int ix = decl.body.indexOf(this);

         // Property assignments without an initializer are used to just merge modifiers and stuff into
         // the definition.  Just remove the property assignment and move on.
         if (initializer == null) {
            super.transform(runtime);
            decl.body.remove(ix);
            if (decl.body.size() > ix)
               decl.body.get(ix).transform(runtime);
            return true;
         }

         if (!suppressGeneration) {
            BlockStatement st = null;

            boolean isStatic = isStatic();

            // Check if there's a block statement there for us so we can avoid creating a second one.
            if (parentNode instanceof SemanticNodeList) {
               SemanticNodeList parentList = (SemanticNodeList) parentNode;
               int parentIx = parentList.indexOf(this);
               if (parentIx > 0) {
                  Object prev = parentList.get(parentIx-1);
                  if (prev instanceof BlockStatement) {
                     st = (BlockStatement) prev;
                     // Can't reuse a static block statement unless this property assignment is itself to a static variable.
                     // We put static assignments in a static section so they run even if there's no instance created.
                     if (!st.visible || (st.staticEnabled != isStatic))
                        st = null;
                  }
               }
            }

            boolean stCreated = false;
            if (st == null) {
               st = new BlockStatement();
               st.fromDefinition = this;
               st.visible = true;
               st.setProperty("statements", new SemanticNodeList<Statement>(st, 1));
               if (isStatic)
                  st.setProperty("staticEnabled", true);
               stCreated = true;
            }

            // For OverrideAssignment, when we attach a BuildInit we may not have an operator but will have an initializer
            if (operator == null)
               operator = "=";

            Statement ae = convertToAssignmentExpression(null, false, operator, true);

            st.statements.add(ae);

            decl.body.remove(ix);  // Remove this guy
            if (stCreated) {
               decl.addBodyStatementAtIndent(ix, st); // Insert the new assignment expression in a block statement

               // In case transformations are required in the new statement
               st.transform(runtime);
            }
            else {
               ae.transform(runtime);
               // Because we removed a node at this spot and did not add one back, we need to transform the guy at this spot or it is skipped in the parent list
               if (decl.body.size() > ix)
                  decl.body.get(ix).transform(runtime);
            }

         }
         else {// already processed this through collectReferenceInitializers so just remove this guy and transform the node that goes into its place
            decl.body.remove(ix);
            if (decl.body.size() > ix)
               decl.body.get(ix).transform(runtime);
         }

         decl.addToHiddenBody(this, false);

         return true;
      }
      throw new UnsupportedOperationException();
   }
/** The PropertyAssignment defined for .sc is not in Java - we do a conversion here to replace x = y by { x = y } */
The PropertyAssignment defined for .sc is not in Java - we do a conversion here to replace x = y by { x = y }
The PropertyAssignment defined for . sc is not in Java - we do a conversion here to replace x = y by { x = y }
public boolean transform(ILanguageModel.RuntimeType runtime) {
      if (runtime == ILanguageModel.RuntimeType.JAVA) {
         BodyTypeDeclaration decl = (BodyTypeDeclaration) parentNode.getParentNode();
         int ix = decl.body.indexOf(this);
         if (initializer == null) {
            super.transform(runtime);
            decl.body.remove(ix);
            if (decl.body.size() > ix)
               decl.body.get(ix).transform(runtime);
            return true;
         }
         if (!suppressGeneration) {
            BlockStatement st = null;
            boolean isStatic = isStatic();
            if (parentNode instanceof SemanticNodeList) {
               SemanticNodeList parentList = (SemanticNodeList) parentNode;
               int parentIx = parentList.indexOf(this);
               if (parentIx > 0) {
                  Object prev = parentList.get(parentIx-1);
                  if (prev instanceof BlockStatement) {
                     st = (BlockStatement) prev;
                     if (!st.visible || (st.staticEnabled != isStatic))
                        st = null;
                  }
               }
            }
            boolean stCreated = false;
            if (st == null) {
               st = new BlockStatement();
               st.fromDefinition = this;
               st.visible = true;
               st.setProperty("statements", new SemanticNodeList<Statement>(st, 1));
               if (isStatic)
                  st.setProperty("staticEnabled", true);
               stCreated = true;
            }
            if (operator == null)
               operator = "=";
            Statement ae = convertToAssignmentExpression(null, false, operator, true);
            st.statements.add(ae);
            decl.body.remove(ix);  
            if (stCreated) {
               decl.addBodyStatementAtIndent(ix, st); 
               st.transform(runtime);
            }
            else {
               ae.transform(runtime);
               if (decl.body.size() > ix)
                  decl.body.get(ix).transform(runtime);
            }
         }
         else {
            decl.body.remove(ix);
            if (decl.body.size() > ix)
               decl.body.get(ix).transform(runtime);
         }
         decl.addToHiddenBody(this, false);
         return true;
      }
      throw new UnsupportedOperationException();
   }
public boolean transform ( ILanguageModel . RuntimeType runtime ) { if ( runtime == ILanguageModel . RuntimeType . JAVA ) { BodyTypeDeclaration decl = ( BodyTypeDeclaration ) parentNode . getParentNode ( ) ; int ix = decl . body . indexOf ( this ) ; if ( initializer == null ) { super . transform ( runtime ) ; decl . body . remove ( ix ) ; if ( decl . body . size ( ) > ix ) decl . body . get ( ix ) . transform ( runtime ) ; return true ; } if ( ! suppressGeneration ) { BlockStatement st = null ; boolean isStatic = isStatic ( ) ; if ( parentNode instanceof SemanticNodeList ) { SemanticNodeList parentList = ( SemanticNodeList ) parentNode ; int parentIx = parentList . indexOf ( this ) ; if ( parentIx > 0 ) { Object prev = parentList . get ( parentIx - 1 ) ; if ( prev instanceof BlockStatement ) { st = ( BlockStatement ) prev ; if ( ! st . visible || ( st . staticEnabled != isStatic ) ) st = null ; } } } boolean stCreated = false ; if ( st == null ) { st = new BlockStatement ( ) ; st . fromDefinition = this ; st . visible = true ; st . setProperty ( "statements" , new SemanticNodeList < Statement > ( st , 1 ) ) ; if ( isStatic ) st . setProperty ( "staticEnabled" , true ) ; stCreated = true ; } if ( operator == null ) operator = "=" ; Statement ae = convertToAssignmentExpression ( null , false , operator , true ) ; st . statements . add ( ae ) ; decl . body . remove ( ix ) ; if ( stCreated ) { decl . addBodyStatementAtIndent ( ix , st ) ; st . transform ( runtime ) ; } else { ae . transform ( runtime ) ; if ( decl . body . size ( ) > ix ) decl . body . get ( ix ) . transform ( runtime ) ; } } else { decl . body . remove ( ix ) ; if ( decl . body . size ( ) > ix ) decl . body . get ( ix ) . transform ( runtime ) ; } decl . addToHiddenBody ( this , false ) ; return true ; } throw new UnsupportedOperationException ( ) ; }
The PropertyAssignment defined for .sc is not in Java - we do a conversion here to replace x = y by { x = y }
The PropertyAssignment defined for . sc is not in Java - we do a conversion here to replace x = y by { x = y }
// Skip the list and go to the declaration // TODO: we should pass this down from the parent node to avoid the N*N // Property assignments without an initializer are used to just merge modifiers and stuff into // the definition.  Just remove the property assignment and move on. // Check if there's a block statement there for us so we can avoid creating a second one. // Can't reuse a static block statement unless this property assignment is itself to a static variable. // We put static assignments in a static section so they run even if there's no instance created. // For OverrideAssignment, when we attach a BuildInit we may not have an operator but will have an initializer // Remove this guy // Insert the new assignment expression in a block statement // In case transformations are required in the new statement // Because we removed a node at this spot and did not add one back, we need to transform the guy at this spot or it is skipped in the parent list // already processed this through collectReferenceInitializers so just remove this guy and transform the node that goes into its place