|
| 1 | +private import semmle.code.binary.ast.Location |
| 2 | +private import semmle.code.binary.ast.instructions as Raw |
| 3 | +private import TranslatedElement |
| 4 | +private import codeql.util.Option |
| 5 | +private import semmle.code.binary.ast.ir.internal.Opcode as Opcode |
| 6 | +private import Variable |
| 7 | +private import Instruction |
| 8 | +private import TranslatedInstruction |
| 9 | +private import TranslatedFunction |
| 10 | +private import semmle.code.binary.ast.ir.internal.Tags |
| 11 | +private import InstructionTag |
| 12 | +private import codeql.controlflow.SuccessorType |
| 13 | + |
| 14 | +abstract class TranslatedType extends TranslatedElement { |
| 15 | + final override predicate producesResult() { none() } |
| 16 | + |
| 17 | + final override Variable getResultVariable() { none() } |
| 18 | + |
| 19 | + final override Variable getVariableOperand(InstructionTag tag, OperandTag operandTag) { none() } |
| 20 | + |
| 21 | + final FunEntryInstruction getEntry() { none() } |
| 22 | + |
| 23 | + final override predicate hasInstruction( |
| 24 | + Opcode opcode, InstructionTag tag, Option<Variable>::Option v |
| 25 | + ) { |
| 26 | + none() |
| 27 | + } |
| 28 | + |
| 29 | + final override Instruction getSuccessor(InstructionTag tag, SuccessorType succType) { none() } |
| 30 | + |
| 31 | + abstract string getName(); |
| 32 | + |
| 33 | + abstract string getNamespace(); |
| 34 | + |
| 35 | + abstract TranslatedFunction getAFunction(); |
| 36 | + |
| 37 | + final override string toString() { result = "Translation of " + this.getName() } |
| 38 | + |
| 39 | + final override TranslatedFunction getEnclosingFunction() { none() } |
| 40 | + |
| 41 | + final override Instruction getChildSuccessor(TranslatedElement child, SuccessorType succType) { |
| 42 | + none() |
| 43 | + } |
| 44 | + |
| 45 | + final override string getDumpId() { result = this.getName() } |
| 46 | +} |
| 47 | + |
| 48 | +class TranslatedCiLType extends TranslatedType, TTranslatedCilType { |
| 49 | + Raw::CilType type; |
| 50 | + |
| 51 | + TranslatedCiLType() { this = TTranslatedCilType(type) } |
| 52 | + |
| 53 | + final override Raw::Element getRawElement() { result = type } |
| 54 | + |
| 55 | + final override string getName() { result = type.getName() } |
| 56 | + |
| 57 | + final override string getNamespace() { result = type.getNamespace() } |
| 58 | + |
| 59 | + final override TranslatedCilMethod getAFunction() { |
| 60 | + result = getTranslatedFunction(type.getAMethod()) |
| 61 | + } |
| 62 | + |
| 63 | + final override Location getLocation() { result = type.getLocation() } |
| 64 | +} |
| 65 | + |
| 66 | +TranslatedType getTranslatedType(Raw::Element raw) { result.getRawElement() = raw } |
0 commit comments