CSFrame.h

// CSFrame.h
//
// Author David Barrett-Lennard
// (C)opyright Cedanet Pty Ltd 2012

#include <map>
#include "Ceda/cxUtils/xstring.h"
#include "Ceda/cxUtils/SubString.h"
#include "Ceda/cxUtils/CedaAssert.h"
#include "Ceda/cxUtils/IException.h"
@import "Ceda/cxObject/Object.h"
@import "cxCedaScript.h"
@import "CSValue.h"

namespace ceda
{

typedef SubString Varname;

///////////////////////////////////////////////////////////////////////////////////////////////////
/*
struct Var
{
    Varname name;
    CSValue value;
};

inline bool operator==(const Var& x, const Var& y)
{
    return x.name == y.name;
}

inline bool operator<(const Var& x, const Var& y)
{
    return x.name < y.name;
}
*/

///////////////////////////////////////////////////////////////////////////////////////////////////
// CSFrame

class @api CSFrame
{
public:
    CSFrame(CSFrame* parent);

    typedef std::pair<const Varname,CSValue> Var;

    Var* FindLocal(Varname name);
    
    // Search locals and then recurse into parent frames
    Var* FindLocalOrNonlocal(Varname name);

private:
    typedef std::map<Varname,CSValue> MAP;
    MAP m_locals;
    
    //typedef std::set<Var> SET;
    //SET m_locals;
    
    // The parent frame of a given frame corresponds to the calling frame - i.e. the frame that 
    // caused this frame to be pushed onto the stack of frames during invocation of a function.
    CSFrame* m_parent;
};

} // namespace ceda