Fixed issue in parsing typed objects in multiple iterations and added test case.

This commit is contained in:
2017-06-18 04:15:05 +02:00
parent 04ded5e8b8
commit e364d01cf4
4 changed files with 23 additions and 5 deletions

View File

@@ -34,7 +34,7 @@ void parseAndAddConstantDeclarations(Context &context, ast::Domain &domain, ast:
tokenizer.skipWhiteSpace();
// Index on the first element of the current inheritance list
size_t inheritanceIndex = 0;
size_t inheritanceIndex = constantDeclarations.size();
while (tokenizer.currentCharacter() != ')')
{

View File

@@ -45,6 +45,7 @@ void parseAndAddPrimitiveTypeDeclarations(Context &context, ast::Domain &domain)
tokenizer.skipWhiteSpace();
const auto position = tokenizer.position();
const auto typeStartIndex = domain.types.size();
// First pass: collect all primitive types
while (tokenizer.currentCharacter() != ')')
@@ -64,8 +65,9 @@ void parseAndAddPrimitiveTypeDeclarations(Context &context, ast::Domain &domain)
// Second pass: link parent types correctly
// Index on the first element of the current inheritance list
size_t inheritanceIndex = 0;
size_t i = 0;
// TODO: test correct implementation of offset if this function is called multiple times
size_t inheritanceIndex = typeStartIndex;
size_t i = typeStartIndex;
while (tokenizer.currentCharacter() != ')')
{

View File

@@ -35,7 +35,7 @@ void parseAndAddVariableDeclarations(Context &context, ast::Domain &domain, ast:
tokenizer.skipWhiteSpace();
// Index on the first element of the current inheritance list
size_t inheritanceIndex = 0;
size_t inheritanceIndex = variableDeclarations.size();
while (tokenizer.currentCharacter() != ')')
{