KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > compiler > base > ast > SemanticObject


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.ast;
26
27 import org.aspectj.compiler.base.*;
28
29 /**
30   * Represents the platonic ideals of the declarations in the ast.
31   *
32   * One important purpose for these objects is to retain their identity across
33   * incremental recompilation.
34   *
35   * This implementation treats these objects as proxies for Decs. That isn't essential
36   * to their nature but rather a convenient way to get started.
37   */

38 public abstract class SemanticObject extends CompilerObject {
39     protected Dec dec;
40
41     public SemanticObject(JavaCompiler compiler) {
42         super(compiler);
43     }
44
45     public SemanticObject(Dec dec) {
46         super(dec.getCompiler());
47         this.dec = dec;
48     }
49     public String JavaDoc getName() { return dec.getName(); }
50     public String JavaDoc getId() { return dec.getId(); }
51     public String JavaDoc getBytecodeId() { return dec.getBytecodeId(); }
52
53     public Type getDeclaringType() { return dec.getDeclaringType(); }
54
55     //public Type getResultType() { return dec.getResultType(); }
56

57     public Dec getCorrespondingDec() { return dec; }
58
59     public String JavaDoc getKind() { return dec.getKind(); }
60
61     public String JavaDoc toShortString() { return dec.toShortString(); }
62
63     //*********************************
64
public String JavaDoc getDescriptor() { return dec.getDescriptor(); }
65     public int getStackDelta() { return dec.getStackDelta(); }
66
67     public Modifiers getModifiers() { return dec.getModifiers(); }
68
69     public boolean isAbstract() { return dec.isAbstract(); }
70     public boolean isStatic() { return dec.isStatic(); }
71
72     public boolean isInherited(Type inType) { return dec.isInherited(inType); }
73     public boolean conflictsWith(SemanticObject other) {
74         return dec.conflictsWith(other.dec);
75     }
76     public boolean checkOverride(Type inType, SemanticObject other) {
77         return dec.checkOverride(inType, other.dec);
78     }
79     public boolean dominates(SemanticObject other) {
80         return dec.dominates(other.dec);
81     }
82
83     public boolean isMoreSpecificThan(SemanticObject other) {
84         return dec.isMoreSpecificThan(other.dec);
85     }
86     public boolean isApplicable(Exprs params) { return dec.isApplicable(params); }
87     public boolean isAlmostApplicable(Exprs params) { return dec.isAlmostApplicable(params); }
88
89     public boolean isAccessible(ASTObject fromWhere) { return isAccessible(fromWhere, false); }
90     public boolean isAccessible(ASTObject fromWhere, boolean inBytecode) {
91         if (dec == null) {
92             System.out.println("no dec: " + this);
93             return false;
94         }
95         return dec.isAccessible(fromWhere, inBytecode);
96     }
97
98     public void showConflictError(SemanticObject other, String JavaDoc message) {
99         getCorrespondingDec().showError(toShortString() + " conflicts with " +
100                 other.toShortString() + ": " + message);
101     }
102
103     public Expr updateTargetExpr(Expr expr) {
104         if (isStatic() && InterfaceDec.isHelperClass(getDeclaringType().getTypeDec())) {
105             return expr.getAST().makeTypeExpr(getDeclaringType());
106         }
107         return expr;
108     }
109 }
110
Popular Tags