blob: cb38d776c5c9bbb47a20116c2d7dd5f94bf6fd1e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
/*
* GlobalEnvironment.java
*
* Initilializing must be done after loading classes.
*
* Jul 28, 1998 modified by mich
*/
package io.devnulllabs.openjava.mop;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import io.devnulllabs.openjava.tools.DebugOut;
public class GlobalEnvironment
extends Environment
{
private Hashtable table = new Hashtable();
public GlobalEnvironment() {
}
public String toString() {
StringWriter str_writer = new StringWriter();
PrintWriter out = new PrintWriter( str_writer );
out.println( "GlobalEnvironment" );
out.print( "class object table : " );
out.println( table.toString() );
out.flush();
return str_writer.toString();
}
private static void writeStringVector( PrintWriter out, Vector v ) {
Enumeration e = v.elements();
while (e.hasMoreElements()) {
String str = (String) e.nextElement();
out.print( str + " " );
}
}
/**
* Gets the package name.
*/
public String getPackageName()
{
return null;
}
/**
* Looks a class object up.
*
* @param name the name of the fully-qualified name of
* the class looked for
*/
public OJClass lookupClass( String name ) {
if (name == null) return null;
return (OJClass) table.get( name );
}
/**
* Records a class object.
*
* @param name the fully-qualified name of the class
* @param clazz the class object associated with that name
*/
public void record( String name, OJClass clazz ) {
String str = null;
try {
str = clazz.toString();
} catch (Exception ex) {
str = "<" + ex.toString() + ">";
}
DebugOut.println("Genv#record(): " + name + " " + str);
table.put(name, clazz);
}
/**
* Obtains the fully-qualified name of the given class name.
*
* @param name a simple class name or a fully-qualified class name
* @return the fully-qualified name of the class
*/
public String toQualifiedName( String name ) {
return name;
}
/**
* binds a name to the class type.
*
* @param name the fully-qualified name of the class
* @param clazz the class object associated with that name
*/
public void bindVariable( String name, OJClass clazz ) {
System.err.println( "error : illegal binding on GlobalEnvironment" );
}
public OJClass lookupBind( String name ) {
return null;
}
}
|