Skip to content

Commit c247728

Browse files
committed
[js] Implement nqp::getstrfromname and nqp::codepointfromname.
1 parent e5872af commit c247728

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/vm/js/Operations.nqp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,9 @@ class QAST::OperationsJS {
15971597

15981598
add_simple_op('sleep', $T_NUM, [$T_NUM], :side_effects);
15991599

1600+
add_simple_op('getstrfromname', $T_STR, [$T_STR]);
1601+
add_simple_op('codepointfromname', $T_INT, [$T_STR]);
1602+
16001603
add_op('js', sub ($comp, $node, :$want) {
16011604
my %want_char := nqp::hash($T_INT, 'I', $T_NUM, 'N', $T_STR, 'S', $T_VOID, 'v');
16021605
my sub want($node, $type) {

src/vm/js/nqp-runtime/core.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,16 @@ op.tclc = function(string) {
10031003
return first + lower.toLowerCase();
10041004
};
10051005

1006+
op.getstrfromname = function(name) {
1007+
let unicharadata = require('unicharadata');
1008+
return unicharadata.lookup(name);
1009+
};
1010+
1011+
op.codepointfromname = function(name) {
1012+
let unicharadata = require('unicharadata');
1013+
return unicharadata.lookup(name).codePointAt(0);
1014+
};
1015+
10061016
op.islist = function(list) {
10071017
return (list._STable && list._STable.REPR instanceof reprs.VMArray) ? 1 : 0;
10081018
};

0 commit comments

Comments
 (0)