(binding: Binding, module: SourceModule)
| 1487 | } |
| 1488 | |
| 1489 | private bindingValue(binding: Binding, module: SourceModule): Evaluated { |
| 1490 | const cached = this.valuesByBinding.get(binding) |
| 1491 | if (cached === "evaluating") { |
| 1492 | return { |
| 1493 | value: new DynamicValue( |
| 1494 | module, |
| 1495 | binding.id, |
| 1496 | `\`${binding.name}\` depends on itself` |
| 1497 | ), |
| 1498 | trace: emptyTrace() |
| 1499 | } |
| 1500 | } |
| 1501 | if (cached) return cached |
| 1502 | this.registerSites?.(module) |
| 1503 | this.valuesByBinding.set(binding, "evaluating") |
| 1504 | const declaration = binding.declaration |
| 1505 | const ctx = rootContext(module, declaration) |
| 1506 | let result: Evaluated |
| 1507 | try { |
| 1508 | result = { |
| 1509 | value: |
| 1510 | binding.kind === "function" ? |
| 1511 | this.functionStandIn( |
| 1512 | { |
| 1513 | node: declaration as FunctionNode, |
| 1514 | module, |
| 1515 | env: undefined, |
| 1516 | name: binding.name |
| 1517 | }, |
| 1518 | declaration |
| 1519 | ) |
| 1520 | : binding.kind === "class" ? |
| 1521 | this.classStandIn(declaration as Class, ctx) |
| 1522 | : binding.kind === "enum" ? this.evaluateEnum(binding, ctx) |
| 1523 | : this.declaredValue(binding, ctx), |
| 1524 | trace: ctx.trace |
| 1525 | } |
| 1526 | } catch (e) { |
| 1527 | result = { value: undefined, trace: ctx.trace, error: e } |
| 1528 | } |
| 1529 | this.markDeclared( |
| 1530 | result, |
| 1531 | declaration.type === "VariableDeclarator" ? declaration.init : undefined, |
| 1532 | module |
| 1533 | ) |
| 1534 | this.valuesByBinding.set(binding, result) |
| 1535 | return result |
| 1536 | } |
| 1537 | |
| 1538 | private markDeclared( |
| 1539 | result: Evaluated, |
no test coverage detected