scope.cpp 503 Bytes
Newer Older
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
#include "include/scope.h"

static Root_scope * Root_scope::instance()
{
  if(!instance_)
    instance_ = new Root_scope();
  return instance_;
}

Type * Root_scope::lookup_symbol(char * sym, int* err)
{
  if(types_.find(sym) == types_.end())
    {
      // error
    }
  else
    return types_[sym];
}

int Root_scope::insert_symbol(char * sym, Type * value)
{
  std::pair<std::map<char*,Type*>::iterator,bool> ret;
  ret = types_.insert(std::pair<char*, Type*>(sym, value));
  
  return ret.second;
}