rm constructors
This commit is contained in:
@@ -145,12 +145,8 @@ void script_startup(cell_rt *prt)
|
||||
JS_SetPropertyStr(js, cell, "hidden", hidden_fn);
|
||||
JS_SetPropertyStr(js, hidden_fn, "os", js_os_use(js));
|
||||
|
||||
const char actorsym_script[] = "Symbol('actordata');";
|
||||
|
||||
JSValue actorsym = JS_Eval(js, actorsym_script, sizeof(actorsym_script)-1, "internal", 0);
|
||||
JS_SetPropertyStr(js, hidden_fn, "actorsym", actorsym);
|
||||
|
||||
crt->actor_sym = JS_ValueToAtom(js, actorsym);
|
||||
crt->actor_sym = JS_NewObject(js);
|
||||
JS_SetPropertyStr(js, hidden_fn, "actorsym", JS_DupValue(js,crt->actor_sym));
|
||||
|
||||
if (crt->init_wota) {
|
||||
JS_SetPropertyStr(js, hidden_fn, "init", wota2value(js, crt->init_wota));
|
||||
@@ -282,14 +278,12 @@ void cell_trace_sethook(cell_hook)
|
||||
int uncaught_exception(JSContext *js, JSValue v)
|
||||
{
|
||||
cell_rt *rt = JS_GetContextOpaque(js);
|
||||
|
||||
if (!JS_HasException(js)) {
|
||||
JS_FreeValue(js,v);
|
||||
return 1;
|
||||
}
|
||||
|
||||
JSValue exp = JS_GetException(js);
|
||||
|
||||
if (JS_IsNull(rt->on_exception)) {
|
||||
const char *str = JS_ToCString(js, exp);
|
||||
if (str) {
|
||||
|
||||
@@ -53,7 +53,7 @@ typedef struct cell_rt {
|
||||
int main_thread_only;
|
||||
int affinity;
|
||||
|
||||
JSAtom actor_sym;
|
||||
JSValue actor_sym;
|
||||
|
||||
const char *name; // human friendly name
|
||||
cell_hook trace_hook;
|
||||
@@ -63,7 +63,7 @@ cell_rt *create_actor(void *wota);
|
||||
const char *register_actor(const char *id, cell_rt *actor, int mainthread, double ar);
|
||||
void actor_disrupt(cell_rt *actor);
|
||||
|
||||
JSAtom actor_sym(cell_rt *actor);
|
||||
JSValue actor_sym(cell_rt *actor);
|
||||
|
||||
const char *send_message(const char *id, void *msg);
|
||||
const char *register_actor(const char *id, cell_rt *actor, int mainthread, double ar);
|
||||
|
||||
@@ -186,7 +186,8 @@ static void wota_encode_value(WotaEncodeContext *enc, JSValueConst val, JSValueC
|
||||
break;
|
||||
}
|
||||
cell_rt *crt = JS_GetContextOpaque(ctx);
|
||||
JSValue adata = JS_GetProperty(ctx, replaced, crt->actor_sym);
|
||||
// JSValue adata = JS_GetProperty(ctx, replaced, crt->actor_sym);
|
||||
JSValue adata = JS_NULL;
|
||||
if (!JS_IsNull(adata)) {
|
||||
wota_write_sym(&enc->wb, WOTA_PRIVATE);
|
||||
wota_encode_value(enc, adata, replaced, JS_ATOM_NULL);
|
||||
@@ -248,7 +249,7 @@ static char *decode_wota_value(JSContext *ctx, char *data_ptr, JSValue *out_val,
|
||||
data_ptr = decode_wota_value(ctx, data_ptr, &inner, holder, JS_ATOM_NULL, reviver);
|
||||
JSValue obj = JS_NewObject(ctx);
|
||||
cell_rt *crt = JS_GetContextOpaque(ctx);
|
||||
JS_SetProperty(ctx, obj, crt->actor_sym, inner);
|
||||
// JS_SetProperty(ctx, obj, crt->actor_sym, inner);
|
||||
*out_val = obj;
|
||||
} else if (scode == WOTA_NULL) *out_val = JS_NULL;
|
||||
else if (scode == WOTA_FALSE) *out_val = JS_NewBool(ctx, 0);
|
||||
|
||||
@@ -97,7 +97,6 @@ DEF( rot3r, 1, 3, 3, none) /* a b x -> x a b */
|
||||
DEF( rot4l, 1, 4, 4, none) /* x a b c -> a b c x */
|
||||
DEF( rot5l, 1, 5, 5, none) /* x a b c d -> a b c d x */
|
||||
|
||||
DEF(call_constructor, 3, 2, 1, npop) /* func new.target args -> ret. arguments are not counted in n_pop */
|
||||
DEF( call, 3, 1, 1, npop) /* arguments are not counted in n_pop */
|
||||
DEF( tail_call, 3, 1, 0, npop) /* arguments are not counted in n_pop */
|
||||
DEF( call_method, 3, 2, 1, npop) /* arguments are not counted in n_pop */
|
||||
@@ -219,6 +218,9 @@ DEF( strict_neq, 1, 2, 1, none)
|
||||
DEF( and, 1, 2, 1, none)
|
||||
DEF( xor, 1, 2, 1, none)
|
||||
DEF( or, 1, 2, 1, none)
|
||||
/* template literal concatenation - pops N parts, pushes concatenated string */
|
||||
DEF(template_concat, 3, 0, 1, npop_u16)
|
||||
|
||||
/* must be the last non short and non temporary opcode */
|
||||
DEF( nop, 1, 0, 0, none)
|
||||
|
||||
|
||||
746
source/quickjs.c
746
source/quickjs.c
File diff suppressed because it is too large
Load Diff
@@ -469,7 +469,6 @@ typedef struct JSClassExoticMethods {
|
||||
typedef void JSClassFinalizer(JSRuntime *rt, JSValue val);
|
||||
typedef void JSClassGCMark(JSRuntime *rt, JSValueConst val,
|
||||
JS_MarkFunc *mark_func);
|
||||
#define JS_CALL_FLAG_CONSTRUCTOR (1 << 0)
|
||||
typedef JSValue JSClassCall(JSContext *ctx, JSValueConst func_obj,
|
||||
JSValueConst this_val, int argc, JSValueConst *argv,
|
||||
int flags);
|
||||
@@ -478,11 +477,7 @@ typedef struct JSClassDef {
|
||||
const char *class_name;
|
||||
JSClassFinalizer *finalizer;
|
||||
JSClassGCMark *gc_mark;
|
||||
/* if call != NULL, the object is a function. If (flags &
|
||||
JS_CALL_FLAG_CONSTRUCTOR) != 0, the function is called as a
|
||||
constructor. In this case, 'this_val' is new.target. A
|
||||
constructor call only happens if the object constructor bit is
|
||||
set (see JS_SetConstructorBit()). */
|
||||
/* if call != NULL, the object is a function */
|
||||
JSClassCall *call;
|
||||
/* XXX: suppress this indirection ? It is here only to save memory
|
||||
because only a few classes need these methods */
|
||||
|
||||
@@ -270,7 +270,7 @@ void actor_free(cell_rt *actor)
|
||||
JS_FreeValue(js, actor->message_handle);
|
||||
JS_FreeValue(js, actor->on_exception);
|
||||
JS_FreeValue(js, actor->unneeded);
|
||||
JS_FreeAtom(js, actor->actor_sym);
|
||||
JS_FreeValue(js, actor->actor_sym);
|
||||
|
||||
for (int i = 0; i < hmlen(actor->timers); i++) {
|
||||
JS_FreeValue(js, actor->timers[i].value);
|
||||
@@ -497,7 +497,7 @@ cell_rt *create_actor(void *wota)
|
||||
actor->message_handle = JS_NULL;
|
||||
actor->unneeded = JS_NULL;
|
||||
actor->on_exception = JS_NULL;
|
||||
actor->actor_sym = JS_ATOM_NULL;
|
||||
actor->actor_sym = JS_NULL;
|
||||
|
||||
arrsetcap(actor->letters, 5);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user