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.

make it dry

+2 -83
+1 -1
meson.build
··· 67 67 build_date = run_command('date', '+%Y-%m-%d', check: true).stdout().strip() 68 68 69 69 version_conf = configuration_data() 70 - version_conf.set('ANT_VERSION', '0.0.6.25') 70 + version_conf.set('ANT_VERSION', '0.0.6.26') 71 71 version_conf.set('ANT_GIT_HASH', git_hash) 72 72 version_conf.set('ANT_BUILD_DATE', build_date) 73 73
+1 -82
src/ant.c
··· 1890 1890 closure_scope = resolveprop(js, mkval(T_PROP, scope_off)); 1891 1891 } 1892 1892 1893 - jsoff_t parent_scope_offset; 1894 - if (vtype(closure_scope) == T_OBJ) { 1895 - parent_scope_offset = (jsoff_t) vdata(closure_scope); 1896 - } else { 1897 - parent_scope_offset = (jsoff_t) vdata(js->scope); 1898 - } 1899 - 1900 - jsval_t saved_scope = js->scope; 1901 - jsval_t function_scope = mkobj(js, parent_scope_offset); 1902 - js->scope = function_scope; 1903 - 1904 - jsoff_t fnpos = 1; 1905 - int arg_idx = 0; 1906 - bool has_rest = false; 1907 - jsoff_t rest_param_start = 0, rest_param_len = 0; 1908 - 1909 - while (fnpos < fnlen) { 1910 - fnpos = skiptonext(fn, fnlen, fnpos); 1911 - if (fnpos < fnlen && fn[fnpos] == ')') break; 1912 - 1913 - bool is_rest = false; 1914 - if (fnpos + 3 < fnlen && fn[fnpos] == '.' && fn[fnpos + 1] == '.' && fn[fnpos + 2] == '.') { 1915 - is_rest = true; 1916 - has_rest = true; 1917 - fnpos += 3; 1918 - fnpos = skiptonext(fn, fnlen, fnpos); 1919 - } 1920 - 1921 - jsoff_t identlen = 0; 1922 - uint8_t tok = parseident(&fn[fnpos], fnlen - fnpos, &identlen); 1923 - if (tok != TOK_IDENTIFIER) break; 1924 - 1925 - if (is_rest) { 1926 - rest_param_start = fnpos; 1927 - rest_param_len = identlen; 1928 - fnpos = skiptonext(fn, fnlen, fnpos + identlen); 1929 - break; 1930 - } 1931 - 1932 - jsval_t v = arg_idx < nargs ? args[arg_idx] : js_mkundef(); 1933 - setprop(js, function_scope, js_mkstr(js, &fn[fnpos], identlen), v); 1934 - arg_idx++; 1935 - fnpos = skiptonext(fn, fnlen, fnpos + identlen); 1936 - if (fnpos < fnlen && fn[fnpos] == ',') fnpos++; 1937 - } 1938 - 1939 - if (has_rest && rest_param_len > 0) { 1940 - jsval_t rest_array = mkarr(js); 1941 - if (!is_err(rest_array)) { 1942 - jsoff_t idx = 0; 1943 - while (arg_idx < nargs) { 1944 - char idxstr[16]; 1945 - snprintf(idxstr, sizeof(idxstr), "%u", (unsigned) idx); 1946 - jsval_t key = js_mkstr(js, idxstr, strlen(idxstr)); 1947 - setprop(js, rest_array, key, args[arg_idx]); 1948 - idx++; 1949 - arg_idx++; 1950 - } 1951 - jsval_t len_key = js_mkstr(js, "length", 6); 1952 - setprop(js, rest_array, len_key, tov((double) idx)); 1953 - rest_array = mkval(T_ARR, vdata(rest_array)); 1954 - setprop(js, function_scope, js_mkstr(js, &fn[rest_param_start], rest_param_len), rest_array); 1955 - } 1956 - } 1957 - 1958 - if (fnpos < fnlen && fn[fnpos] == ')') fnpos++; 1959 - fnpos = skiptonext(fn, fnlen, fnpos); 1960 - if (fnpos < fnlen && fn[fnpos] == '{') fnpos++; 1961 - size_t body_len = fnlen - fnpos - 1; 1962 - 1963 - jsval_t saved_this = js->this_val; 1964 - jsval_t target_this = peek_this(); 1965 - js->this_val = target_this; 1966 - js->flags = F_CALL; 1967 - 1968 - jsval_t res = js_eval(js, &fn[fnpos], body_len); 1969 - if (!is_err(res) && !(js->flags & F_RETURN)) res = js_mkundef(); 1970 - 1971 - js->this_val = saved_this; 1972 - js->scope = saved_scope; 1973 - 1974 - return res; 1893 + return call_js_code_with_args(js, fn, fnlen, closure_scope, args, nargs); 1975 1894 } 1976 1895 1977 1896 static jsval_t call_js_code_with_args(struct js *js, const char *fn, jsoff_t fnlen, jsval_t closure_scope, jsval_t *args, int nargs) {