01: /*
02: * $Id: ClassRef.java,v 1.11 2002/09/16 08:05:03 jkl Exp $
03: *
04: * Copyright (c) 2002 Njet Communications Ltd. All Rights Reserved.
05: *
06: * Use is subject to license terms, as defined in
07: * Anvil Sofware License, Version 1.1. See LICENSE
08: * file, or http://njet.org/license-1.1.txt
09: */
10: package anvil.script;
11:
12: import anvil.Location;
13: import anvil.ErrorListener;
14:
15: /**
16: * class ClassRef
17: *
18: * @author: Jani Lehtimäki
19: */
20: public class ClassRef extends Ref {
21:
22: protected ClassType _classtype = null;
23:
24: public ClassRef(ReferenceResolver resolver) {
25: super (resolver);
26: }
27:
28: public Type getType() {
29: return _classtype;
30: }
31:
32: public ClassType getClassType() {
33: return _classtype;
34: }
35:
36: public boolean resolve(ErrorListener context) {
37: Type type = _resolver.resolveReference(context);
38: if (type != null) {
39: if (type.getType() != Type.CLASS) {
40: context.error(_resolver.getLocation(), "Entity '"
41: + toString() + "' is not a class");
42: } else {
43: if (type instanceof NativeJava) {
44: context.error(_resolver.getLocation(), "Entity '"
45: + toString()
46: + "' is class which cannot be extended.");
47: }
48: _classtype = (ClassType) type;
49: }
50: } else {
51: context.error(_resolver.getLocation(), "Entity '"
52: + toString() + "' is not declared");
53: }
54: _resolved = true;
55: return (_classtype != null);
56: }
57:
58: }
|