01: /**************************************************************************/
02: /* N I C E */
03: /* A high-level object-oriented research language */
04: /* (c) Daniel Bonniot 2000 */
05: /* */
06: /* This program is free software; you can redistribute it and/or modify */
07: /* it under the terms of the GNU General Public License as published by */
08: /* the Free Software Foundation; either version 2 of the License, or */
09: /* (at your option) any later version. */
10: /* */
11: /**************************************************************************/package bossa.syntax;
12:
13: import java.util.*;
14:
15: /**
16: Abstract definition.
17: May be a class definition, a method definition, an interface definition...
18:
19: @version $Date: 2005/03/06 01:34:26 $
20: @author Daniel Bonniot (d.bonniot@mail.dotcom.fr)
21: */
22: public abstract class Definition extends Node implements
23: bossa.util.Located {
24:
25: Definition(LocatedString name, int propagate) {
26: super (propagate);
27:
28: this .name = name;
29: module = currentModule;
30: }
31:
32: /**
33: Resolve local entities, that do not influence the global context.
34:
35: Toplevel entities have already been resolved and declared earlier,
36: since they can be mutually recursive.
37: */
38: void resolveBody() {
39: }
40:
41: /**
42: * Write the exported interface of the definition
43: * to the stream.
44: *
45: * @param s a PrintWriter
46: */
47: abstract void printInterface(java.io.PrintWriter s);
48:
49: static void printInterface(List definitions, java.io.PrintWriter s) {
50: if (definitions == null)
51: return;
52: for (Iterator i = definitions.iterator(); i.hasNext();)
53: ((Definition) i.next()).printInterface(s);
54: }
55:
56: /**
57: * Generates bytecode for this definition.
58: */
59: abstract void compile();
60:
61: /**
62: * The module this definition appears in.
63: */
64: protected Module module;
65: public static Module currentModule;
66:
67: public boolean inInterfaceFile() {
68: return module.compiled();
69: }
70:
71: bossa.modules.Compilation compilation() {
72: return module.compilation();
73: }
74:
75: /****************************************************************
76: * Name and location of the definition
77: ****************************************************************/
78:
79: public LocatedString getName() {
80: return name;
81: }
82:
83: public bossa.util.Location location() {
84: return name.location();
85: }
86:
87: LocatedString name;
88:
89: public String docString;
90: }
|