Changeset 3289

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

Feeding generated APIs to static analysis, not yet working

Location:
trunk/ProjectFortress
Files:
1 added
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/TypeDisambiguator.java

    r3246 r3289  
    11/******************************************************************************* 
    2     Copyright 2008 Sun Microsystems, Inc., 
     2    Copyright 2009 Sun Microsystems, Inc., 
    33    4150 Network Circle, Santa Clara, California 95054, U.S.A. 
    44    All rights reserved. 
     
    303303            Option<APIName> realApiOpt = _env.apiName(originalApi); 
    304304            if (realApiOpt.isNone()) { 
     305                // retry for debugging purposes 
     306                realApiOpt = _env.apiName(originalApi); 
    305307                error("Undefined API: " + NodeUtil.nameString(originalApi), originalApi); 
    306308                return that; 
  • 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     
  • trunk/ProjectFortress/src/com/sun/fortress/repository/GraphRepository.java

    r3288 r3289  
    460460                @Override 
    461461                public Boolean apply(GraphNode g){ 
    462                     return g instanceof ApiGraphNode && staleOrDependsOnStale.get(g); 
     462                    return g instanceof ApiGraphNode && (staleOrDependsOnStale.get(g) || 
     463                            // TODO need to fix the whole date-stamp thing for APIs. 
     464                            foreignJava.definesApi(((ApiGraphNode)g).getName()) 
     465                            ); 
    463466                } 
    464467            }; 
     
    628631        try{ 
    629632            APIName api_name = node.getName(); 
    630             File fdot = findFile(api_name, ProjectProperties.API_SOURCE_SUFFIX); 
    631             CompilationUnit api = Parser.parseFileConvertExn(fdot); 
    632             if (api instanceof Api) { 
    633                 return (Api) api; 
     633            if (foreignJava.definesApi(api_name)) { 
     634                return (Api) foreignJava.fakeApi(api_name).ast(); 
    634635            } else { 
    635                 throw StaticError.make("Unexpected parse of API " + api_name, ""); 
     636                File fdot = findFile(api_name, ProjectProperties.API_SOURCE_SUFFIX); 
     637                CompilationUnit api = Parser.parseFileConvertExn(fdot); 
     638                if (api instanceof Api) { 
     639                    return (Api) api; 
     640                } else { 
     641                    throw StaticError.make("Unexpected parse of API " + api_name, ""); 
     642                } 
    636643            } 
    637644        } catch ( FileNotFoundException e ){