Show
Ignore:
Timestamp:
07/28/08 20:20:58 (16 months ago)
Author:
sukyoungryu
Message:

[tool] Fixed arrays and also do.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/ProjectFortress/src/com/sun/fortress/tools/FortressAstToConcrete.java

    r2402 r2405  
    3434     */ 
    3535 
     36    /* indentation utilities *************************************************/ 
    3637    private int indent = 0; 
    3738 
     
    5960 
    6061    /* utility methods ********************************************************/ 
     62    /* returns number copies of s */ 
     63    private String makeCopies(int number, String s) { 
     64        String result = s; 
     65        for (int index = 1; index < number; index++) { 
     66            result += s; 
     67        } 
     68        return result; 
     69    } 
     70 
    6171    /* returns a string beginning with 'kind' followed by a sequence of elements 
    6272       in 'list' separated by commas and  enclosed by '{' and '}' 
     
    362372                                              List<String> decls_result) { 
    363373        StringBuilder s = new StringBuilder(); 
    364          
     374 
    365375        increaseIndent(); 
    366376 
     
    386396        s.append( indent(join(decls_result,"\n")) ); 
    387397        s.append( "\nend" ).append( "\n" ); 
    388          
     398 
    389399        decreaseIndent(); 
    390400 
     
    655665                                      List<String> fronts_result) { 
    656666        StringBuilder s = new StringBuilder(); 
    657         s.append( indent(join(fronts_result, "\n")) ); 
     667        s.append( indent(join(fronts_result, " also\n")) ); 
    658668        s.append( "\nend" ); 
    659669        return s.toString(); 
     
    10301040        StringBuilder s = new StringBuilder(); 
    10311041 
    1032         // s.append( op_result ); 
    10331042        s.append( join(args_result, " " + op_result + " ") ); 
    10341043 
     
    10941103//    @Override public String forMathPrimaryOnly( that, 
    10951104 
    1096     @Override public String forArrayElementOnly(ArrayElement that, List<String> staticArgs_result, String element_result) { 
    1097         StringBuilder s = new StringBuilder(); 
    1098  
    1099         s.append( element_result ); 
    1100         s.append( inOxfordBrackets(staticArgs_result)); 
    1101  
    1102         return s.toString(); 
    1103     } 
    1104  
    1105     @Override public String forArrayElementsOnly(ArrayElements that, List<String> staticArgs_result, List<String> elements_result) { 
    1106         StringBuilder s = new StringBuilder(); 
    1107  
    1108         s.append( "[ " ); 
    1109         s.append( join(elements_result, ", ") ); 
    1110         s.append( inOxfordBrackets( staticArgs_result ) ); 
    1111         s.append( " ]" ); 
     1105    @Override public String forArrayElementOnly(ArrayElement that, 
     1106                                                List<String> staticArgs_result, 
     1107                                                String element_result) { 
     1108        return element_result; 
     1109    } 
     1110 
     1111    @Override public String forArrayElementsOnly(ArrayElements that, 
     1112                                                 List<String> staticArgs_result, 
     1113                                                 List<String> elements_result) { 
     1114        StringBuilder s = new StringBuilder(); 
     1115 
     1116        if ( that.isOutermost() ) { 
     1117            s.append( "[" ); 
     1118            s.append( inOxfordBrackets( staticArgs_result ) ); 
     1119            s.append( " " ); 
     1120        } 
     1121        String separator; 
     1122        if ( that.getDimension() == 1 ) 
     1123            separator = " "; 
     1124        else 
     1125            separator = makeCopies(that.getDimension()-1, ";"); 
     1126        s.append( join(elements_result, separator) ); 
     1127        if ( that.isOutermost() ) 
     1128            s.append( " ]" ); 
    11121129 
    11131130        return s.toString(); 
     
    11311148//    @Override public String for_RewriteGenericSingletonTypeOnly( that, 
    11321149 
    1133     @Override public String forArrayTypeOnly(ArrayType that, String type_result, String indices_result) { 
     1150    @Override public String forArrayTypeOnly(ArrayType that, 
     1151                                             String type_result, 
     1152                                             String indices_result) { 
    11341153        StringBuilder s = new StringBuilder(); 
    11351154 
     
    17111730    @Override public String forAnonymousFnNameOnly(AnonymousFnName that, 
    17121731                                                   Option<String> api_result) { 
    1713         StringBuilder s = new StringBuilder(); 
    1714  
    1715         return s.toString(); 
    1716         /* 
    1717         return bug(that, "Anonymous function names are not supported " + 
    1718                    "in Fortress concrete syntax."); 
    1719                    */ 
     1732        return ""; 
    17201733    } 
    17211734 
     
    18121825    } 
    18131826 
    1814     @Override public String forExtentRangeOnly(ExtentRange that, Option<String> base_result, Option<String> size_result) { 
    1815             StringBuilder s = new StringBuilder(); 
    1816  
    1817             if ( base_result.isSome() ){ 
    1818                     s.append( base_result.unwrap() ); 
    1819             } 
    1820             if ( size_result.isSome() ){ 
    1821                     s.append( size_result.unwrap() ); 
    1822             } 
    1823  
    1824             return s.toString(); 
     1827    /* Possible differences in the original Fortress program and 
     1828       the unparsed program. 
     1829       In the Fortress source program, either "#" or ":" may be used. 
     1830       In AST, only "#" is used. 
     1831       In the Fortress source program, either "#size" or "size" may be used. 
     1832       In AST, only "#size" is used. 
     1833     */ 
     1834    @Override public String forExtentRangeOnly(ExtentRange that, 
     1835                                               Option<String> base_result, 
     1836                                               Option<String> size_result) { 
     1837        StringBuilder s = new StringBuilder(); 
     1838 
     1839        if ( base_result.isSome() ){ 
     1840            s.append( base_result.unwrap() ); 
     1841        } 
     1842        s.append( "#" ); 
     1843        if ( size_result.isSome() ){ 
     1844            s.append( size_result.unwrap() ); 
     1845        } 
     1846 
     1847        return s.toString(); 
    18251848    } 
    18261849 
     
    18561879//    @Override public String forTraitTypeWhereOnly( that, 
    18571880 
    1858     @Override public String forIndicesOnly(Indices that, List<String> extents_result) { 
     1881    @Override public String forIndicesOnly(Indices that, 
     1882                                           List<String> extents_result) { 
    18591883        StringBuilder s = new StringBuilder(); 
    18601884