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

Method print

src/cpp-syntax.ts:856–882  ·  view source on GitHub ↗
(ctx: PrintContext)

Source from the content-addressed store, hash-verified

854 }
855
856 override print(ctx: PrintContext) {
857 this.type.markUsed(ctx);
858 const {isFullDeclaraion, isMethodDeclaration, isClassDeclaration} = this.getPrintMode(ctx);
859 let result = ctx.prefix;
860 if (this.modifiers.includes('static')) {
861 if (isClassDeclaration)
862 result += 'static ';
863 else if (isMethodDeclaration)
864 result = `${ctx.prefix}// static\n${result}`;
865 }
866 if (isClassDeclaration && this.modifiers.includes('virtual'))
867 result += 'virtual ';
868 result += `${this.type.returnType.print(ctx)} `;
869 result += isMethodDeclaration ? `${this.classDeclaration!.name}::${this.name}` : this.name;
870 result += '(';
871 result += ParameterDeclaration.printParameters(ctx, this.parameters);
872 result += ')';
873 if (this.modifiers.includes('const'))
874 result += ' const';
875 if (isClassDeclaration && this.modifiers.includes('override'))
876 result += ' override';
877 if (isMethodDeclaration || isFullDeclaraion)
878 result += ' ' + (this.body?.print(ctx) ?? '{}');
879 else
880 result += ';';
881 return result;
882 }
883}
884
885export abstract class Statement {

Callers

nothing calls this directly

Calls 4

includesMethod · 0.80
printParametersMethod · 0.80
markUsedMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected