| 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 | |
|---|
| 18 | package com.sun.fortress.scala_src.linker |
|---|
| 19 | |
|---|
| 20 | import com.sun.fortress.compiler.index.ApiIndex |
|---|
| 21 | import com.sun.fortress.compiler.GlobalEnvironment |
|---|
| 22 | import com.sun.fortress.compiler.index.ApiIndex |
|---|
| 23 | import com.sun.fortress.compiler.IndexBuilder |
|---|
| 24 | import com.sun.fortress.nodes._ |
|---|
| 25 | import com.sun.fortress.repository.FortressRepository |
|---|
| 26 | import com.sun.fortress.scala_src.nodes._ |
|---|
| 27 | import com.sun.fortress.scala_src.useful.Lists._ |
|---|
| 28 | import _root_.java.util.{List => JList} |
|---|
| 29 | import _root_.java.util.Map |
|---|
| 30 | import _root_.java.util.ArrayList |
|---|
| 31 | |
|---|
| 32 | class 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 | |
|---|