01: /*
02: * Copyright 1994-2003 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun in the LICENSE file that accompanied this code.
10: *
11: * This code is distributed in the hope that it will be useful, but WITHOUT
12: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14: * version 2 for more details (a copy is included in the LICENSE file that
15: * accompanied this code).
16: *
17: * You should have received a copy of the GNU General Public License version
18: * 2 along with this work; if not, write to the Free Software Foundation,
19: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20: *
21: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25:
26: package sun.tools.tree;
27:
28: import sun.tools.java.*;
29: import sun.tools.asm.Assembler;
30: import java.io.PrintStream;
31: import java.util.Hashtable;
32:
33: /**
34: * WARNING: The contents of this source file are not part of any
35: * supported API. Code that depends on them does so at its own risk:
36: * they are subject to change or removal without notice.
37: */
38: public class SuperExpression extends ThisExpression {
39:
40: /**
41: * Constructor
42: */
43: public SuperExpression(long where) {
44: super (SUPER, where);
45: }
46:
47: /**
48: * Constructor for "outer.super()"
49: */
50: public SuperExpression(long where, Expression outerArg) {
51: super (where, outerArg);
52: op = SUPER;
53: }
54:
55: public SuperExpression(long where, Context ctx) {
56: super (where, ctx);
57: op = SUPER;
58: }
59:
60: /**
61: * Check expression
62: */
63: public Vset checkValue(Environment env, Context ctx, Vset vset,
64: Hashtable exp) {
65: vset = checkCommon(env, ctx, vset, exp);
66: if (type != Type.tError) {
67: // "super" is not allowed in this context:
68: env.error(where, "undef.var.super", idSuper);
69: }
70: return vset;
71: }
72:
73: /**
74: * Check if the present name is part of a scoping prefix.
75: */
76: public Vset checkAmbigName(Environment env, Context ctx, Vset vset,
77: Hashtable exp, UnaryExpression loc) {
78: return checkCommon(env, ctx, vset, exp);
79: }
80:
81: /** Common code for checkValue and checkAmbigName */
82: private Vset checkCommon(Environment env, Context ctx, Vset vset,
83: Hashtable exp) {
84: ClassDeclaration super Class = ctx.field.getClassDefinition()
85: .getSuperClass();
86: if (super Class == null) {
87: env.error(where, "undef.var", idSuper);
88: type = Type.tError;
89: return vset;
90: }
91: vset = super.checkValue(env, ctx, vset, exp);
92: type = superClass.getType();
93: return vset;
94: }
95:
96: }
|