Add accessors for scope info.

llvm-svn: 38917
This commit is contained in:
Chris Lattner 2006-08-14 00:57:12 +00:00
parent bd78161d95
commit 9a9d7ec822
1 changed files with 17 additions and 3 deletions
clang/include/clang/Parse

View File

@ -14,11 +14,11 @@
#ifndef LLVM_CLANG_PARSE_SCOPE_H
#define LLVM_CLANG_PARSE_SCOPE_H
#include "clang/Parse/Action.h"
#include "llvm/ADT/SmallVector.h"
namespace llvm {
namespace clang {
class Decl;
/// Scope - A scope is a transient data structure that is used while parsing the
/// program. It assists with resolving identifiers to the appropriate
@ -37,8 +37,9 @@ class Scope {
/// the declaration is added to the scope, it is set as the current
/// declaration for the identifier in the IdentifierTable. When the scope is
/// popped, these declarations are removed from the IdentifierTable's notion
/// of current declaration.
SmallVector<Decl*, 32> DeclsInScope;
/// of current declaration. It is up to the current Action implementation to
/// implement these semantics.
SmallVector<Action::DeclTy*, 32> DeclsInScope;
public:
Scope(Scope *parent) : Parent(parent), Depth(Parent ? Parent->Depth+1 : 0) {
}
@ -47,6 +48,19 @@ public:
///
Scope *getParent() const { return Parent; }
typedef SmallVector<Action::DeclTy*, 32>::iterator decl_iterator;
typedef SmallVector<Action::DeclTy*, 32>::const_iterator decl_const_iterator;
decl_iterator decl_begin() { return DeclsInScope.begin(); }
decl_iterator decl_end() { return DeclsInScope.end(); }
decl_const_iterator decl_begin() const { return DeclsInScope.begin(); }
decl_const_iterator decl_end() const { return DeclsInScope.end(); }
void AddDecl(Action::DeclTy *D) {
DeclsInScope.push_back(D);
}
};
} // end namespace clang