KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > compiler > crosscuts > ast > ArgsPcd


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.crosscuts.ast;
26 import org.aspectj.compiler.base.ast.*;
27 import org.aspectj.compiler.crosscuts.joinpoints.*;
28
29 import org.aspectj.compiler.base.JavaCompiler;
30
31 import java.util.*;
32 import org.aspectj.util.FuzzyBoolean;
33
34 /**
35   * @grammar args(typeNamePattern, ...)
36   * @child FormalsPattern argTypeNames
37   */

38 public class ArgsPcd extends Pcd {
39     public String JavaDoc toShortString() {
40         return "args(" + getArgTypeNames().toShortString() + ")";
41     }
42
43     public boolean allowsNameBinding() { return true; }
44     public void checkStatic() { showNonStaticError(); }
45     
46     public JpPlanner makePlanner(PlanData planData) {
47         return new JpPlanner() {
48             public FuzzyBoolean fastMatch(JoinPoint jp) {
49                 //XXX optimize this: getArgTypeNames().matchesInstances(jp.getArgTypes());
50
return FuzzyBoolean.MAYBE;
51             }
52             public JpPlan makePlan(JoinPoint jp) {
53                 Exprs argsExprs = jp.makeArgsExprs();
54                 if (argsExprs == null) return JpPlan.NO_PLAN;
55                 return getArgTypeNames().makePlan(argsExprs, jp);
56             }
57         };
58     }
59     
60     //BEGIN: Generated from @child and @property
61
protected FormalsPattern argTypeNames;
62     public FormalsPattern getArgTypeNames() { return argTypeNames; }
63     public void setArgTypeNames(FormalsPattern _argTypeNames) {
64         if (_argTypeNames != null) _argTypeNames.setParent(this);
65         argTypeNames = _argTypeNames;
66     }
67     
68     public ArgsPcd(SourceLocation location, FormalsPattern _argTypeNames) {
69         super(location);
70         setArgTypeNames(_argTypeNames);
71     }
72     protected ArgsPcd(SourceLocation source) {
73         super(source);
74     }
75     
76     public ASTObject copyWalk(CopyWalker walker) {
77         ArgsPcd ret = new ArgsPcd(getSourceLocation());
78         ret.preCopy(walker, this);
79         if (argTypeNames != null) ret.setArgTypeNames( (FormalsPattern)walker.process(argTypeNames) );
80         return ret;
81     }
82     
83     public ASTObject getChildAt(int childIndex) {
84         switch(childIndex) {
85         case 0: return argTypeNames;
86         default: return super.getChildAt(childIndex);
87         }
88     }
89      public String JavaDoc getChildNameAt(int childIndex) {
90         switch(childIndex) {
91         case 0: return "argTypeNames";
92         default: return super.getChildNameAt(childIndex);
93         }
94     }
95      public void setChildAt(int childIndex, ASTObject child) {
96         switch(childIndex) {
97         case 0: setArgTypeNames((FormalsPattern)child); return;
98         default: super.setChildAt(childIndex, child); return;
99         }
100     }
101      public int getChildCount() {
102         return 1;
103     }
104     
105     public String JavaDoc getDefaultDisplayName() {
106         return "ArgsPcd()";
107     }
108     
109     //END: Generated from @child and @property
110
}
111
112
Popular Tags