Skip to content

Commit 815473e

Browse files
committed
Update codegen
1 parent 25697d1 commit 815473e

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

utbot-python/src/main/kotlin/org/utbot/python/framework/codegen/model/PythonCodeGenerator.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class PythonCodeGenerator(
143143
val parameters = methodArguments.zip(arguments).map { (model, argument) ->
144144
if (model is PythonTreeModel) {
145145
val obj = (context.cgLanguageAssistant.getVariableConstructorBy(context) as PythonCgVariableConstructor).getOrCreateVariable(model)
146+
context.currentBlock.forEach {it.accept(renderer)}
146147
// (obj as CgPythonTree).children.forEach { it.accept(renderer) }
147148

148149
CgAssignment(

utbot-python/src/main/kotlin/org/utbot/python/framework/codegen/model/constructor/tree/PythonCgVariableConstructor.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class PythonCgVariableConstructor(context_: CgContext) : CgVariableConstructor(c
9696
}
9797

9898
val initArgs = objectNode.args.map {
99-
pythonBuildObject2(it)
99+
getOrCreateVariable(PythonTreeModel(it, it.type))
100100
}
101101
val constructor = ConstructorId(
102102
objectNode.constructor,
@@ -111,16 +111,14 @@ class PythonCgVariableConstructor(context_: CgContext) : CgVariableConstructor(c
111111
(context.cgLanguageAssistant as PythonCgLanguageAssistant).memoryObjects[id] = obj
112112

113113
val state = objectNode.state.map { (key, value) ->
114-
val buildObj = pythonBuildObject2(value)
115-
key to buildObj
114+
key to getOrCreateVariable(PythonTreeModel(value, value.type))
116115
}.toMap()
117116
val listitems = objectNode.listitems.map {
118-
val buildObj = pythonBuildObject2(it)
119-
buildObj
117+
getOrCreateVariable(PythonTreeModel(it, it.type))
120118
}
121119
val dictitems = objectNode.dictitems.map { (key, value) ->
122-
val keyObj = pythonBuildObject2(key)
123-
val valueObj = pythonBuildObject2(value)
120+
val keyObj = getOrCreateVariable(PythonTreeModel(key, key.type))
121+
val valueObj = getOrCreateVariable(PythonTreeModel(value, value.type))
124122
keyObj to valueObj
125123
}
126124

0 commit comments

Comments
 (0)