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.

object literals

+39 -5
+1 -1
meson.build
··· 75 75 build_date = run_command('date', '+%Y-%m-%d', check: true).stdout().strip() 76 76 77 77 version_conf = configuration_data() 78 - version_conf.set('ANT_VERSION', '0.1.3.18') 78 + version_conf.set('ANT_VERSION', '0.1.3.19') 79 79 version_conf.set('ANT_GIT_HASH', git_hash) 80 80 version_conf.set('ANT_BUILD_DATE', build_date) 81 81
+38 -4
src/ant.c
··· 378 378 static bool is_err(jsval_t v) { return vtype(v) == T_ERR; } 379 379 static bool is_unary(uint8_t tok) { return (tok >= TOK_POSTINC && tok <= TOK_UMINUS) || tok == TOK_NOT || tok == TOK_TILDA || tok == TOK_TYPEOF || tok == TOK_VOID; } 380 380 static bool is_assign(uint8_t tok) { return (tok >= TOK_ASSIGN && tok <= TOK_OR_ASSIGN); } 381 + static bool is_keyword_propname(uint8_t tok) { return (tok >= TOK_ASYNC && tok <= TOK_GLOBAL_THIS) || tok == TOK_TYPEOF; } 381 382 382 383 static uint32_t js_to_uint32(double d) { 383 384 if (!isfinite(d) || d == 0) return 0; ··· 6522 6523 if (next(js) != TOK_RBRACKET) { 6523 6524 return js_mkerr_typed(js, JS_ERR_SYNTAX, "] expected after computed property name"); 6524 6525 } 6526 + } else if (is_keyword_propname(js->tok)) { 6527 + id_off = js->toff; 6528 + id_len = js->tlen; 6529 + if (exe) key = js_mkstr(js, js->code + js->toff, js->tlen); 6525 6530 } else { 6526 6531 return js_mkerr_typed(js, JS_ERR_SYNTAX, "parse error"); 6527 6532 } ··· 6920 6925 case TOK_LBRACKET: return js_arr_or_destruct(js); 6921 6926 case TOK_DIV: return js_regex_literal(js); 6922 6927 case TOK_CLASS: return js_class_expr(js, true); 6923 - case TOK_FUNC: return js_func_literal(js, false); 6928 + case TOK_FUNC: { 6929 + uint8_t la = lookahead(js); 6930 + if (la != TOK_LPAREN && la != TOK_IDENTIFIER) { 6931 + return mkcoderef((jsoff_t) js->toff, (jsoff_t) js->tlen); 6932 + } 6933 + return js_func_literal(js, false); 6934 + } 6924 6935 case TOK_ASYNC: { 6925 6936 js->consumed = 1; 6926 6937 uint8_t next_tok = next(js); ··· 7055 7066 case TOK_IDENTIFIER: 7056 7067 case TOK_CATCH: 7057 7068 case TOK_TRY: 7058 - case TOK_FINALLY: return mkcoderef((jsoff_t) js->toff, (jsoff_t) js->tlen); 7069 + case TOK_FINALLY: 7070 + case TOK_IF: 7071 + case TOK_ELSE: 7072 + case TOK_WHILE: 7073 + case TOK_DO: 7074 + case TOK_RETURN: 7075 + case TOK_BREAK: 7076 + case TOK_CONTINUE: 7077 + case TOK_VAR: 7078 + case TOK_NEW: 7079 + case TOK_THROW: 7080 + case TOK_SWITCH: 7081 + case TOK_CASE: 7082 + case TOK_DEFAULT: 7083 + case TOK_INSTANCEOF: 7084 + case TOK_IN: 7085 + case TOK_DEBUGGER: return mkcoderef((jsoff_t) js->toff, (jsoff_t) js->tlen); 7059 7086 7060 7087 default: return js_mkerr_typed(js, JS_ERR_SYNTAX, "bad expr"); 7061 7088 } ··· 7293 7320 } else { 7294 7321 obj = resolveprop(js, res); 7295 7322 } 7323 + jsval_t prop_name; 7324 + uint8_t nxt = next(js); 7325 + if (nxt == TOK_IDENTIFIER || is_keyword_propname(nxt)) { 7326 + js->consumed = 1; 7327 + prop_name = mkcoderef((jsoff_t) js->toff, (jsoff_t) js->tlen); 7328 + } else { 7329 + prop_name = js_group(js); 7330 + } 7296 7331 if (op == TOK_OPTIONAL_CHAIN && (vtype(obj) == T_NULL || vtype(obj) == T_UNDEF)) { 7297 - js_group(js); 7298 7332 res = js_mkundef(); 7299 7333 } else { 7300 - res = do_op(js, op, res, js_group(js)); 7334 + res = do_op(js, op, res, prop_name); 7301 7335 } 7302 7336 } else if (js->tok == TOK_LBRACKET) { 7303 7337 js->consumed = 1;