KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > compiler > base > TypeValidator


1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * This file is part of the compiler and core tools for the AspectJ(tm)
4  * programming language; see http://aspectj.org
5  *
6  * The contents of this file are subject to the Mozilla Public License
7  * Version 1.1 (the "License"); you may not use this file except in
8  * compliance with the License. You may obtain a copy of the License at
9  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is AspectJ.
17  *
18  * The Initial Developer of the Original Code is Xerox Corporation. Portions
19  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
20  * All Rights Reserved.
21  *
22  * Contributor(s):
23  */

24
25 package org.aspectj.compiler.base;
26
27 import org.aspectj.compiler.base.ast.*;
28 import org.aspectj.compiler.base.*;
29
30
31 import java.util.*;
32
33 public class TypeValidator extends AbstractCompilerPass implements WorldPass {
34     public TypeValidator(JavaCompiler compiler) {
35         super(compiler);
36     }
37
38     public void transformWorld() {
39 // // first put all source types in the TypeManager
40
// for (Iterator i = getWorld().sourceTypesIterator(); i.hasNext(); ) {
41
// Type type = (Type)i.next();
42
// getTypeManager().addType(type);
43
// }
44
//
45

46         // first build up the inner type maps
47
//XXX TBD
48

49         
50         
51         
52         // then bind implements/extends and build the type graph
53
for (Iterator i = getWorld().sourceTypesIterator(); i.hasNext(); ) {
54             Type type = (Type)i.next();
55             type.buildTypeGraph();
56         }
57     
58         // now check for circularites
59
getTypeManager().getObjectType().validateTypeGraph();
60         
61         // now do type level introductions
62
for (Iterator i = getWorld().sourceTypesIterator(); i.hasNext(); ) {
63             Type type = (Type)i.next();
64             type.finishTypeIntroductions();
65         }
66     
67         
68         
69     }
70         
71 // Enumeration cuEnum = getWorld().enumerateCompilationUnits();
72
// while (cuEnum.hasMoreElements()) {
73
// CompilationUnit cu = (CompilationUnit)cuEnum.nextElement();
74
// Decs decs = cu.getDecs();
75
// for (int j=0; j < decs.size(); j++) {
76
// Dec dec = (Dec)decs.get(j);
77
// if (dec instanceof TypeDec) {
78
// TypeDec typeDec = (TypeDec)dec;
79
// if (typeDec.isInnerType()) continue;
80
// getCompiler().enterNode(dec);
81
// //System.out.println("type "+typeDec+": building type graph");
82
// typeDec.buildTypeGraph();
83
// //if (!((TypeDec)dec).validate(new LinkedList())) break;
84
// getCompiler().exitNode(dec);
85
// }
86
// }
87
// }
88

89
90         
91         
92 // // now check for circularities
93
// cuEnum = getWorld().enumerateCompilationUnits();
94
// while (cuEnum.hasMoreElements()) {
95
// CompilationUnit cu = (CompilationUnit)cuEnum.nextElement();
96
// Decs decs = cu.getDecs();
97
// for (int j=0; j < decs.size(); j++) {
98
// Dec dec = (Dec)decs.get(j);
99
// if (dec instanceof TypeDec) {
100
// TypeDec typeDec = (TypeDec)dec;
101
// if (typeDec.isInnerType()) continue;
102
// getCompiler().enterNode(dec);
103
// //System.out.println("type "+typeDec+": building type graph");
104
// typeDec.validate();
105
// //if (!((TypeDec)dec).validate(new LinkedList())) break;
106
// getCompiler().exitNode(dec);
107
// }
108
// }
109
// }
110

111     public String JavaDoc getDisplayName() {
112         return "building type graph";
113     }
114
115 }
116
Popular Tags