@@ -2372,3 +2372,98 @@ class TranslatedCilLoadArg extends TranslatedCilInstruction, TTranslatedCilLoadA
23722372 result = getTranslatedCilInstruction ( instr .getABackwardPredecessor ( ) ) .getStackElement ( i - 1 )
23732373 }
23742374}
2375+
2376+ /**
2377+ * Translation for CIL ldind.* instructions (load indirect through pointer).
2378+ * These instructions pop an address from the stack and push the value at that address.
2379+ */
2380+ class TranslatedCilLoadIndirect extends TranslatedCilInstruction , TTranslatedCilLoadIndirect {
2381+ override Raw:: CilLoadIndirectInstruction instr ;
2382+
2383+ TranslatedCilLoadIndirect ( ) { this = TTranslatedCilLoadIndirect ( instr ) }
2384+
2385+ final override predicate hasInstruction (
2386+ Opcode opcode , InstructionTag tag , Option< Variable > :: Option v
2387+ ) {
2388+ opcode instanceof Opcode:: Load and
2389+ tag = CilLdindLoadTag ( ) and
2390+ v .asSome ( ) = this .getTempVariable ( CilLdindVarTag ( ) )
2391+ }
2392+
2393+ override predicate hasTempVariable ( TempVariableTag tag ) { tag = CilLdindVarTag ( ) }
2394+
2395+ override predicate producesResult ( ) { any ( ) }
2396+
2397+ override Variable getVariableOperand ( InstructionTag tag , OperandTag operandTag ) {
2398+ tag = CilLdindLoadTag ( ) and
2399+ operandTag instanceof LoadAddressTag and
2400+ result = getTranslatedCilInstruction ( instr .getABackwardPredecessor ( ) ) .getStackElement ( 0 )
2401+ }
2402+
2403+ override Instruction getChildSuccessor ( TranslatedElement child , SuccessorType succType ) { none ( ) }
2404+
2405+ override Instruction getSuccessor ( InstructionTag tag , SuccessorType succType ) {
2406+ tag = CilLdindLoadTag ( ) and
2407+ succType instanceof DirectSuccessor and
2408+ result = getTranslatedInstruction ( instr .getASuccessor ( ) ) .getEntry ( )
2409+ }
2410+
2411+ override Instruction getEntry ( ) { result = this .getInstruction ( CilLdindLoadTag ( ) ) }
2412+
2413+ override Variable getResultVariable ( ) { result = this .getTempVariable ( CilLdindVarTag ( ) ) }
2414+
2415+ final override Variable getStackElement ( int i ) {
2416+ i = 0 and
2417+ result = this .getInstruction ( CilLdindLoadTag ( ) ) .getResultVariable ( )
2418+ or
2419+ i > 0 and
2420+ result = getTranslatedCilInstruction ( instr .getABackwardPredecessor ( ) ) .getStackElement ( i )
2421+ }
2422+ }
2423+
2424+ /**
2425+ * Translation for CIL stind.* instructions (store indirect through pointer).
2426+ * These instructions pop a value and an address from the stack, then store the value at that address.
2427+ */
2428+ class TranslatedCilStoreIndirect extends TranslatedCilInstruction , TTranslatedCilStoreIndirect {
2429+ override Raw:: CilStoreIndirectInstruction instr ;
2430+
2431+ TranslatedCilStoreIndirect ( ) { this = TTranslatedCilStoreIndirect ( instr ) }
2432+
2433+ final override predicate hasInstruction (
2434+ Opcode opcode , InstructionTag tag , Option< Variable > :: Option v
2435+ ) {
2436+ opcode instanceof Opcode:: Store and
2437+ tag = CilStindStoreTag ( ) and
2438+ v .isNone ( )
2439+ }
2440+
2441+ override predicate producesResult ( ) { any ( ) }
2442+
2443+ override Variable getVariableOperand ( InstructionTag tag , OperandTag operandTag ) {
2444+ tag = CilStindStoreTag ( ) and
2445+ exists ( Raw:: CilInstruction pred | pred = instr .getABackwardPredecessor ( ) |
2446+ operandTag instanceof StoreAddressTag and
2447+ result = getTranslatedCilInstruction ( pred ) .getStackElement ( 1 )
2448+ or
2449+ operandTag instanceof StoreValueTag and
2450+ result = getTranslatedCilInstruction ( pred ) .getStackElement ( 0 )
2451+ )
2452+ }
2453+
2454+ override Instruction getChildSuccessor ( TranslatedElement child , SuccessorType succType ) { none ( ) }
2455+
2456+ override Instruction getSuccessor ( InstructionTag tag , SuccessorType succType ) {
2457+ tag = CilStindStoreTag ( ) and
2458+ succType instanceof DirectSuccessor and
2459+ result = getTranslatedInstruction ( instr .getASuccessor ( ) ) .getEntry ( )
2460+ }
2461+
2462+ override Instruction getEntry ( ) { result = this .getInstruction ( CilStindStoreTag ( ) ) }
2463+
2464+ override Variable getResultVariable ( ) { none ( ) }
2465+
2466+ final override Variable getStackElement ( int i ) {
2467+ result = getTranslatedCilInstruction ( instr .getABackwardPredecessor ( ) ) .getStackElement ( i + 2 )
2468+ }
2469+ }
0 commit comments