KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > expr > AccessExp


1 // Copyright (c) 2005 Per M.A. Bothner.
2
// This is free software; for terms and warranty disclaimer see ./COPYING.
3

4 package gnu.expr;
5 import gnu.mapping.*;
6
7 /** A common super-type for ReferenceExpa and SetExp.
8  * Contains shared information about the variable that is accessed. */

9
10 public abstract class AccessExp extends Expression
11 {
12   /** The name of the variable to set - either a String or a Symbol. */
13   Object JavaDoc symbol;
14   /** If non-null, the local Declaration this refers to. */
15   Declaration binding;
16   public String JavaDoc string_name () { return symbol.toString(); }
17
18   public final String JavaDoc getName()
19   {
20     return symbol instanceof Symbol ? ((Symbol) symbol).getName()
21       : symbol.toString();
22   }
23
24   /** Return a simple name, or null if the name has a non-empty namespace. */
25   public final String JavaDoc getSimpleName()
26   {
27     if (symbol instanceof String JavaDoc)
28       return (String JavaDoc) symbol;
29     Symbol sym;
30     if (symbol instanceof Symbol
31         && (sym = (Symbol) symbol).hasEmptyNamespace())
32       return sym.getLocalName();
33     return null;
34   }
35
36   public final Object JavaDoc getSymbol() { return symbol; }
37   /** If non-null, the local Declaration this refers to. */
38   public final Declaration getBinding() { return binding; }
39
40   public final void setBinding(Declaration decl) { binding = decl; }
41
42   /** If binding has a non-static field and no base, use this instead of base.
43    * This is mainly used for aliases of imported module declarations. */

44   private Declaration context;
45   public final Declaration contextDecl ()
46   { return context; }
47   public final void setContextDecl(Declaration decl)
48   { context = decl; }
49 }
50
Popular Tags