MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add loop block support to for loop

+39 -26
+1
libant/meson.build
··· 1 1 project('libant', 'c', default_options: [ 2 + 'buildtype=release', 2 3 'optimization=2', 3 4 'c_std=gnu23', 4 5 'default_library=static',
+4 -4
maidfile.toml
··· 2 2 path = "build" 3 3 script = "meson compile" 4 4 5 - [tasks.clean] 5 + [tasks.strip] 6 6 path = "build" 7 - script = "meson clean" 7 + script = "strip ant" 8 8 9 9 [tasks.download] 10 10 script = [".github/download.sh", "open .github/artifacts"] ··· 37 37 '''] 38 38 39 39 [tasks.install] 40 - script = ["maid build -q", ''' 40 + script = ["maid build -q", "maid strip", ''' 41 41 bash -c 'which ant && cp ./build/ant "$(which ant)" || 42 42 { mkdir -p ~/.local/bin && cp ./build/ant ~/.local/bin/; }' 43 43 '''] ··· 45 45 [tasks.debug] 46 46 script = ['meson subprojects download', ''' 47 47 bash -c 'CC="ccache $(which clang)" \ 48 - meson setup build --wipe -Doptimization=0 -Db_lto=false -Dstrip=false -Db_lundef=false -Dunity=off -Ddebug=true' 48 + meson setup build --wipe --buildtype=debug -Doptimization=0 -Db_lto=false -Dstrip=false -Db_lundef=false -Dunity=off' 49 49 '''] 50 50 51 51 [tasks.embed_example]
+1
meson.build
··· 1 1 project('ant', 'c', default_options: [ 2 + 'buildtype=release', 2 3 'optimization=2', 3 4 'c_std=gnu23', 4 5 'default_library=static',
-7
meson/deps/meson.build
··· 16 16 17 17 libsodium_dep = dependency('libsodium', required: true, static: is_static) 18 18 19 - # Platform-specific dependencies 20 19 if host_machine.system() == 'windows' 21 20 uuid_dep = cc.find_library('rpcrt4', required: true) 22 21 secur32_dep = cc.find_library('secur32', required: true) ··· 33 32 win_deps = [] 34 33 endif 35 34 36 - # llhttp 37 35 llhttp = dependency('llhttp', static: true, required: false) 38 36 if not llhttp.found() 39 37 llhttp = dependency('llhttp', method: 'cmake', modules: ['llhttp::llhttp_static'], required: true) 40 38 endif 41 39 42 - # libuv subproject 43 40 libuv_sub = subproject('libuv', default_options: [ 44 41 'build_tests=false', 45 42 'build_benchmarks=false' 46 43 ]) 47 44 libuv_dep = libuv_sub.get_variable('libuv_dep') 48 45 49 - # CMake subproject options 50 46 tlsuv_opts = cmake.subproject_options() 51 47 bdwgc_opts = cmake.subproject_options() 52 48 ··· 86 82 tlsuv_dep = cmake.subproject('tlsuv', options: tlsuv_opts).dependency('tlsuv') 87 83 bdwgc_dep = cmake.subproject('bdwgc', options: bdwgc_opts).dependency('gc') 88 84 89 - # Meson subprojects 90 85 pcre2_dep = subproject('pcre2').get_variable('libpcre2_8') 91 86 uthash_dep = subproject('uthash').get_variable('uthash_dep') 92 87 yyjson_dep = subproject('yyjson').get_variable('yyjson_dep') ··· 103 98 'tests=false' 104 99 ]).get_variable('ffi_dep') 105 100 106 - # Rust oxc parser 107 101 cargo = find_program('cargo', required: true) 108 102 cp = find_program('cp', required: true) 109 103 ··· 134 128 135 129 oxc_dep = declare_dependency(link_with: oxc_lib) 136 130 137 - # Collect all dependencies 138 131 ant_deps = [ 139 132 libffi_dep, bdwgc_dep, uuid_dep, 140 133 llhttp, pcre2_dep, libuv_dep,
+10 -5
meson/meson.build
··· 1 - # Shared build configuration 2 - # Variables expected from parent: 3 - # src_root - path to project root (for finding sources) 4 - # vendor_dir - name of vendor/subproject directory 5 - # is_static - whether to link dependencies statically 1 + message('Build configuration:') 2 + message(' buildtype: ' + get_option('buildtype')) 3 + message(' optimization: ' + get_option('optimization')) 4 + message(' debug: ' + (get_option('debug') ? 'true' : 'false')) 5 + message(' b_lto: ' + (get_option('b_lto') ? 'true' : 'false')) 6 + message(' strip: ' + (get_option('strip') ? 'true' : 'false')) 7 + 8 + if get_option('buildtype') != 'release' 9 + warning('Building in non-release mode. For best performance, use --buildtype=release') 10 + endif 6 11 7 12 subdir('deps') 8 13 subdir('version')
-3
meson/snapshot/meson.build
··· 1 - # Snapshot generation 2 - # Include with: subdir('meson') or subdir('../meson') 3 - 4 1 node = find_program('node', required: true) 5 2 6 3 core_files = run_command('sh', '-c',
-3
meson/version/meson.build
··· 1 - # Version and build configuration 2 - # Include with: subdir('meson') or subdir('../meson') 3 - 4 1 git_hash = run_command('git', 'rev-parse', '--short', 'HEAD', check: false).stdout().strip() 5 2 if git_hash == '' 6 3 git_hash = 'unknown'
+23 -4
src/ant.c
··· 10106 10106 10107 10107 static inline jsval_t loop_block_exec(struct js *js, loop_block_ctx_t *ctx) { 10108 10108 if (ctx->needs_scope) scope_clear_props(js, ctx->loop_scope); 10109 + 10110 + if (ctx->is_block) { 10111 + next(js); 10112 + return js_block(js, false); 10113 + } 10114 + 10109 10115 return js_block_or_stmt(js); 10110 10116 } 10111 10117 ··· 10161 10167 jsoff_t destructure_off; 10162 10168 jsoff_t destructure_len; 10163 10169 int marker_index; 10170 + loop_block_ctx_t loop_ctx; 10164 10171 } for_iter_ctx_t; 10165 10172 10166 10173 static jsval_t for_iter_bind_var(struct js *js, for_iter_ctx_t *ctx, jsval_t value) { ··· 10180 10187 js->pos = ctx->body_start; 10181 10188 js->consumed = 1; 10182 10189 js->flags = (ctx->flags & ~F_NOEXEC) | F_LOOP; 10183 - return js_block_or_stmt(js); 10190 + return loop_block_exec(js, &ctx->loop_ctx); 10184 10191 } 10185 10192 10186 10193 static inline bool for_iter_handle_continue(struct js *js, for_iter_ctx_t *ctx) { ··· 10532 10539 if (!expect(js, TOK_RPAREN, &res)) goto done; 10533 10540 10534 10541 jsoff_t body_start = js->pos; 10542 + loop_block_ctx_t forin_loop_ctx = {0}; 10543 + if (exe) loop_block_init(js, &forin_loop_ctx); 10535 10544 js->flags |= F_NOEXEC; 10536 10545 v = js_block_or_stmt(js); 10537 10546 if (is_err2(&v, &res)) goto done; ··· 10544 10553 var_name_off, var_name_len, 10545 10554 is_const_var, flags, 10546 10555 has_destructure, destructure_off, 10547 - destructure_len, marker_index 10556 + destructure_len, marker_index, 10557 + forin_loop_ctx 10548 10558 }; 10549 10559 res = for_in_iter_object(js, &ctx, obj); 10560 + loop_block_cleanup(js, &forin_loop_ctx); 10550 10561 if (is_err(res)) goto done; 10551 10562 if (js->flags & F_RETURN) goto done; 10552 10563 } ··· 10563 10574 if (!expect(js, TOK_RPAREN, &res)) goto done; 10564 10575 10565 10576 jsoff_t body_start = js->pos; 10577 + loop_block_ctx_t forof_loop_ctx = {0}; 10578 + if (exe) loop_block_init(js, &forof_loop_ctx); 10566 10579 js->flags |= F_NOEXEC; 10567 10580 v = js_block_or_stmt(js); 10568 10581 if (is_err2(&v, &res)) goto done; ··· 10576 10589 var_name_off, var_name_len, 10577 10590 is_const_var, flags, 10578 10591 has_destructure, destructure_off, 10579 - destructure_len, marker_index 10592 + destructure_len, marker_index, 10593 + forof_loop_ctx 10580 10594 }; 10581 10595 10582 10596 if (itype == T_ARR) res = for_of_iter_array(js, &ctx, iterable); ··· 10584 10598 else if (itype == T_OBJ) res = for_of_iter_object(js, &ctx, iterable); 10585 10599 else res = js_mkerr(js, "for-of requires iterable"); 10586 10600 10601 + loop_block_cleanup(js, &forof_loop_ctx); 10587 10602 if (is_err(res)) goto done; 10588 10603 if (js->flags & F_RETURN) goto done; 10589 10604 } ··· 10609 10624 } 10610 10625 if (!expect(js, TOK_RPAREN, &res)) goto done; 10611 10626 pos3 = js->pos; 10627 + loop_block_ctx_t loop_ctx = {0}; 10628 + if (exe) loop_block_init(js, &loop_ctx); 10612 10629 v = js_block_or_stmt(js); 10613 10630 if (is_err2(&v, &res)) goto done; 10614 10631 pos4 = js->pos; ··· 10636 10653 js->flags |= F_LOOP; 10637 10654 js->pos = pos3; 10638 10655 js->consumed = 1; 10639 - v = js_block_or_stmt(js); 10656 + v = loop_block_exec(js, &loop_ctx); 10640 10657 if (is_err2(&v, &res)) { 10641 10658 if (iter_scope) delscope(js); 10659 + loop_block_cleanup(js, &loop_ctx); 10642 10660 goto done; 10643 10661 } 10644 10662 ··· 10682 10700 if (is_err2(&v, &res)) goto done; 10683 10701 } 10684 10702 } 10703 + if (exe) loop_block_cleanup(js, &loop_ctx); 10685 10704 js->pos = pos4, js->tok = TOK_SEMICOLON, js->consumed = 0; 10686 10705 done: 10687 10706 if (use_label_stack && label_stack && utarray_len(label_stack) > 0) {