Skip to content

Commit e611352

Browse files
committed
fixes in BuiltinFunctionRootNode
1 parent 9bbbc46 commit e611352

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/function/BuiltinFunctionRootNode.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public BuiltinVarArgsCallNode(PythonVarargsBuiltinNode node, PNode arg1, PNode a
132132
this.node = node;
133133
this.arg1 = arg1;
134134
this.arg2 = arg2;
135-
this.arg2 = arg3;
135+
this.arg3 = arg3;
136136
}
137137

138138
@Override
@@ -204,17 +204,22 @@ public Object execute(VirtualFrame frame) {
204204
CompilerDirectives.transferToInterpreterAndInvalidate();
205205
PNode[] argumentsList = createArgumentsList(builtin);
206206
if (PythonBuiltinNode.class.isAssignableFrom(factory.getNodeClass())) {
207-
body = new BuiltinAnyCallNode((PythonBuiltinNode) factory.createNode((Object) argumentsList));
207+
body = insert(new BuiltinAnyCallNode((PythonBuiltinNode) factory.createNode((Object) argumentsList)));
208208
} else {
209209
PythonBuiltinBaseNode node = factory.createNode();
210210
if (node instanceof PythonUnaryBuiltinNode) {
211-
body = new BuiltinUnaryCallNode((PythonUnaryBuiltinNode) node, argumentsList[0]);
211+
assert argumentsList.length == 1 : "mismatch in number of arguments for " + node.getClass().getSimpleName();
212+
body = insert(new BuiltinUnaryCallNode((PythonUnaryBuiltinNode) node, argumentsList[0]));
212213
} else if (node instanceof PythonBinaryBuiltinNode) {
213-
body = new BuiltinBinaryCallNode((PythonBinaryBuiltinNode) node, argumentsList[0], argumentsList[1]);
214+
assert argumentsList.length == 2 : "mismatch in number of arguments for " + node.getClass().getSimpleName();
215+
body = insert(new BuiltinBinaryCallNode((PythonBinaryBuiltinNode) node, argumentsList[0], argumentsList[1]));
214216
} else if (node instanceof PythonTernaryBuiltinNode) {
215-
body = new BuiltinTernaryCallNode((PythonTernaryBuiltinNode) node, argumentsList[0], argumentsList[1], argumentsList[2]);
217+
assert argumentsList.length == 3 : "mismatch in number of arguments for " + node.getClass().getSimpleName();
218+
body = insert(new BuiltinTernaryCallNode((PythonTernaryBuiltinNode) node, argumentsList[0], argumentsList[1], argumentsList[2]));
216219
} else if (node instanceof PythonVarargsBuiltinNode) {
217-
body = new BuiltinVarArgsCallNode((PythonVarargsBuiltinNode) node, argumentsList[0], argumentsList[1], argumentsList[2]);
220+
assert argumentsList.length == 3 : "mismatch in number of arguments for " + node.getClass().getSimpleName();
221+
assert argumentsList[0] != null && argumentsList[1] != null && argumentsList[2] != null;
222+
body = insert(new BuiltinVarArgsCallNode((PythonVarargsBuiltinNode) node, argumentsList[0], argumentsList[1], argumentsList[2]));
218223
} else {
219224
throw new RuntimeException("unexpected builtin node type: " + node.getClass());
220225
}

0 commit comments

Comments
 (0)