Show
Ignore:
Timestamp:
01/05/09 12:04:20 (11 months ago)
Author:
dr2chase
Message:

Feeding generated APIs to static analysis, not yet working

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/ProjectFortress/src/com/sun/fortress/repository/ForeignJava.java

    r3288 r3289  
    6464public class ForeignJava { 
    6565 
    66     /** given an API Name, what Java classes does it import?  (Name of existing 
    67      * Java class, not its wrapper.) 
     66    /** given an API Name, what Java classes does it import?  (Existing 
     67     * Java class, not its compiled Fortress wrapper class.) 
    6868     */ 
    6969    MultiMap<APIName, Class> javaImplementedAPIs = new MultiMap<APIName, Class>(); 
     
    263263        generatedImports.putItem(importing_package, api_name); 
    264264         
     265        /* 
     266         * Ensure that the API and class appear. 
     267         */ 
     268        javaImplementedAPIs.putItem(api_name,imported_class); 
     269         
    265270        Id name = NodeFactory.makeId(span, imported_class.getSimpleName()); 
    266271         
     
    396401            Set<APIName> gi = generatedImports.get(name); 
    397402            if (gi != null) 
    398             for (APIName a : gi) { 
    399                 AliasedAPIName aan = NodeFactory.makeAliasedAPIName(a); 
    400                 /* 
    401                  * Hoping to lie, slightly, to static analysis. This is 
    402                  * technically speaking a "foreign" import, but the import is 
    403                  * already known to the ForeignJava data structures, and this 
    404                  * allows use of fully qualified (hence unambiguous) references 
    405                  * to classes from other packages in the generated API. 
    406                  *  
    407                  * So, one lie -- no foreign annotation. 
    408                  */ 
    409                 ImportApi iapi = NodeFactory.makeImportApi(span, Option 
    410                         .<String> none(), Useful.list(aan)); 
    411                 imports.add(iapi); 
    412             } 
    413  
     403                for (APIName a : gi) { 
     404                    importAnApi(imports, a); 
     405                } 
     406            // Implicitly import. 
     407            importAnApi(imports, NodeFactory.makeAPIName(span, "FortressLibrary")); 
     408             
    414409            List<Decl> decls = new ArrayList<Decl>(); 
    415410            for (Decl d : apiToStaticDecls.get(name)) { 
     
    422417        } 
    423418        return result; 
    424          
     419 
     420    } 
     421 
     422    private void importAnApi(List<Import> imports, APIName a) { 
     423        AliasedAPIName aan = NodeFactory.makeAliasedAPIName(a); 
     424        /* 
     425         * Hoping to lie, slightly, to static analysis. This is 
     426         * technically speaking a "foreign" import, but the import 
     427         * is already known to the ForeignJava data structures, and 
     428         * this allows use of fully qualified (hence unambiguous) 
     429         * references to classes from other packages in the 
     430         * generated API. 
     431         *  
     432         * So, one lie -- no foreign annotation. 
     433         */ 
     434        ImportApi iapi = NodeFactory.makeImportApi(span, Option 
     435                .<String> none(), Useful.list(aan)); 
     436        imports.add(iapi); 
    425437    } 
    426438