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

Method pushDeclaration

src/cpp-file.ts:177–185  ·  view source on GitHub ↗

* Push the declaration to this.declarations with some checks.

(...declarations: syntax.DeclarationStatement[])

Source from the content-addressed store, hash-verified

175 * Push the declaration to this.declarations with some checks.
176 */
177 private pushDeclaration(...declarations: syntax.DeclarationStatement[]) {
178 for (const decl of declarations) {
179 if (decl instanceof syntax.VariableStatement) {
180 if (decl.type.hasObject() && decl.declarationList.declarations.some(d => d.initializer))
181 throw new Error('Can not initialize objects in top-level variable declarations');
182 }
183 }
184 this.declarations.statements.push(...declarations);
185 }
186
187 /**
188 * Print declarations for all the function and class declarations.

Callers 2

addDeclarationMethod · 0.95

Calls 2

hasObjectMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected