(ast)
| 7 | 'use strict'; |
| 8 | |
| 9 | function evalStringConcat(ast) { |
| 10 | switch (ast.type) { |
| 11 | case 'StringLiteral': |
| 12 | case 'Literal': // ESLint |
| 13 | return ast.value; |
| 14 | case 'BinaryExpression': // `+` |
| 15 | if (ast.operator !== '+') { |
| 16 | throw new Error('Unsupported binary operator ' + ast.operator); |
| 17 | } |
| 18 | return evalStringConcat(ast.left) + evalStringConcat(ast.right); |
| 19 | default: |
| 20 | throw new Error('Unsupported type ' + ast.type); |
| 21 | } |
| 22 | } |
| 23 | exports.evalStringConcat = evalStringConcat; |
| 24 | |
| 25 | function evalStringAndTemplateConcat(ast, args) { |
no outgoing calls