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

Method constructor

src/cpp-syntax.ts:908–932  ·  view source on GitHub ↗
(type: Type, isExported: boolean, members: ClassElement[])

Source from the content-addressed store, hash-verified

906 destructor?: ClassElement;
907
908 constructor(type: Type, isExported: boolean, members: ClassElement[]) {
909 super(type, type.name, isExported);
910 for (const member of members) {
911 if (member.modifiers.includes('private'))
912 this.privateMembers.push(member);
913 else if (member.modifiers.includes('protected'))
914 this.protectedMembers.push(member);
915 else
916 this.publicMembers.push(member);
917 }
918 if (notTriviallyDestructible(members)) {
919 // Add Trace method.
920 const trace = createTraceMethod(this.type, members);
921 if (trace) {
922 trace.classDeclaration = this;
923 this.publicMembers.push(trace);
924 }
925 // Add a virtual destructor.
926 const destructor = new DestructorDeclaration(this.name, [ 'virtual' ]);
927 destructor.classDeclaration = this;
928 this.publicMembers.push(destructor);
929 }
930 // Add pre finalizer if a method is marked as destructor.
931 this.destructor = members.find(m => m instanceof MethodDeclaration && m.modifiers.includes('destructor'));
932 }
933
934 override print(ctx: PrintContext) {
935 ctx.features.add('object');

Callers

nothing calls this directly

Calls 4

notTriviallyDestructibleFunction · 0.90
createTraceMethodFunction · 0.90
includesMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected