* Add a top-level variable declaration.
(statement: syntax.VariableStatement)
| 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. |
no test coverage detected