Skip to content

Commit 9c79d1f

Browse files
committed
Add nqp::isint/nqp::isnum/nqp::isstr for JVM.
1 parent adfa9c8 commit 9c79d1f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/vm/jvm/QAST/Compiler.nqp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,6 +1774,9 @@ QAST::OperationsJAST.map_classlib_core_op('shift_i', $TYPE_OPS, 'shift_i', [$RT_
17741774
QAST::OperationsJAST.map_classlib_core_op('shift_n', $TYPE_OPS, 'shift_n', [$RT_OBJ], $RT_NUM, :tc);
17751775
QAST::OperationsJAST.map_classlib_core_op('shift_s', $TYPE_OPS, 'shift_s', [$RT_OBJ], $RT_STR, :tc);
17761776
QAST::OperationsJAST.map_classlib_core_op('splice', $TYPE_OPS, 'splice', [$RT_OBJ, $RT_OBJ, $RT_INT, $RT_INT], $RT_OBJ, :tc);
1777+
QAST::OperationsJAST.map_classlib_core_op('isint', $TYPE_OPS, 'isint', [$RT_OBJ], $RT_INT, :tc);
1778+
QAST::OperationsJAST.map_classlib_core_op('isnum', $TYPE_OPS, 'isnum', [$RT_OBJ], $RT_INT, :tc);
1779+
QAST::OperationsJAST.map_classlib_core_op('isstr', $TYPE_OPS, 'isstr', [$RT_OBJ], $RT_INT, :tc);
17771780
QAST::OperationsJAST.map_classlib_core_op('islist', $TYPE_OPS, 'islist', [$RT_OBJ], $RT_INT, :tc);
17781781
QAST::OperationsJAST.map_classlib_core_op('ishash', $TYPE_OPS, 'ishash', [$RT_OBJ], $RT_INT, :tc);
17791782
QAST::OperationsJAST.map_classlib_core_op('iterator', $TYPE_OPS, 'iter', [$RT_OBJ], $RT_OBJ, :tc);

src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,18 @@ public static double unbox_n(SixModelObject obj, ThreadContext tc) {
14931493
public static String unbox_s(SixModelObject obj, ThreadContext tc) {
14941494
return obj.get_str(tc);
14951495
}
1496+
public static long isint(SixModelObject obj, ThreadContext tc) {
1497+
StorageSpec ss = obj.st.REPR.get_storage_spec(tc, obj.st);
1498+
return (ss.can_box & StorageSpec.CAN_BOX_INT) == 0 ? 0 : 1;
1499+
}
1500+
public static long isnum(SixModelObject obj, ThreadContext tc) {
1501+
StorageSpec ss = obj.st.REPR.get_storage_spec(tc, obj.st);
1502+
return (ss.can_box & StorageSpec.CAN_BOX_NUM) == 0 ? 0 : 1;
1503+
}
1504+
public static long isstr(SixModelObject obj, ThreadContext tc) {
1505+
StorageSpec ss = obj.st.REPR.get_storage_spec(tc, obj.st);
1506+
return (ss.can_box & StorageSpec.CAN_BOX_STR) == 0 ? 0 : 1;
1507+
}
14961508

14971509
/* Attribute operations. */
14981510
public static SixModelObject getattr(SixModelObject obj, SixModelObject ch, String name, ThreadContext tc) {

0 commit comments

Comments
 (0)