Commits

Dmitri Hrybenko committed f73d866d916
Implement delayed parsing for function bodies In order to do this, we need to save and restore parser state easily. The important pieces of state are: * lexer position; * lexical scope stack. Lexer position can be saved/restored easily. We don't need to store the tokens for the function body because swift does not have a preprocessor and we can easily re-lex everything we need. We just store the lexer state for the beginning and the end of the body. To save the lexical scope stack, we had to change the underlying data structure. Originally, the parser used the ScopedHashTable, which supports only a stack of scopes. But we need a *tree* of scopes. I implemented TreeScopedHashTable based on ScopedHashTable. It has an optimization for pushing/popping scopes in a stack fashion -- these scopes will not be allocated on the heap. While ‘detached’ scopes that we want to re-enter later, and all their parent scopes, are moved to the heap. In parseIntoTranslationUnit() we do a second pass over the 'structural AST' that does not contain function bodies to actually parse them from saved token ranges. Swift SVN r5886