/* SI 413 Fall 2011
 * C++ header file for the Frame class
 * Supports lexical scope
 */

#ifndef FRAME_HPP
#define FRAME_HPP

#include <iostream>
#include <map>
#include <string>
using namespace std;

#include "value.hpp"

/* This class represents a lexical frame. */
class Frame {
  private:
    map<string,Value> bindings;
    Frame* parent;

  public:
    // Constructor takes a pointer to the parent frame.
    // Symbol table will initially be empty.
    Frame (Frame* p = NULL) :parent(p) { }

    // Returns the Value bound to the given name.
    Value lookup(string name);

    // Creates a new name-value binding
    void bind(string name, Value val = Value());

    // Re-defines the value bound to the given name.
    void rebind(string name, Value val);
};

#endif // FRAME_HPP