rm some functions
This commit is contained in:
@@ -294,7 +294,6 @@ typedef enum JSErrorEnum {
|
||||
#define __exception __attribute__ ((warn_unused_result))
|
||||
|
||||
/* Forward declaration for bytecode freeing */
|
||||
struct JSFunctionBytecode;
|
||||
|
||||
#define JS_VALUE_GET_ARRAY(v) ((JSArray *)chase (v))
|
||||
#define JS_VALUE_GET_OBJ(v) ((JSRecord *)chase (v))
|
||||
@@ -302,7 +301,7 @@ struct JSFunctionBytecode;
|
||||
#define JS_VALUE_GET_BLOB(v) ((JSBlob *)JS_VALUE_GET_PTR (v))
|
||||
#define JS_VALUE_GET_FUNCTION(v) ((JSFunction *)chase (v))
|
||||
#define JS_VALUE_GET_FRAME(v) ((JSFrame *)chase (v))
|
||||
#define JS_VALUE_GET_CODE(v) ((JSFunctionBytecode *)JS_VALUE_GET_PTR (v))
|
||||
#define JS_VALUE_GET_CODE(v) (JS_VALUE_GET_PTR (v))
|
||||
#define JS_VALUE_GET_STRING(v) ((JSText *)chase (v))
|
||||
|
||||
/* Compatibility: JS_TAG_STRING is an alias for text type checks */
|
||||
@@ -1237,11 +1236,6 @@ typedef struct JSFunction {
|
||||
uint8_t cproto;
|
||||
int16_t magic;
|
||||
} cfunc;
|
||||
struct {
|
||||
struct JSFunctionBytecode *function_bytecode;
|
||||
JSValue outer_frame; /* JSFrame JSValue, lexical parent for closures */
|
||||
JSValue env_record; /* stone record, module environment */
|
||||
} func;
|
||||
struct {
|
||||
JSCodeRegister *code; /* compiled register code (off-heap) */
|
||||
JSValue env_record; /* stone record, module environment */
|
||||
@@ -1250,107 +1244,12 @@ typedef struct JSFunction {
|
||||
} u;
|
||||
} JSFunction;
|
||||
|
||||
typedef struct JSClosureVar {
|
||||
uint8_t is_local : 1;
|
||||
uint8_t is_arg : 1;
|
||||
uint8_t is_const : 1;
|
||||
uint8_t is_lexical : 1;
|
||||
uint8_t var_kind : 4; /* see JSVarKindEnum */
|
||||
/* 8 bits available */
|
||||
uint16_t var_idx; /* is_local = TRUE: index to a normal variable of the
|
||||
parent function. otherwise: index to a closure
|
||||
variable of the parent function */
|
||||
JSValue var_name;
|
||||
} JSClosureVar;
|
||||
|
||||
#define ARG_SCOPE_INDEX 1
|
||||
#define ARG_SCOPE_END (-2)
|
||||
|
||||
typedef struct JSVarScope {
|
||||
int parent; /* index into fd->scopes of the enclosing scope */
|
||||
int first; /* index into fd->vars of the last variable in this scope */
|
||||
} JSVarScope;
|
||||
|
||||
typedef enum {
|
||||
/* XXX: add more variable kinds here instead of using bit fields */
|
||||
JS_VAR_NORMAL,
|
||||
JS_VAR_FUNCTION_DECL, /* lexical var with function declaration */
|
||||
JS_VAR_NEW_FUNCTION_DECL, /* lexical var with async/generator
|
||||
function declaration */
|
||||
JS_VAR_CATCH,
|
||||
JS_VAR_FUNCTION_NAME, /* function expression name */
|
||||
} JSVarKindEnum;
|
||||
|
||||
/* XXX: could use a different structure in bytecode functions to save
|
||||
memory */
|
||||
typedef struct JSVarDef {
|
||||
JSValue var_name;
|
||||
/* index into fd->scopes of this variable lexical scope */
|
||||
int scope_level;
|
||||
/* during compilation:
|
||||
- if scope_level = 0: scope in which the variable is defined
|
||||
- if scope_level != 0: index into fd->vars of the next
|
||||
variable in the same or enclosing lexical scope
|
||||
in a bytecode function:
|
||||
index into fd->vars of the next
|
||||
variable in the same or enclosing lexical scope
|
||||
*/
|
||||
int scope_next;
|
||||
uint8_t is_const : 1;
|
||||
uint8_t is_lexical : 1;
|
||||
uint8_t is_captured : 1;
|
||||
uint8_t var_kind : 4; /* see JSVarKindEnum */
|
||||
/* only used during compilation: function pool index for lexical
|
||||
variables with var_kind =
|
||||
JS_VAR_FUNCTION_DECL/JS_VAR_NEW_FUNCTION_DECL or scope level of
|
||||
the definition of the 'var' variables (they have scope_level =
|
||||
0) */
|
||||
int func_pool_idx : 24; /* only used during compilation : index in
|
||||
the constant pool for hoisted function
|
||||
definition */
|
||||
} JSVarDef;
|
||||
|
||||
/* for the encoding of the pc2line table */
|
||||
#define PC2LINE_BASE (-1)
|
||||
#define PC2LINE_RANGE 5
|
||||
#define PC2LINE_OP_FIRST 1
|
||||
#define PC2LINE_DIFF_PC_MAX ((255 - PC2LINE_OP_FIRST) / PC2LINE_RANGE)
|
||||
|
||||
typedef struct JSFunctionBytecode {
|
||||
objhdr_t header; /* must come first */
|
||||
uint8_t js_mode;
|
||||
uint8_t has_prototype : 1; /* true if a prototype field is necessary */
|
||||
uint8_t has_simple_parameter_list : 1;
|
||||
uint8_t func_kind : 2;
|
||||
uint8_t has_debug : 1;
|
||||
uint8_t read_only_bytecode : 1;
|
||||
uint8_t is_direct_or_indirect_eval
|
||||
: 1; /* used by JS_GetScriptOrModuleName() */
|
||||
/* XXX: 10 bits available */
|
||||
uint8_t *byte_code_buf; /* (self pointer) */
|
||||
int byte_code_len;
|
||||
JSValue func_name;
|
||||
JSVarDef *vardefs; /* arguments + local variables (arg_count + var_count)
|
||||
(self pointer) */
|
||||
JSClosureVar
|
||||
*closure_var; /* list of variables in the closure (self pointer) */
|
||||
uint16_t arg_count;
|
||||
uint16_t var_count;
|
||||
uint16_t defined_arg_count; /* for length function property */
|
||||
uint16_t stack_size; /* maximum stack size */
|
||||
JSValue *cpool; /* constant pool (self pointer) */
|
||||
int cpool_count;
|
||||
int closure_var_count;
|
||||
struct {
|
||||
/* debug info, move to separate structure to save memory? */
|
||||
JSValue filename;
|
||||
int source_len;
|
||||
int pc2line_len;
|
||||
uint8_t *pc2line_buf;
|
||||
char *source;
|
||||
} debug;
|
||||
} JSFunctionBytecode;
|
||||
|
||||
/* New simplified compiled unit structure for Phase 1+ simplification.
|
||||
Replaces JSFunctionBytecode with a simpler model:
|
||||
- No closure machinery (uses outer_frame chain at runtime)
|
||||
@@ -1390,10 +1289,6 @@ typedef struct JSCompiledUnit {
|
||||
Struct definitions are in quickjs.h
|
||||
============================================================ */
|
||||
|
||||
typedef struct JSProperty {
|
||||
JSValue value;
|
||||
} JSProperty;
|
||||
|
||||
#define JS_PROP_INITIAL_SIZE 2
|
||||
#define JS_PROP_INITIAL_HASH_SIZE 4 /* must be a power of two */
|
||||
#define JS_ARRAY_INITIAL_SIZE 2
|
||||
@@ -1421,14 +1316,9 @@ void js_dump_value_write (void *opaque, const char *buf, size_t len);
|
||||
void js_regexp_finalizer (JSRuntime *rt, JSValue val);
|
||||
JSValue js_new_function (JSContext *ctx, JSFunctionKind kind);
|
||||
|
||||
/* Forward declarations for intrinsics (now declared in quickjs.h) */
|
||||
|
||||
/* Forward declaration - helper to set cap in objhdr */
|
||||
static inline objhdr_t objhdr_set_cap56 (objhdr_t h, uint64_t cap);
|
||||
|
||||
/* JS_VALUE_GET_STRING is an alias for getting JSText from a string value */
|
||||
/* Note: Uses chase() for GC safety - already defined at line 293 */
|
||||
|
||||
/* JS_ThrowMemoryError is an alias for JS_ThrowOutOfMemory */
|
||||
#define JS_ThrowMemoryError(ctx) JS_ThrowOutOfMemory(ctx)
|
||||
|
||||
@@ -1611,118 +1501,6 @@ static inline __exception int js_poll_interrupts (JSContext *ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
/* === Token enum (shared by parser, tokenizer, AST) === */
|
||||
enum {
|
||||
TOK_NUMBER = -128,
|
||||
TOK_STRING,
|
||||
TOK_TEMPLATE,
|
||||
TOK_IDENT,
|
||||
TOK_REGEXP,
|
||||
/* warning: order matters (see js_parse_assign_expr) */
|
||||
TOK_MUL_ASSIGN,
|
||||
TOK_DIV_ASSIGN,
|
||||
TOK_MOD_ASSIGN,
|
||||
TOK_PLUS_ASSIGN,
|
||||
TOK_MINUS_ASSIGN,
|
||||
TOK_SHL_ASSIGN,
|
||||
TOK_SAR_ASSIGN,
|
||||
TOK_SHR_ASSIGN,
|
||||
TOK_AND_ASSIGN,
|
||||
TOK_XOR_ASSIGN,
|
||||
TOK_OR_ASSIGN,
|
||||
TOK_POW_ASSIGN,
|
||||
TOK_LAND_ASSIGN,
|
||||
TOK_LOR_ASSIGN,
|
||||
TOK_DEC,
|
||||
TOK_INC,
|
||||
TOK_SHL,
|
||||
TOK_SAR,
|
||||
TOK_SHR,
|
||||
TOK_LT,
|
||||
TOK_LTE,
|
||||
TOK_GT,
|
||||
TOK_GTE,
|
||||
TOK_EQ,
|
||||
TOK_STRICT_EQ,
|
||||
TOK_NEQ,
|
||||
TOK_STRICT_NEQ,
|
||||
TOK_LAND,
|
||||
TOK_LOR,
|
||||
TOK_POW,
|
||||
TOK_ARROW,
|
||||
TOK_ERROR,
|
||||
TOK_PRIVATE_NAME,
|
||||
TOK_EOF,
|
||||
/* whitespace/comment tokens for tokenizer */
|
||||
TOK_COMMENT,
|
||||
TOK_NEWLINE,
|
||||
TOK_SPACE,
|
||||
/* keywords: WARNING: same order as atoms */
|
||||
TOK_NULL, /* must be first */
|
||||
TOK_FALSE,
|
||||
TOK_TRUE,
|
||||
TOK_IF,
|
||||
TOK_ELSE,
|
||||
TOK_RETURN,
|
||||
TOK_GO,
|
||||
TOK_VAR,
|
||||
TOK_DEF,
|
||||
TOK_THIS,
|
||||
TOK_DELETE,
|
||||
TOK_IN,
|
||||
TOK_DO,
|
||||
TOK_WHILE,
|
||||
TOK_FOR,
|
||||
TOK_BREAK,
|
||||
TOK_CONTINUE,
|
||||
TOK_DISRUPT,
|
||||
TOK_DISRUPTION,
|
||||
TOK_FUNCTION,
|
||||
TOK_DEBUGGER,
|
||||
TOK_WITH,
|
||||
/* FutureReservedWord */
|
||||
TOK_CLASS,
|
||||
TOK_CONST,
|
||||
TOK_ENUM,
|
||||
TOK_EXPORT,
|
||||
TOK_EXTENDS,
|
||||
TOK_IMPORT,
|
||||
TOK_SUPER,
|
||||
/* FutureReservedWords when parsing strict mode code */
|
||||
TOK_IMPLEMENTS,
|
||||
TOK_INTERFACE,
|
||||
TOK_LET,
|
||||
TOK_PRIVATE,
|
||||
TOK_PROTECTED,
|
||||
TOK_PUBLIC,
|
||||
TOK_STATIC,
|
||||
TOK_YIELD,
|
||||
TOK_AWAIT, /* must be last */
|
||||
TOK_OF, /* only used for js_parse_skip_parens_token() */
|
||||
};
|
||||
|
||||
#define TOK_FIRST_KEYWORD TOK_NULL
|
||||
#define TOK_LAST_KEYWORD TOK_AWAIT
|
||||
|
||||
/* unicode code points */
|
||||
#define CP_NBSP 0x00a0
|
||||
#define CP_BOM 0xfeff
|
||||
|
||||
#define CP_LS 0x2028
|
||||
#define CP_PS 0x2029
|
||||
|
||||
|
||||
/* === Line/column cache === */
|
||||
typedef struct {
|
||||
/* last source position */
|
||||
const uint8_t *ptr;
|
||||
int line_num;
|
||||
int col_num;
|
||||
const uint8_t *buf_start;
|
||||
} GetLineColCache;
|
||||
|
||||
|
||||
|
||||
/* === PPretext (parser pretext, system-malloc, used by cell_js.c parser) === */
|
||||
typedef struct PPretext {
|
||||
uint32_t *data;
|
||||
@@ -1739,8 +1517,6 @@ extern JSClassID js_class_id_alloc;
|
||||
/* runtime.c — line/column, GC, and VM dispatch */
|
||||
int ctx_gc (JSContext *ctx, int allow_grow, size_t alloc_size);
|
||||
JSValue JS_CallInternal (JSContext *ctx, JSValue func_obj, JSValue this_obj, int argc, JSValue *argv, int flags);
|
||||
int get_line_col (int *pcol_num, const uint8_t *buf, size_t len);
|
||||
int get_line_col_cached (GetLineColCache *s, int *pcol_num, const uint8_t *ptr);
|
||||
|
||||
/* runtime.c exports */
|
||||
JSValue JS_ThrowStackOverflow (JSContext *ctx);
|
||||
@@ -1792,7 +1568,7 @@ static inline JSValue *get_upvalue_ptr (JSValue frame_val, int depth, int slot)
|
||||
JSFrame *frame = JS_VALUE_GET_FRAME(frame_val);
|
||||
while (depth > 0) {
|
||||
JSFunction *fn = JS_VALUE_GET_FUNCTION(frame->function);
|
||||
frame_val = fn->u.func.outer_frame;
|
||||
frame_val = fn->u.reg.outer_frame;
|
||||
if (JS_IsNull(frame_val)) return NULL;
|
||||
frame = JS_VALUE_GET_FRAME(frame_val);
|
||||
depth--;
|
||||
|
||||
Reference in New Issue
Block a user