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

Method addVariableStatement

src/cpp-file.ts:67–76  ·  view source on GitHub ↗

* Add a top-level variable declaration.

(statement: syntax.VariableStatement)

Source from the content-addressed store, hash-verified

65 * Add a top-level variable declaration.
66 */
67 addVariableStatement(statement: syntax.VariableStatement) {
68 // For non-main function top-level variable declaration is static variable.
69 if (!this.body)
70 return this.addDeclaration(statement);
71 // If the main function has been created, treat it as local variable.
72 if (!this.body.isEmpty())
73 return this.addStatement(statement);
74 // Otherwise keep the declarations and wait for following statements.
75 this.variableStatements.push(statement);
76 }
77
78 /**
79 * Add statements to the main body.

Callers 1

parseSourceFileMethod · 0.95

Calls 4

addDeclarationMethod · 0.95
addStatementMethod · 0.95
isEmptyMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected