diff options
author | bptato <nincsnevem662@gmail.com> | 2023-08-19 10:02:54 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-08-20 15:39:07 +0200 |
commit | 65ad7f9fc8b69140c050006fbe9ea1644bc283d8 (patch) | |
tree | b2e8b654c31ba6fe66992014c3eefeb0b731b3e2 /src/js/regex.nim | |
parent | 01dfb3abe8d3a282a127aafd34e55fff1ff9d2df (diff) | |
download | chawan-65ad7f9fc8b69140c050006fbe9ea1644bc283d8.tar.gz |
javascript: update Events, misc fixes & additions
Events: just implement the interfaces, no events are triggered yet. JS changes: * add LegacyUnforgeable * make consts enumerable * fix crash in isInstanceOf * fix destructor warnings * refactor registerType As a result, peakmem is now 1G+ on 1.6.14. It stays ~750M on 2.0.0. Hmm. Well, better upgrade to 2.0.0 I guess.
Diffstat (limited to 'src/js/regex.nim')
-rw-r--r-- | src/js/regex.nim | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/js/regex.nim b/src/js/regex.nim index eb6ef80f..d7371428 100644 --- a/src/js/regex.nim +++ b/src/js/regex.nim @@ -33,13 +33,21 @@ type var dummyRuntime = newJSRuntime() var dummyContext = dummyRuntime.newJSContextRaw() -proc `=destroy`*(regex: var Regex) = - if regex.bytecode != nil: - if regex.clone: - dealloc(regex.bytecode) - else: - dummyRuntime.js_free_rt(regex.bytecode) - regex.bytecode = nil +when NimMajor >= 2: + proc `=destroy`*(regex: Regex) = + if regex.bytecode != nil: + if regex.clone: + dealloc(regex.bytecode) + else: + dummyRuntime.js_free_rt(regex.bytecode) +else: + proc `=destroy`*(regex: var Regex) = + if regex.bytecode != nil: + if regex.clone: + dealloc(regex.bytecode) + else: + dummyRuntime.js_free_rt(regex.bytecode) + regex.bytecode = nil proc `=copy`*(dest: var Regex, source: Regex) = if dest.bytecode != source.bytecode: |