01: package gnu.expr;
02:
03: import gnu.mapping.*;
04:
05: /** An Environment containing the default bindings for the current Language.
06: * All <code>lookup</code> operatiosn are indirected to the
07: * current <code>Language</code>. */
08:
09: public class BuiltinEnvironment extends Environment {
10: static final BuiltinEnvironment instance = new BuiltinEnvironment();
11: static {
12: instance.setName("language-builtins");
13: }
14:
15: public static BuiltinEnvironment getInstance() {
16: return instance;
17: }
18:
19: public Environment getLangEnvironment() {
20: Language lang = Language.getDefaultLanguage();
21: return lang == null ? null : lang.getLangEnvironment();
22: }
23:
24: public NamedLocation lookup(Symbol name, Object property, int hash) {
25: if (property == ThreadLocation.ANONYMOUS)
26: return null;
27: Language lang = Language.getDefaultLanguage();
28: return lang == null ? null : lang.lookupBuiltin(name, property,
29: hash);
30: }
31:
32: public NamedLocation getLocation(Symbol key, Object property,
33: int hash, boolean create) {
34: throw new RuntimeException();
35: }
36:
37: public void define(Symbol key, Object property, Object newValue) {
38: throw new RuntimeException();
39: }
40:
41: public LocationEnumeration enumerateLocations() {
42: return getLangEnvironment().enumerateLocations();
43: }
44:
45: public LocationEnumeration enumerateAllLocations() {
46: return getLangEnvironment().enumerateLocations();
47: }
48:
49: protected boolean hasMoreElements(LocationEnumeration it) {
50: throw new RuntimeException();
51: }
52:
53: public NamedLocation addLocation(Symbol name, Object prop,
54: Location loc) {
55: throw new RuntimeException();
56: }
57: }
|