From b673108852141eb3a31de9b6bb1751c8488c775f Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Mon, 11 Dec 2017 14:48:34 +0000 Subject: [PATCH] Add functions needed for switch ref-counting fix --- libs/core/core.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libs/core/core.cpp b/libs/core/core.cpp index a4d083da..2a026aa8 100644 --- a/libs/core/core.cpp +++ b/libs/core/core.cpp @@ -29,6 +29,15 @@ namespace String_ { return 0; } + //% + int compareDecr(StringData *s, StringData *that) { + int r = compare(s, that); + if (r == 0) + decr((uint32_t)that); + return r; + } + + //% int length(StringData *s) { return s->len; } @@ -112,6 +121,15 @@ namespace Number_ { int div(int x, int y) { return x / y; } //% int mod(int x, int y) { return x % y; } + + //% + bool eqDecr(int x, int y) { + if(x == y) { + decr(y); + return true; + } + return false; + } } namespace Math_ {