Skip to content

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
maximiliankaul committed Oct 19, 2023
1 parent b4ab9c1 commit 3776106
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import de.fraunhofer.aisec.cpg.graph.declarations.FieldDeclaration
import de.fraunhofer.aisec.cpg.graph.declarations.MethodDeclaration
import de.fraunhofer.aisec.cpg.graph.declarations.VariableDeclaration
import de.fraunhofer.aisec.cpg.graph.statements.expressions.AssignExpression
import de.fraunhofer.aisec.cpg.graph.statements.expressions.CallExpression
import de.fraunhofer.aisec.cpg.graph.statements.expressions.MemberExpression
import de.fraunhofer.aisec.cpg.graph.statements.expressions.Reference
import de.fraunhofer.aisec.cpg.helpers.SubgraphWalker
Expand Down Expand Up @@ -74,6 +75,9 @@ class PythonAddDeclarationsPass(ctx: TranslationContext) : ComponentPass(ctx), N
* Return null when not creating a new decl
*/
private fun handleReference(node: Reference): VariableDeclaration? {
if (node.resolutionHelper is CallExpression) {
return null
}
val resolved = scopeManager.resolveReference(node)
if (resolved == null) {
val decl =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class PythonFrontendTest : BaseTest() {
val s = bar.parameters.first()
assertNotNull(s)
assertLocalName("s", s)
assertEquals(tu.primitiveType("str"), s.type)
// assertEquals(tu.primitiveType("str"), s.type) TODO decide how to handle types here

assertLocalName("bar", bar)

Expand All @@ -164,15 +164,15 @@ class PythonFrontendTest : BaseTest() {
assertLocalName("s", ref)
assertEquals(s, ref.refersTo)

val stmt = compStmt.statements[1] as? DeclarationStatement
val stmt = compStmt.statements[1] as? AssignExpression
assertNotNull(stmt)

val a = stmt.singleDeclaration as? VariableDeclaration
val a = stmt.declarations.first() as? VariableDeclaration
assertNotNull(a)

assertLocalName("a", a)

val op = a.initializer as? BinaryOperator
val op = a.firstAssignment as? BinaryOperator
assertNotNull(op)

assertEquals("+", op.operatorCode)
Expand Down Expand Up @@ -722,13 +722,13 @@ class PythonFrontendTest : BaseTest() {
val p = tu.namespaces["literal"]
assertNotNull(p)

assertEquals(Region(1, 1, 1, 9), (p.variables["b"])?.location?.region)
assertEquals(Region(1, 5, 1, 9), (p.variables["b"])?.initializer?.location?.region)
assertEquals(Region(2, 1, 2, 7), (p.variables["i"])?.location?.region)
assertEquals(Region(3, 1, 3, 8), (p.variables["f"])?.location?.region)
assertEquals(Region(4, 1, 4, 11), (p.variables["c"])?.location?.region)
assertEquals(Region(5, 1, 5, 12), (p.variables["t"])?.location?.region)
assertEquals(Region(6, 1, 6, 9), (p.variables["n"])?.location?.region)
assertEquals(Region(1, 0, 1, 8), (p.statements[0]).location?.region)
assertEquals(Region(1, 4, 1, 8), (p.variables["b"])?.firstAssignment?.location?.region)
assertEquals(Region(2, 0, 2, 6), (p.statements[1]).location?.region)
assertEquals(Region(3, 0, 3, 7), (p.statements[2]).location?.region)
assertEquals(Region(4, 0, 4, 10), (p.statements[3]).location?.region)
assertEquals(Region(5, 0, 5, 11), (p.statements[4]).location?.region)
assertEquals(Region(6, 0, 6, 8), (p.statements[5]).location?.region)
}

@Test
Expand Down

0 comments on commit 3776106

Please sign in to comment.