root/trunk/ProjectFortress/src/com/sun/fortress/scala_src/linker/ApiLinker.scala @ 3876

Revision 3876, 2.2 KB (checked in by EricAllen, 5 months ago)

Added API linker and associated hooks (work in progress).
Added some testing of cache cleaning.

Line 
1/*******************************************************************************
2    Copyright 2009 Sun Microsystems, Inc.,
3    4150 Network Circle, Santa Clara, California 95054, U.S.A.
4    All rights reserved.
5
6    U.S. Government Rights - Commercial software.
7    Government users are subject to the Sun Microsystems, Inc. standard
8    license agreement and applicable provisions of the FAR and its supplements.
9
10    Use is subject to license terms.
11
12    This distribution may include materials developed by third parties.
13
14    Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
15    trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
16 ******************************************************************************/
17
18package com.sun.fortress.scala_src.linker
19
20import com.sun.fortress.compiler.index.ApiIndex
21import com.sun.fortress.compiler.GlobalEnvironment
22import com.sun.fortress.compiler.index.ApiIndex
23import com.sun.fortress.compiler.IndexBuilder
24import com.sun.fortress.nodes._
25import com.sun.fortress.repository.FortressRepository
26import com.sun.fortress.scala_src.nodes._
27import com.sun.fortress.scala_src.useful.Lists._
28import _root_.java.util.{List => JList}
29import _root_.java.util.Map
30import _root_.java.util.ArrayList
31
32class ApiLinker(env: GlobalEnvironment, repository: FortressRepository) {
33  def link(api: ApiIndex): ApiIndex = {
34    api.ast match {
35      case SApi(info, name, imports, decls, comprises) => {
36        if (comprises.isEmpty) {
37          api
38        }
39        else {
40          val allDecls = new ArrayList[Decl]()
41          for (constituent <- comprises) {
42            constituent match {
43              case SApi(cinfo, cname, cimports, cdecls, _) => {
44                // The comprises clause should be empty because repositories
45                // only store simple APIs
46                  allDecls.addAll(toJavaList(cdecls))
47                }
48              }
49            }
50            IndexBuilder.builder.buildApiIndex(new Api(info, name, toJavaList(imports),
51                                                       allDecls, new ArrayList[APIName]()),
52                                               api.modifiedDate)
53        }
54      }
55    }
56  }
57}
58
Note: See TracBrowser for help on using the browser.