|
1 | 1 | /**
|
2 |
| - * This file imports the module that is used to construct the strings used by `Node.ToString`. |
| 2 | + * This file imports the class that is used to construct the strings used by |
| 3 | + * `Node.ToString`. |
3 | 4 | *
|
4 |
| - * Normally, this file should just import `NormalNode0ToString` to compute the efficient `toString`, but for debugging purposes |
5 |
| - * one can import `DebugPrinting.qll` to better correlate the dataflow nodes with their underlying instructions and operands. |
| 5 | + * Normally, this file should just import `NormalNode0ToString` to compute the |
| 6 | + * efficient `toString`, but for debugging purposes one can import |
| 7 | + * `DebugPrinting.qll` to better correlate the dataflow nodes with their |
| 8 | + * underlying instructions and operands. |
6 | 9 | */
|
7 | 10 |
|
8 |
| -import Node0ToStringSig |
9 |
| -import NormalNode0ToString |
| 11 | +private import semmle.code.cpp.ir.IR |
| 12 | +private import codeql.util.Unit |
| 13 | +private import DataFlowUtil |
| 14 | +import NormalNode0ToString // Change this import to control which version should be used. |
| 15 | + |
| 16 | +/** An abstract class to control the behavior of `Node.toString`. */ |
| 17 | +abstract class Node0ToString extends Unit { |
| 18 | + /** |
| 19 | + * Gets the string that should be used by `OperandNode.toString` to print the |
| 20 | + * dataflow node whose underlying operand is `op.` |
| 21 | + */ |
| 22 | + abstract string operandToString(Operand op); |
| 23 | + |
| 24 | + /** |
| 25 | + * Gets the string that should be used by `InstructionNode.toString` to print |
| 26 | + * the dataflow node whose underlying instruction is `instr`. |
| 27 | + */ |
| 28 | + abstract string instructionToString(Instruction i); |
| 29 | + |
| 30 | + /** |
| 31 | + * Gets the string representation of the `Expr` associated with `n`, if any. |
| 32 | + */ |
| 33 | + abstract string toExprString(Node n); |
| 34 | +} |
| 35 | + |
| 36 | +/** |
| 37 | + * Gets the string that should be used by `OperandNode.toString` to print the |
| 38 | + * dataflow node whose underlying operand is `op.` |
| 39 | + */ |
| 40 | +string operandToString(Operand op) { result = any(Node0ToString s).operandToString(op) } |
| 41 | + |
| 42 | +/** |
| 43 | + * Gets the string that should be used by `InstructionNode.toString` to print |
| 44 | + * the dataflow node whose underlying instruction is `instr`. |
| 45 | + */ |
| 46 | +string instructionToString(Instruction instr) { |
| 47 | + result = any(Node0ToString s).instructionToString(instr) |
| 48 | +} |
| 49 | + |
| 50 | +/** |
| 51 | + * Gets the string representation of the `Expr` associated with `n`, if any. |
| 52 | + */ |
| 53 | +string toExprString(Node n) { result = any(Node0ToString s).toExprString(n) } |
0 commit comments