Skip to content

Commit 48ccee7

Browse files
committed
Convert NoValue to NULL handle
1 parent ffff281 commit 48ccee7

File tree

1 file changed

+14
-1
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy

1 file changed

+14
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyNodes.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,15 +1351,28 @@ static Object doGeneric(@SuppressWarnings("unused") GraalHPyContext hpyContext,
13511351
}
13521352

13531353
@GenerateUncached
1354+
@ImportStatic(PGuards.class)
13541355
public abstract static class HPyAsHandleNode extends CExtToNativeNode {
13551356

13561357
// TODO(fa) implement handles for primitives that avoid boxing
13571358

1358-
@Specialization
1359+
@Specialization(guards = "isNoValue(object)")
1360+
static GraalHPyHandle doNoValue(GraalHPyContext hpyContext, @SuppressWarnings("unused") PNone object) {
1361+
return hpyContext.getNullHandle();
1362+
}
1363+
1364+
@Specialization(guards = "!isNoValue(object)")
13591365
static GraalHPyHandle doObject(@SuppressWarnings("unused") CExtContext hpyContext, Object object) {
13601366
return new GraalHPyHandle(object);
13611367
}
13621368

1369+
@Specialization(replaces = {"doNoValue", "doObject"})
1370+
static GraalHPyHandle doGeneric(GraalHPyContext hpyContext, Object object) {
1371+
if (PGuards.isNoValue(object)) {
1372+
return hpyContext.getNullHandle();
1373+
}
1374+
return new GraalHPyHandle(object);
1375+
}
13631376
}
13641377

13651378
/**

0 commit comments

Comments
 (0)