@@ -3455,6 +3455,8 @@ const char *JS_AtomToCString(JSContext *ctx, JSAtom atom)
3455
3455
return cstr;
3456
3456
}
3457
3457
3458
+ #ifndef QJS_DISABLE_PARSER
3459
+
3458
3460
/* return a string atom containing name concatenated with str1 */
3459
3461
/* `str1` may be pure ASCII or UTF-8 encoded */
3460
3462
// TODO(chqrlie): use string concatenation instead of UTF-8 conversion
@@ -3497,6 +3499,8 @@ static JSAtom js_atom_concat_num(JSContext *ctx, JSAtom name, uint32_t n)
3497
3499
return js_atom_concat_str(ctx, name, buf);
3498
3500
}
3499
3501
3502
+ #endif // QJS_DISABLE_PARSER
3503
+
3500
3504
static inline bool JS_IsEmptyString(JSValueConst v)
3501
3505
{
3502
3506
return JS_VALUE_GET_TAG(v) == JS_TAG_STRING && JS_VALUE_GET_STRING(v)->len == 0;
@@ -20372,8 +20376,6 @@ static const JSOpCode opcode_info[OP_COUNT + (OP_TEMP_END - OP_TEMP_START)] = {
20372
20376
opcode_info[(op) >= OP_TEMP_START ? \
20373
20377
(op) + (OP_TEMP_END - OP_TEMP_START) : (op)]
20374
20378
20375
- static __exception int next_token(JSParseState *s);
20376
-
20377
20379
static void free_token(JSParseState *s, JSToken *token)
20378
20380
{
20379
20381
switch(token->val) {
@@ -20480,6 +20482,10 @@ int JS_PRINTF_FORMAT_ATTR(2, 3) js_parse_error(JSParseState *s, JS_PRINTF_FORMAT
20480
20482
return -1;
20481
20483
}
20482
20484
20485
+ #ifndef QJS_DISABLE_PARSER
20486
+
20487
+ static __exception int next_token(JSParseState *s);
20488
+
20483
20489
static int js_parse_expect(JSParseState *s, int tok)
20484
20490
{
20485
20491
char buf[ATOM_GET_STR_BUF_SIZE];
@@ -20824,6 +20830,8 @@ static __exception int js_parse_regexp(JSParseState *s)
20824
20830
return -1;
20825
20831
}
20826
20832
20833
+ #endif // QJS_DISABLE_PARSER
20834
+
20827
20835
static __exception int ident_realloc(JSContext *ctx, char **pbuf, size_t *psize,
20828
20836
char *static_buf)
20829
20837
{
@@ -20851,6 +20859,8 @@ static __exception int ident_realloc(JSContext *ctx, char **pbuf, size_t *psize,
20851
20859
return 0;
20852
20860
}
20853
20861
20862
+ #ifndef QJS_DISABLE_PARSER
20863
+
20854
20864
/* convert a TOK_IDENT to a keyword when needed */
20855
20865
static void update_token_ident(JSParseState *s)
20856
20866
{
@@ -21425,6 +21435,8 @@ static __exception int next_token(JSParseState *s)
21425
21435
return -1;
21426
21436
}
21427
21437
21438
+ #endif // QJS_DISABLE_PARSER
21439
+
21428
21440
static int json_parse_error(JSParseState *s, const uint8_t *curp, const char *msg)
21429
21441
{
21430
21442
const uint8_t *p, *line_start;
@@ -21725,6 +21737,8 @@ static __exception int json_next_token(JSParseState *s)
21725
21737
return -1;
21726
21738
}
21727
21739
21740
+ #ifndef QJS_DISABLE_PARSER
21741
+
21728
21742
/* only used for ':' and '=>', 'let' or 'function' look-ahead. *pp is
21729
21743
only set if TOK_IMPORT is returned */
21730
21744
/* XXX: handle all unicode cases */
@@ -27641,6 +27655,8 @@ static __exception int js_parse_statement_or_decl(JSParseState *s,
27641
27655
return -1;
27642
27656
}
27643
27657
27658
+ #endif // QJS_DISABLE_PARSER
27659
+
27644
27660
/* 'name' is freed */
27645
27661
static JSModuleDef *js_new_module_def(JSContext *ctx, JSAtom name)
27646
27662
{
@@ -27726,6 +27742,8 @@ static void js_free_module_def(JSContext *ctx, JSModuleDef *m)
27726
27742
js_free(ctx, m);
27727
27743
}
27728
27744
27745
+ #ifndef QJS_DISABLE_PARSER
27746
+
27729
27747
static int add_req_module_entry(JSContext *ctx, JSModuleDef *m,
27730
27748
JSAtom module_name)
27731
27749
{
@@ -27750,6 +27768,8 @@ static int add_req_module_entry(JSContext *ctx, JSModuleDef *m,
27750
27768
return i;
27751
27769
}
27752
27770
27771
+ #endif // QJS_DISABLE_PARSER
27772
+
27753
27773
static JSExportEntry *find_export_entry(JSContext *ctx, const JSModuleDef *m,
27754
27774
JSAtom export_name)
27755
27775
{
@@ -27794,6 +27814,8 @@ static JSExportEntry *add_export_entry2(JSContext *ctx,
27794
27814
return me;
27795
27815
}
27796
27816
27817
+ #ifndef QJS_DISABLE_PARSER
27818
+
27797
27819
static JSExportEntry *add_export_entry(JSParseState *s, JSModuleDef *m,
27798
27820
JSAtom local_name, JSAtom export_name,
27799
27821
JSExportTypeEnum export_type)
@@ -27817,6 +27839,8 @@ static int add_star_export_entry(JSContext *ctx, JSModuleDef *m,
27817
27839
return 0;
27818
27840
}
27819
27841
27842
+ #endif // QJS_DISABLE_PARSER
27843
+
27820
27844
/* create a C module */
27821
27845
/* `name_str` may be pure ASCII or UTF-8 encoded */
27822
27846
JSModuleDef *JS_NewCModule(JSContext *ctx, const char *name_str,
@@ -29465,6 +29489,8 @@ static JSValue js_evaluate_module(JSContext *ctx, JSModuleDef *m)
29465
29489
return js_dup(m->promise);
29466
29490
}
29467
29491
29492
+ #ifndef QJS_DISABLE_PARSER
29493
+
29468
29494
static __exception JSAtom js_parse_from_clause(JSParseState *s)
29469
29495
{
29470
29496
JSAtom module_name;
@@ -29904,6 +29930,8 @@ static JSFunctionDef *js_new_function_def(JSContext *ctx,
29904
29930
return fd;
29905
29931
}
29906
29932
29933
+ #endif // QJS_DISABLE_PARSER
29934
+
29907
29935
static void free_bytecode_atoms(JSRuntime *rt,
29908
29936
const uint8_t *bc_buf, int bc_len,
29909
29937
bool use_short_opcodes)
@@ -29937,6 +29965,8 @@ static void free_bytecode_atoms(JSRuntime *rt,
29937
29965
}
29938
29966
}
29939
29967
29968
+ #ifndef QJS_DISABLE_PARSER
29969
+
29940
29970
static void js_free_function_def(JSContext *ctx, JSFunctionDef *fd)
29941
29971
{
29942
29972
int i;
@@ -29999,6 +30029,8 @@ static void js_free_function_def(JSContext *ctx, JSFunctionDef *fd)
29999
30029
js_free(ctx, fd);
30000
30030
}
30001
30031
30032
+ #endif // QJS_DISABLE_PARSER
30033
+
30002
30034
#ifdef ENABLE_DUMPS // JS_DUMP_BYTECODE_*
30003
30035
static const char *skip_lines(const char *p, int n) {
30004
30036
while (p && n-- > 0 && *p) {
@@ -30455,6 +30487,8 @@ static __maybe_unused void js_dump_function_bytecode(JSContext *ctx, JSFunctionB
30455
30487
}
30456
30488
#endif
30457
30489
30490
+ #ifndef QJS_DISABLE_PARSER
30491
+
30458
30492
static int add_closure_var(JSContext *ctx, JSFunctionDef *s,
30459
30493
bool is_local, bool is_arg,
30460
30494
int var_idx, JSAtom var_name,
@@ -33762,8 +33796,10 @@ static JSValue js_create_function(JSContext *ctx, JSFunctionDef *fd)
33762
33796
are used to compile the eval and they must be ordered by scope,
33763
33797
so it is necessary to create the closure variables before any
33764
33798
other variable lookup is done. */
33799
+ #ifndef QJS_DISABLE_PARSER
33765
33800
if (fd->has_eval_call)
33766
33801
add_eval_variables(ctx, fd);
33802
+ #endif // QJS_DISABLE_PARSER
33767
33803
33768
33804
/* add the module global variables in the closure */
33769
33805
if (fd->module) {
@@ -33922,6 +33958,8 @@ static JSValue js_create_function(JSContext *ctx, JSFunctionDef *fd)
33922
33958
return JS_EXCEPTION;
33923
33959
}
33924
33960
33961
+ #endif // QJS_DISABLE_PARSER
33962
+
33925
33963
static void free_function_bytecode(JSRuntime *rt, JSFunctionBytecode *b)
33926
33964
{
33927
33965
int i;
@@ -33956,6 +33994,8 @@ static void free_function_bytecode(JSRuntime *rt, JSFunctionBytecode *b)
33956
33994
}
33957
33995
}
33958
33996
33997
+ #ifndef QJS_DISABLE_PARSER
33998
+
33959
33999
static __exception int js_parse_directives(JSParseState *s)
33960
34000
{
33961
34001
char str[20];
@@ -34767,6 +34807,8 @@ static __exception int js_parse_program(JSParseState *s)
34767
34807
return 0;
34768
34808
}
34769
34809
34810
+ #endif // QJS_DISABLE_PARSER
34811
+
34770
34812
static void js_parse_init(JSContext *ctx, JSParseState *s,
34771
34813
const char *input, size_t input_len,
34772
34814
const char *filename, int line)
@@ -34822,6 +34864,8 @@ JSValue JS_EvalFunction(JSContext *ctx, JSValue fun_obj)
34822
34864
return JS_EvalFunctionInternal(ctx, fun_obj, ctx->global_obj, NULL, NULL);
34823
34865
}
34824
34866
34867
+ #ifndef QJS_DISABLE_PARSER
34868
+
34825
34869
/* 'input' must be zero terminated i.e. input[input_len] = '\0'. */
34826
34870
/* `export_name` and `input` may be pure ASCII or UTF-8 encoded */
34827
34871
static JSValue __JS_EvalInternal(JSContext *ctx, JSValueConst this_obj,
@@ -34938,6 +34982,8 @@ static JSValue __JS_EvalInternal(JSContext *ctx, JSValueConst this_obj,
34938
34982
return JS_EXCEPTION;
34939
34983
}
34940
34984
34985
+ #endif // QJS_DISABLE_PARSER
34986
+
34941
34987
/* the indirection is needed to make 'eval' optional */
34942
34988
static JSValue JS_EvalInternal(JSContext *ctx, JSValueConst this_obj,
34943
34989
const char *input, size_t input_len,
@@ -52859,7 +52905,9 @@ void JS_AddIntrinsicDate(JSContext *ctx)
52859
52905
52860
52906
void JS_AddIntrinsicEval(JSContext *ctx)
52861
52907
{
52908
+ #ifndef QJS_DISABLE_PARSER
52862
52909
ctx->eval_internal = __JS_EvalInternal;
52910
+ #endif // QJS_DISABLE_PARSER
52863
52911
}
52864
52912
52865
52913
/* BigInt */
@@ -57526,6 +57574,7 @@ static void _JS_AddIntrinsicCallSite(JSContext *ctx)
57526
57574
57527
57575
bool JS_DetectModule(const char *input, size_t input_len)
57528
57576
{
57577
+ #ifndef QJS_DISABLE_PARSER
57529
57578
JSRuntime *rt;
57530
57579
JSContext *ctx;
57531
57580
JSValue val;
@@ -57554,6 +57603,9 @@ bool JS_DetectModule(const char *input, size_t input_len)
57554
57603
JS_FreeContext(ctx);
57555
57604
JS_FreeRuntime(rt);
57556
57605
return is_module;
57606
+ #else
57607
+ return false;
57608
+ #endif // QJS_DISABLE_PARSER
57557
57609
}
57558
57610
57559
57611
uintptr_t js_std_cmd(int cmd, ...) {
0 commit comments