-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update type and query to improve reentrancy
- Loading branch information
1 parent
aa7692b
commit e06c88f
Showing
6 changed files
with
201 additions
and
9 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...y/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/solidity/ConstructorResolutionPass.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package de.fraunhofer.aisec.cpg.frontends.solidity | ||
|
||
import com.google.common.graph.Graphs | ||
import de.fraunhofer.aisec.cpg.TranslationContext | ||
import de.fraunhofer.aisec.cpg.graph.Component | ||
import de.fraunhofer.aisec.cpg.graph.Node | ||
import de.fraunhofer.aisec.cpg.graph.allChildren | ||
import de.fraunhofer.aisec.cpg.graph.declarations.FunctionDeclaration | ||
import de.fraunhofer.aisec.cpg.graph.declarations.RecordDeclaration | ||
import de.fraunhofer.aisec.cpg.graph.declarations.TranslationUnitDeclaration | ||
import de.fraunhofer.aisec.cpg.graph.declarations.VariableDeclaration | ||
import de.fraunhofer.aisec.cpg.graph.newConstructExpression | ||
import de.fraunhofer.aisec.cpg.graph.scopes.GlobalScope | ||
import de.fraunhofer.aisec.cpg.graph.scopes.ValueDeclarationScope | ||
import de.fraunhofer.aisec.cpg.graph.statements.expressions.CallExpression | ||
import de.fraunhofer.aisec.cpg.graph.statements.expressions.ConstructExpression | ||
import de.fraunhofer.aisec.cpg.graph.types.ObjectType | ||
import de.fraunhofer.aisec.cpg.helpers.SubgraphWalker | ||
import de.fraunhofer.aisec.cpg.passes.* | ||
import de.fraunhofer.aisec.cpg.passes.order.DependsOn | ||
import de.fraunhofer.aisec.cpg.passes.order.ExecuteBefore | ||
|
||
@ExecuteBefore(EvaluationOrderGraphPass::class) | ||
@ExecuteBefore(TypeResolver::class) | ||
class ConstructorResolutionPass(ctx: TranslationContext): TranslationUnitPass(ctx) { | ||
|
||
override fun accept(result: TranslationUnitDeclaration) { | ||
val all = SubgraphWalker.flattenAST(result) | ||
val records = all.filterIsInstance<RecordDeclaration>() | ||
val calls = all.filterIsInstance<CallExpression>() | ||
|
||
calls.forEach { | ||
val call = it | ||
val record = records.filter { it.name.lastPartsMatch(call.name) }.firstOrNull() | ||
record?.let { | ||
call.type = ObjectType(record.name.toString(), listOf(), false, call.language) //TypeHandler.getAddressType(call.language,call.ctx!!) | ||
} | ||
} | ||
} | ||
|
||
override fun cleanup() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters