KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > compiler > crosscuts > joinpoints > FieldGetJp


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.fix
21  *
22  * Contributor(s):
23  */

24 package org.aspectj.compiler.crosscuts.joinpoints;
25
26 import org.aspectj.compiler.base.ast.*;
27 import org.aspectj.compiler.crosscuts.ast.*;
28
29 import org.aspectj.compiler.base.JavaCompiler;
30 import org.aspectj.util.JavaStrings;
31
32 import java.util.*;
33
34
35 public class FieldGetJp extends ExprJp {
36     public static interface FieldGetExprPromise {
37         /** makes this concrete */
38         public FieldAccessExpr getFieldAccessExpr();
39         
40         public FieldDec getFieldDec();
41         public Expr getSourceExpr();
42         public Type getTargetType();
43         public ASTObject getSourceLocation();
44     }
45     
46     FieldGetExprPromise fieldGetExprPromise;
47
48     public FieldGetJp(FieldGetExprPromise fieldGetExprPromise,
49                                 JoinPoint enclosingJoinPoint)
50     {
51         super(fieldGetExprPromise.getSourceExpr(), enclosingJoinPoint);
52         this.fieldGetExprPromise = fieldGetExprPromise;
53     }
54
55     public static final Kind KIND = new Kind("field-get", FIELD_GET);
56
57     public Kind getKind() { return KIND; }
58
59     public ASTObject getSourceLocation() {
60         return fieldGetExprPromise.getSourceLocation();
61     }
62     
63     public List makeArgsTypes() { return Collections.EMPTY_LIST; }
64
65     public Exprs makeArgsExprs() {
66         return getAST().makeExprs();
67     }
68     
69     public Type getTargetType() {
70         return fieldGetExprPromise.getTargetType();
71     }
72
73     public Type getTargetExprType() {
74         if (fieldGetExprPromise.getFieldDec().isStatic()) return null;
75         return getTargetType();
76     }
77
78     public Dec getTargetDec() { return getCalledFieldDec(); }
79
80     public FieldDec getCalledFieldDec() {
81         return fieldGetExprPromise.getFieldDec();
82     }
83
84     public boolean canThrow(Type t) { return t.isUncheckedThrowable(); }
85     public Collection getPossibleCheckedExceptions() {
86         return Collections.EMPTY_LIST;
87     }
88         
89     public Type getResultType() {
90         return getCalledFieldDec().getType();
91     }
92
93     protected ASTObject makeInnerCall(Expr targetExpr, Exprs argsExprs) {
94         return getAST().makeGet(targetExpr, getCalledFieldDec());
95     }
96     
97     protected AnonymousMethodExpr makeSyntheticCall() {
98         final AST ast = getAST();
99         FieldAccessExpr getExpr = fieldGetExprPromise.getFieldAccessExpr();
100         return makeAnonMethodExpr(ast.makeFormals(), getExpr.getExpr(),
101                                   ast.makeExprs());
102     }
103
104     protected void replaceExprWith(Expr newExpr) {
105         fieldGetExprPromise.getFieldAccessExpr().replaceWith(newExpr);
106     }
107 }
108
Popular Tags