Skip to content

Commit

Permalink
[js] Start of nqp::unicmp_s implementation
Browse files Browse the repository at this point in the history
Doesn't pass all tests yet.
  • Loading branch information
pmurias committed Nov 22, 2017
1 parent e1a2233 commit 6f15a2d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/vm/js/Operations.nqp
Expand Up @@ -1792,6 +1792,8 @@ class QAST::OperationsJS {

add_simple_op('cpucores', $T_INT, []);

add_simple_op('unicmp_s', $T_INT, [$T_STR, $T_STR, $T_INT, $T_INT, $T_INT]);

method add_hll_unbox($hll, $type, $method_name) {
unless nqp::existskey(%hll_unbox, $hll) {
%hll_unbox{$hll} := nqp::hash();
Expand Down
13 changes: 13 additions & 0 deletions src/vm/js/nqp-runtime/core.js
Expand Up @@ -1533,6 +1533,19 @@ op.atomicinc_i = function(ctx, ref) {
return value;
};

op.unicmp_s = function(a, b, collationMode, language, code) {
if (language != 0 || code != 0) {
throw new NQPException('collation with a set language NYI');
}

if (collationMode != 85) {
throw new NQPException('collationMode NYI');
}

const result = a.localeCompare(b, 'ducet');
return (result < 0 ? -1 : (result > 0 ? 1 : 0));
};

const getrusage = require('qrusage');
op.getrusage = function() {
const usage = getrusage();
Expand Down

0 comments on commit 6f15a2d

Please sign in to comment.