From 45ee4a337c9e33a8879afcac0f20f3c1052d24fc Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Sat, 17 Jan 2026 11:12:54 -0600 Subject: [PATCH] add not --- .cell/lock.toml | 6 ------ internal/engine.cm | 5 +++-- source/quickjs.c | 37 +++++++++++++++++++++++++++++++++++++ test.ce | 6 +++--- 4 files changed, 43 insertions(+), 11 deletions(-) delete mode 100644 .cell/lock.toml diff --git a/.cell/lock.toml b/.cell/lock.toml deleted file mode 100644 index ea5e875a..00000000 --- a/.cell/lock.toml +++ /dev/null @@ -1,6 +0,0 @@ -[modules] -[modules.extramath] -hash = "MCLZT3JABTAENS4WVXKGWJ7JPBLZER4YQ5VN2PE7ZD2Z4WYGTIMA====" -url = "https://gitea.pockle.world/john/extramath@master" -downloaded = "Monday June 2 12:07:20.42 PM -5 2025 AD" -commit = "84d81a19a8455bcf8dc494739e9e6d545df6ff2c" \ No newline at end of file diff --git a/internal/engine.cm b/internal/engine.cm index 0b15504e..e479c0c2 100644 --- a/internal/engine.cm +++ b/internal/engine.cm @@ -25,7 +25,7 @@ var ACTOR_EXT = '.ce' var load_internal = os.load_internal function use_embed(name) { - return load_internal(`js_${name}_use`) + return load_internal("js_" + name + "_use") } globalThis.logical = function(val1) @@ -54,9 +54,10 @@ globalThis.ends_with = function(str, suffix) { } var js = use_embed('js') -os.print(js) var fd = use_embed('fd') +os.print(fd) + // Get the shop path from HOME environment var home = os.getenv('HOME') || os.getenv('USERPROFILE') if (!home) { diff --git a/source/quickjs.c b/source/quickjs.c index c9687628..9f4015e3 100644 --- a/source/quickjs.c +++ b/source/quickjs.c @@ -30715,8 +30715,27 @@ static JSValue js_string_iterator_next(JSContext *ctx, JSValueConst this_val, } } +static JSValue js_string_concat(JSContext *ctx, JSValueConst this_val, + int argc, JSValueConst *argv) +{ + JSValue r; + int i; + + /* XXX: Use more efficient method */ + /* XXX: This method is OK if r has a single refcount */ + /* XXX: should use string_buffer? */ + r = JS_ToStringCheckObject(ctx, this_val); + for (i = 0; i < argc; i++) { + if (JS_IsException(r)) + break; + r = JS_ConcatString(ctx, r, JS_DupValue(ctx, argv[i])); + } + return r; +} + static const JSCFunctionListEntry js_string_proto_funcs[] = { JS_PROP_INT32_DEF("length", 0, JS_PROP_CONFIGURABLE ), + JS_CFUNC_DEF("concat", 1, js_string_concat), JS_CFUNC_MAGIC_DEF("indexOf", 1, js_string_indexOf, 0 ), JS_CFUNC_MAGIC_DEF("lastIndexOf", 1, js_string_indexOf, 1 ), JS_CFUNC_MAGIC_DEF("match", 1, js_string_match, JS_ATOM_Symbol_match ), @@ -33760,6 +33779,19 @@ static JSValue js_cell_modulo(JSContext *ctx, JSValueConst this_val, return JS_NewFloat64(ctx, result); } +/* not(bool) - negate a boolean value */ +static JSValue js_cell_not(JSContext *ctx, JSValueConst this_val, + int argc, JSValueConst *argv) +{ + if (argc < 1) + return JS_NULL; + + if (!JS_IsBool(argv[0])) + return JS_NULL; + + return JS_NewBool(ctx, !JS_ToBool(ctx, argv[0])); +} + /* neg(number) - negate a number */ static JSValue js_cell_neg(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) @@ -37158,6 +37190,11 @@ void JS_AddIntrinsicBaseObjects(JSContext *ctx) JS_NewCFunction(ctx, js_cell_neg, "neg", 1), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); + /* not(boolean) - logical not */ + JS_DefinePropertyValueStr(ctx, ctx->global_obj, "not", + JS_NewCFunction(ctx, js_cell_not, "not", 1), + JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE); + /* normalize(text) - Unicode normalize */ JS_DefinePropertyValueStr(ctx, ctx->global_obj, "normalize", JS_NewCFunction(ctx, js_cell_normalize, "normalize", 1), diff --git a/test.ce b/test.ce index 50dfba6f..6d7d73b7 100644 --- a/test.ce +++ b/test.ce @@ -376,18 +376,18 @@ if (all_pkgs) { // Run local first if we're in a valid package if (is_valid_package('.')) { all_results.push(run_tests(null, null)) - all_actor_tests = all_actor_tests.concat(collect_actor_tests(null, null)) + all_actor_tests = array(all_actor_tests, collect_actor_tests(null, null)) } // Then all packages in lock var packages = shop.list_packages() for (var i = 0; i < packages.length; i++) { all_results.push(run_tests(packages[i], null)) - all_actor_tests = all_actor_tests.concat(collect_actor_tests(packages[i], null)) + all_actor_tests = array(all_actor_tests, collect_actor_tests(packages[i], null)) } } else { all_results.push(run_tests(target_pkg, target_test)) - all_actor_tests = all_actor_tests.concat(collect_actor_tests(target_pkg, target_test)) + all_actor_tests = array(all_actor_tests, collect_actor_tests(target_pkg, target_test)) } // Spawn actor tests if any