Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 23694bd

Browse files
author
AndreiDiaconu1
committed
Work on classes + refactor
Began working o inheritance, polymorphism and constructor init. Correct code is produced for them (though some more work is needed to accurately treat conversions between classes). Removed commented code. Added classes to properly deal with constructor init and modified and refactored TranslatedFunction to accomodate for the changes.
1 parent 9018b25 commit 23694bd

9 files changed

Lines changed: 428 additions & 726 deletions

File tree

csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/InstructionTag.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ newtype TInstructionTag =
2525
AssignOperationLoadTag() or
2626
AssignOperationConvertLeftTag() or
2727
AssignOperationOpTag() or
28+
AssignmentConvertRightTag() or
2829
AssignOperationConvertResultTag() or
2930
AssignmentStoreTag() or
3031
CrementLoadTag() or
@@ -114,6 +115,7 @@ string getInstructionTagId(TInstructionTag tag) {
114115
tag = ZeroPadStringStoreTag() and result = "ZeroPadStore" or
115116
tag = AssignOperationLoadTag() and result = "AssignOpLoad" or
116117
tag = AssignOperationConvertLeftTag() and result = "AssignOpConvLeft" or
118+
tag = AssignmentConvertRightTag() and result = "AssignConvRight" or
117119
tag = AssignOperationOpTag() and result = "AssignOpOp" or
118120
tag = AssignOperationConvertResultTag() and result = "AssignOpConvRes" or
119121
tag = AssignmentStoreTag() and result = "AssignStore" or

csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/TranslatedCall.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@ class TranslatedFunctionCall extends TranslatedCallExpr, TranslatedDirectCall {
278278
* the constructor call, address will be passed to a variable declaration.
279279
*/
280280
class TranslatedConstructorCall extends TranslatedFunctionCall {
281-
TranslatedConstructorCall() { expr instanceof ObjectCreation }
281+
TranslatedConstructorCall() {
282+
expr instanceof ObjectCreation or
283+
expr instanceof ConstructorInitializer
284+
}
282285

283286
override Instruction getQualifierResult() {
284287
exists(StructorCallContext context |

csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/TranslatedElement.qll

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -307,19 +307,10 @@ newtype TTranslatedElement =
307307
isFirstValueInitializedElementInRange(initList, elementIndex) and
308308
elementCount = getEndOfValueInitializedRange(initList, elementIndex) - elementIndex
309309
} or
310-
// TODO: Convert to C#
311-
// The initialization of a base class from within a constructor.
312-
// TTranslatedConstructorBaseInit(ConstructorBaseInit init) {
313-
// not ignoreExpr(init)
314-
// } or
315-
// // The destruction of a base class from within a destructor.
316-
// TTranslatedDestructorBaseDestruction(DestructorBaseDestruction destruction) {
317-
// not ignoreExpr(destruction)
318-
// } or
319-
// // The destruction of a field from within a destructor.
320-
// TTranslatedDestructorFieldDestruction(DestructorFieldDestruction destruction) {
321-
// not ignoreExpr(destruction)
322-
// } or
310+
// The initialization of a base class from within a constructor.
311+
TTranslatedConstructorInitializer(ConstructorInitializer init) {
312+
not ignoreExpr(init)
313+
} or
323314
// A statement
324315
TTranslatedStmt(Stmt stmt) { translateStmt(stmt) } or
325316
// A function

0 commit comments

Comments
 (0)