Skip to content

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
maximiliankaul committed Oct 23, 2023
1 parent 566097e commit b14fb61
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ class ExpressionHandler(frontend: PythonLanguageFrontend) :
}

private fun handleTuple(node: PythonAST.Tuple): Expression {
TODO()
val lst = mutableListOf<Expression>()
for (e in node.elts) {
lst += handle(e)
}
val ile = newInitializerListExpression(rawNode = node)
ile.initializers = lst.toList()
return ile
}

private fun handleIfExp(node: PythonAST.IfExp): Expression {
Expand All @@ -62,7 +68,18 @@ class ExpressionHandler(frontend: PythonLanguageFrontend) :
}

private fun handleDict(node: PythonAST.Dict): Expression {
TODO()
val lst = mutableListOf<Expression>()
for (i in node.values.indices) {
lst +=
newKeyValueExpression(
key = node.keys[i]?.let { handle(it) },
value = handle(node.values[i]),
rawNode = node
)
}
val ile = newInitializerListExpression(rawNode = node)
ile.initializers = lst.toList()
return ile
}

private fun handleCompare(node: PythonAST.Compare): Expression {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ interface PythonAST {
* ```
*/
class Dict(pyObject: PyObject) : ExprBase(pyObject) {
val keys: List<ExprBase> by lazy { "keys" of pyObject }
val keys: List<ExprBase?> by lazy { "keys" of pyObject }
val values: List<ExprBase> by lazy { "values" of pyObject }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -908,9 +908,8 @@ class PythonFrontendTest : BaseTest() {
assertLocalName("minor", ifCond.lhs as? Reference)

// phr = {"user_id": user_id} | content
val phrDeclaration =
(ifThen.statements[0] as? DeclarationStatement)?.declarations?.get(0)
as? VariableDeclaration
val phrDeclaration = (ifThen.statements[0] as? AssignExpression)?.declarations?.get(0)

assertNotNull(phrDeclaration)
assertLocalName("phr", phrDeclaration)
val phrInitializer = phrDeclaration.firstAssignment as? BinaryOperator
Expand All @@ -919,9 +918,7 @@ class PythonFrontendTest : BaseTest() {
assertEquals(true, phrInitializer.lhs is InitializerListExpression)

// z = {"user_id": user_id}
val elseStmt1 =
(ifElse.statements[0] as? DeclarationStatement)?.declarations?.get(0)
as? VariableDeclaration
val elseStmt1 = (ifElse.statements[0] as? AssignExpression)?.declarations?.get(0)
assertNotNull(elseStmt1)
assertLocalName("z", elseStmt1)

Expand Down

0 comments on commit b14fb61

Please sign in to comment.