KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > compiler > base > cst > UnresolvedFieldAccessExpr


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.cst;
26
27 import java.util.*;
28 import org.aspectj.compiler.base.ast.*;
29
30 import org.aspectj.compiler.base.JavaCompiler;
31 import org.aspectj.compiler.base.CodeWriter;
32
33
34 /**
35   * @grammar expr.id
36   * @property String id
37   */

38
39 public class UnresolvedFieldAccessExpr extends FieldAccessExpr {
40     public UnresolvedFieldAccessExpr(SourceLocation source, Expr expr, String JavaDoc id) {
41         this(source,expr, null, false, id);
42     }
43
44     public Field resolveField() {
45         Type type = expr.getType();
46         if (type == null) {
47             expr.showError("bad type");
48             return null;
49         }
50         
51         return type.getField(id, this, true);
52     }
53     
54     //INTRO from ScopeWalker
55
public ASTObject postScope(ScopeWalker walker) {
56
57         if (expr != null && expr instanceof SuperExpr) {
58             setIsSuper(true);
59         }
60         
61         return new FieldAccessExpr(getSourceLocation(), getExpr(), resolveField(), getIsSuper());
62   
63     }
64     
65     //BEGIN: Generated from @child and @property
66
protected String JavaDoc id;
67     public String JavaDoc getId() { return id; }
68     public void setId(String JavaDoc _id) { id = _id; }
69     
70     public UnresolvedFieldAccessExpr(SourceLocation location, Expr _expr, Field _field, boolean _isSuper, String JavaDoc _id) {
71         super(location, _expr, _field, _isSuper);
72         setId(_id);
73     }
74     protected UnresolvedFieldAccessExpr(SourceLocation source) {
75         super(source);
76     }
77     
78     public ASTObject copyWalk(CopyWalker walker) {
79         UnresolvedFieldAccessExpr ret = new UnresolvedFieldAccessExpr(getSourceLocation());
80         ret.preCopy(walker, this);
81         if (expr != null) ret.setExpr( (Expr)walker.process(expr) );
82         ret.field = field;
83         ret.isSuper = isSuper;
84         ret.id = id;
85         return ret;
86     }
87     
88     
89     public String JavaDoc getDefaultDisplayName() {
90         return "UnresolvedFieldAccessExpr(field: "+field+", "+"isSuper: "+isSuper+", "+"id: "+id+")";
91     }
92     
93     //END: Generated from @child and @property
94
}
95
Popular Tags