KickJava   Java API By Example, From Geeks To Geeks.

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


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.JavaCompiler;
28 import org.aspectj.compiler.base.CodeWriter;
29
30 /**
31  * @grammar expr.new innerName(args)
32  * @property String innerName
33  */

34
35 // the only reason this class is not in CST is checkSpec... we have to know
36
// whether something was _originally_ a NewInnerInstanceExpr.
37
public class NewInnerInstanceExpr extends NewInstanceExpr {
38     //INTRO from ScopeWalker
39
public ASTObject postScope(ScopeWalker walker) {
40         super.postScope(walker);
41         return this;
42         //return new NewInstanceExpr(getSourceLocation(), getEnclosingInstanceExpr(), getTypeD(), getArgs(), getTypeDec(), getConstructor());
43
}
44
45     public void preScope(ScopeWalker walker) {
46         // XXX this is here because the type we construct may NOT be
47
// inner. If we were expr.new foo(args) { body }, then our
48
// _supertype_ is inner, but if we live in static context then
49
// we won't be inner. We check that by checking if, by this
50
// time, our enclosing instance expr is null.
51
if (getEnclosingInstanceExpr() == null) {
52             super.preScope(walker);
53             return;
54         }
55         //System.out.println("pre-scope: " + this);
56
setEnclosingInstanceExpr((Expr)walker.process(getEnclosingInstanceExpr()));
57         Type myType =
58             getEnclosingInstanceExpr().getType().getInnerType(getInnerName(),
59                                                               this, true);
60         setTypeD(myType.makeTypeD());
61         if (typeDec != null) {
62             ((ClassDec)typeDec).setSuperClass(myType.makeTypeD());
63         }
64     }
65
66     //BEGIN: Generated from @child and @property
67
protected String JavaDoc innerName;
68     public String JavaDoc getInnerName() { return innerName; }
69     public void setInnerName(String JavaDoc _innerName) { innerName = _innerName; }
70
71     public NewInnerInstanceExpr(SourceLocation location, Expr _enclosingInstanceExpr, TypeD _typeD, Exprs _args, TypeDec _typeDec, Constructor _constructor, String JavaDoc _innerName) {
72         super(location, _enclosingInstanceExpr, _typeD, _args, _typeDec, _constructor);
73         setInnerName(_innerName);
74     }
75     protected NewInnerInstanceExpr(SourceLocation source) {
76         super(source);
77     }
78
79     public ASTObject copyWalk(CopyWalker walker) {
80         NewInnerInstanceExpr ret = new NewInnerInstanceExpr(getSourceLocation());
81         ret.preCopy(walker, this);
82         if (enclosingInstanceExpr != null) ret.setEnclosingInstanceExpr( (Expr)walker.process(enclosingInstanceExpr) );
83         if (typeD != null) ret.setTypeD( (TypeD)walker.process(typeD) );
84         if (args != null) ret.setArgs( (Exprs)walker.process(args) );
85         if (typeDec != null) ret.setTypeDec( (TypeDec)walker.process(typeDec) );
86         ret.constructor = constructor;
87         ret.innerName = innerName;
88         return ret;
89     }
90
91
92     public String JavaDoc getDefaultDisplayName() {
93         return "NewInnerInstanceExpr(constructor: "+constructor+", "+"innerName: "+innerName+")";
94     }
95
96     //END: Generated from @child and @property
97
}
98
Popular Tags