(ast)
| 212 | } |
| 213 | |
| 214 | traceFunctionAST(ast) { |
| 215 | const { contexts, declarations, functions, identifiers, functionCalls } = new FunctionTracer(ast); |
| 216 | this.contexts = contexts; |
| 217 | this.identifiers = identifiers; |
| 218 | this.functionCalls = functionCalls; |
| 219 | this.functions = functions; |
| 220 | for (let i = 0; i < declarations.length; i++) { |
| 221 | const declaration = declarations[i]; |
| 222 | const { ast, inForLoopInit, inForLoopTest } = declaration; |
| 223 | const { init } = ast; |
| 224 | const dependencies = this.getDependencies(init); |
| 225 | let valueType = null; |
| 226 | |
| 227 | if (inForLoopInit && inForLoopTest) { |
| 228 | valueType = 'Integer'; |
| 229 | } else { |
| 230 | if (init) { |
| 231 | const realType = this.getType(init); |
| 232 | switch (realType) { |
| 233 | case 'Integer': |
| 234 | case 'Float': |
| 235 | case 'Number': |
| 236 | if (init.type === 'MemberExpression') { |
| 237 | valueType = realType; |
| 238 | } else { |
| 239 | valueType = 'Number'; |
| 240 | } |
| 241 | break; |
| 242 | case 'LiteralInteger': |
| 243 | valueType = 'Number'; |
| 244 | break; |
| 245 | default: |
| 246 | valueType = realType; |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | declaration.valueType = valueType; |
| 251 | declaration.dependencies = dependencies; |
| 252 | declaration.isSafe = this.isSafeDependencies(dependencies); |
| 253 | } |
| 254 | |
| 255 | for (let i = 0; i < functions.length; i++) { |
| 256 | this.onNestedFunction(functions[i], this.source); |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | getDeclaration(ast) { |
| 261 | for (let i = 0; i < this.identifiers.length; i++) { |
no test coverage detected