(ed, token)
| 523 | |
| 524 | |
| 525 | def getElementByDesignator(ed, token): |
| 526 | if not token.str in [ '.', '[' ]: |
| 527 | return None |
| 528 | |
| 529 | while token.str in [ '.', '[' ]: |
| 530 | token = token.astOperand1 |
| 531 | |
| 532 | while ed and not token.isAssignmentOp: |
| 533 | token = token.astParent |
| 534 | |
| 535 | if token.str == '[': |
| 536 | if not ed.isArray: |
| 537 | ed.markStuctureViolation(token) |
| 538 | |
| 539 | chIndex = -1 |
| 540 | if token.astOperand2 is not None: |
| 541 | chIndex = token.astOperand2.getKnownIntValue() |
| 542 | elif token.astOperand1 is not None: |
| 543 | chIndex = token.astOperand1.getKnownIntValue() |
| 544 | |
| 545 | ed = ed.getChildByIndex(chIndex) if chIndex is not None else None |
| 546 | |
| 547 | elif token.str == '.': |
| 548 | if not ed.isRecord: |
| 549 | ed.markStuctureViolation(token) |
| 550 | |
| 551 | name = "" |
| 552 | if token.astOperand2 is not None: |
| 553 | name = token.astOperand2.str |
| 554 | elif token.astOperand1 is not None: |
| 555 | name = token.astOperand1.str |
| 556 | |
| 557 | ed = ed.getChildByName(name) |
| 558 | |
| 559 | return ed |
no test coverage detected