(identifier: string, type: Type, initializer?: Expression)
| 643 | initializer?: Expression; |
| 644 | |
| 645 | constructor(identifier: string, type: Type, initializer?: Expression) { |
| 646 | super(); |
| 647 | this.identifier = identifier; |
| 648 | this.type = type; |
| 649 | if (type.category == 'method') |
| 650 | throw new Error('Can not store method as function object'); |
| 651 | if (initializer) { |
| 652 | // Make sure initializer is casted to the variable type. |
| 653 | this.initializer = castExpression(initializer, type); |
| 654 | } else if (type.isObject()) { |
| 655 | // Make sure pointers are initialized to nullptr. |
| 656 | this.initializer = new UndefinedKeyword(type); |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | override print(ctx: PrintContext) { |
| 661 | this.type.markUsed(ctx); |
nothing calls this directly
no test coverage detected