MCPcopy Create free account
hub / github.com/compilets/compilets / constructor

Method constructor

src/cpp-syntax.ts:645–658  ·  view source on GitHub ↗
(identifier: string, type: Type, initializer?: Expression)

Source from the content-addressed store, hash-verified

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);

Callers

nothing calls this directly

Calls 2

castExpressionFunction · 0.90
isObjectMethod · 0.80

Tested by

no test coverage detected