Commit d626e639 authored by Roberto Raggi's avatar Roberto Raggi

Process enumerators.

parent ada42e7e
...@@ -345,14 +345,23 @@ bool Bind::visit(EnumeratorAST *ast) ...@@ -345,14 +345,23 @@ bool Bind::visit(EnumeratorAST *ast)
return false; return false;
} }
void Bind::enumerator(EnumeratorAST *ast) void Bind::enumerator(EnumeratorAST *ast, Enum *symbol)
{ {
(void) symbol;
if (! ast) if (! ast)
return; return;
// unsigned identifier_token = ast->identifier_token; // unsigned identifier_token = ast->identifier_token;
// unsigned equal_token = ast->equal_token; // unsigned equal_token = ast->equal_token;
ExpressionTy expression = this->expression(ast->expression); ExpressionTy expression = this->expression(ast->expression);
if (ast->identifier_token) {
const Name *name = control()->nameId(identifier(ast->identifier_token));
Declaration *e = control()->newDeclaration(ast->identifier_token, name);
e->setType(control()->integerType(IntegerType::Int)); // ### introduce IntegerType::Enumerator
symbol->addMember(e);
}
} }
bool Bind::visit(ExceptionSpecificationAST *ast) bool Bind::visit(ExceptionSpecificationAST *ast)
...@@ -2325,14 +2334,19 @@ bool Bind::visit(ElaboratedTypeSpecifierAST *ast) ...@@ -2325,14 +2334,19 @@ bool Bind::visit(ElaboratedTypeSpecifierAST *ast)
bool Bind::visit(EnumSpecifierAST *ast) bool Bind::visit(EnumSpecifierAST *ast)
{ {
// unsigned enum_token = ast->enum_token; unsigned sourceLocation = ast->firstToken();
/*const Name *name =*/ this->name(ast->name); if (ast->name)
// unsigned lbrace_token = ast->lbrace_token; sourceLocation = ast->name->firstToken();
const Name *enumName = this->name(ast->name);
Enum *e = control()->newEnum(sourceLocation, enumName);
ast->symbol = e;
Scope *previousScope = switchScope(e);
for (EnumeratorListAST *it = ast->enumerator_list; it; it = it->next) { for (EnumeratorListAST *it = ast->enumerator_list; it; it = it->next) {
this->enumerator(it->value); this->enumerator(it->value, e);
} }
// unsigned rbrace_token = ast->rbrace_token; (void) switchScope(previousScope);
// Enum *symbol = ast->symbol;
return false; return false;
} }
......
...@@ -93,7 +93,7 @@ protected: ...@@ -93,7 +93,7 @@ protected:
void qtInterfaceName(QtInterfaceNameAST *ast); void qtInterfaceName(QtInterfaceNameAST *ast);
void baseSpecifier(BaseSpecifierAST *ast, unsigned colon_token, Class *klass); void baseSpecifier(BaseSpecifierAST *ast, unsigned colon_token, Class *klass);
void ctorInitializer(CtorInitializerAST *ast, Function *fun); void ctorInitializer(CtorInitializerAST *ast, Function *fun);
void enumerator(EnumeratorAST *ast); void enumerator(EnumeratorAST *ast, Enum *symbol);
FullySpecifiedType exceptionSpecification(ExceptionSpecificationAST *ast, const FullySpecifiedType &init); FullySpecifiedType exceptionSpecification(ExceptionSpecificationAST *ast, const FullySpecifiedType &init);
void memInitializer(MemInitializerAST *ast, Function *fun); void memInitializer(MemInitializerAST *ast, Function *fun);
const Name *nestedNameSpecifier(NestedNameSpecifierAST *ast); const Name *nestedNameSpecifier(NestedNameSpecifierAST *ast);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment