/*
 * Simple Object (environment)
 *
 * Author(s) : Catalin Dumitrescu (catalind@acm.org)
 *
 * File: environ.hh
 * Created: Mon Aug 27 10:15:57 CDT 2001
 *
 */

#ifndef _ENVIRON_
#define _ENVIRON_

#include "hash.hh"
#include "object.hh"
#include "scheme_exc.hh"

#define ENVIRON 10

class envException : public schemeException {
public:
  envException (string s) : schemeException (s) { }
};

class environ : public object {
  environ* parent; 
  shash<object*> content;

public:
  environ (environ* p) { parent = p; }
  ~environ () { }

  virtual object* clone ();
  virtual object* evaluate (bool, object*) { return this; } 
  virtual void* pvalue () { return &content; } 
  virtual void print (ostream&) { }

  virtual int getType () { return ENVIRON; }

  /* Add a new string correlated with an object in current scope */
  void add (string key, object* obj) throw (schemeException) 
    { content.insert (key, obj); }
  /* Search only the current environment */
  object* lookup (string key) throw (schemeException); 
  /* Extended lookup (searching also parent environments */
  object* elookup (string key) throw (schemeException);
};

#endif // _ENVIRON_

