Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.interop.java/src/com/oracle/truffle/api/interop/java/JavaInterop.java @ 22529:2643b968c0c6
Send UNBOX message when a primitive type is requested for a TruffleObject value
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 06 Jan 2016 10:59:58 +0100 |
parents | 6ab540203853 |
children |
comparison
equal
deleted
inserted
replaced
22528:d725323deb6c | 22529:2643b968c0c6 |
---|---|
422 | 422 |
423 static boolean isPrimitive(Object attr) { | 423 static boolean isPrimitive(Object attr) { |
424 return toPrimitive(attr, null) != null; | 424 return toPrimitive(attr, null) != null; |
425 } | 425 } |
426 | 426 |
427 static Object toPrimitive(Object attr, Class<?> requestedType) { | 427 static Object toPrimitive(Object value, Class<?> requestedType) { |
428 if (attr instanceof TruffleObject) { | 428 Object attr; |
429 return null; | 429 if (value instanceof TruffleObject) { |
430 if (!Boolean.TRUE.equals(message(Message.IS_BOXED, value))) { | |
431 return null; | |
432 } | |
433 attr = message(Message.UNBOX, value); | |
434 } else { | |
435 attr = value; | |
430 } | 436 } |
431 if (attr instanceof Number) { | 437 if (attr instanceof Number) { |
432 if (requestedType == null) { | 438 if (requestedType == null) { |
433 return attr; | 439 return attr; |
434 } | 440 } |