mirror of
https://github.com/janet-lang/janet
synced 2024-12-24 23:40:27 +00:00
Replace map of vars with single element arrays
This commit is contained in:
parent
29a39c47b0
commit
1f8b671488
@ -529,9 +529,9 @@ static Slot compile_symbol(GstCompiler *c, FormOptions opts, GstValue sym) {
|
||||
const GstValue *tup;
|
||||
Gst *vm= c->vm;
|
||||
GstValue *t = gst_tuple_begin(vm, 3);
|
||||
t[0] = gst_string_cv(vm, "get"); /* Todo - replace with ref ro actual cfunc */
|
||||
t[0] = gst_string_cv(vm, "get"); /* Todo - replace with actual cfunc or bytecode */
|
||||
t[1] = quote(vm, lit);
|
||||
t[2] = quote(vm, sym);
|
||||
t[2] = gst_wrap_integer(0);
|
||||
tup = gst_tuple_end(vm, t);
|
||||
return compile_value(c, opts, gst_wrap_tuple(tup));
|
||||
} else if (level > 0) {
|
||||
@ -610,7 +610,7 @@ static Slot compile_assign(GstCompiler *c, FormOptions opts, GstValue left, GstV
|
||||
GstValue *t = gst_tuple_begin(vm, 4);
|
||||
t[0] = gst_string_cv(vm, "set!"); /* Todo - replace with ref ro actual cfunc */
|
||||
t[1] = quote(vm, lit);
|
||||
t[2] = quote(vm, left);
|
||||
t[2] = gst_wrap_integer(0);
|
||||
t[3] = right;
|
||||
tup = gst_tuple_end(vm, t);
|
||||
subOpts.resultUnused = 1;
|
||||
|
11
core/util.c
11
core/util.c
@ -274,10 +274,6 @@ GstTable *gst_env_meta(Gst *vm, GstTable *env) {
|
||||
return gst_env_inttab(vm, env, GST_ENV_METADATA);
|
||||
}
|
||||
|
||||
GstTable *gst_env_vars(Gst *vm, GstTable *env) {
|
||||
return gst_env_inttab(vm, env, GST_ENV_VARS);
|
||||
}
|
||||
|
||||
/* Add many global variables and bind to nil */
|
||||
static void mergenils(Gst *vm, GstTable *destEnv, GstTable *nils) {
|
||||
const GstValue *data = nils->data;
|
||||
@ -347,9 +343,10 @@ void gst_env_putc(Gst *vm, GstTable *env, const char *key, GstValue value) {
|
||||
void gst_env_putvar(Gst *vm, GstTable *env, GstValue key, GstValue value) {
|
||||
GstTable *meta = gst_env_meta(vm, env);
|
||||
GstTable *newmeta = gst_table(vm, 4);
|
||||
GstTable *vars = gst_env_vars(vm, env);
|
||||
gst_table_put(vm, vars, key, value);
|
||||
gst_table_put(vm, env, key, gst_wrap_table(vars));
|
||||
GstArray *ref = gst_array(vm, 1);
|
||||
ref->count = 1;
|
||||
ref->data[0] = value;
|
||||
gst_table_put(vm, env, key, gst_wrap_array(ref));
|
||||
gst_table_put(vm, newmeta, gst_string_cv(vm, "mutable"), gst_wrap_boolean(1));
|
||||
gst_table_put(vm, meta, key, gst_wrap_table(newmeta));
|
||||
}
|
||||
|
@ -645,7 +645,6 @@ GstInteger gst_endrange(GstInteger raw, uint32_t len);
|
||||
void gst_env_merge(Gst *vm, GstTable *destEnv, GstTable *srcEnv);
|
||||
GstTable *gst_env_nils(Gst *vm, GstTable *env);
|
||||
GstTable *gst_env_meta(Gst *vm, GstTable *env);
|
||||
GstTable *gst_env_vars(Gst *vm, GstTable *env);
|
||||
void gst_env_put(Gst *vm, GstTable *env, GstValue key, GstValue value);
|
||||
void gst_env_putc(Gst *vm, GstTable *env, const char *key, GstValue value);
|
||||
void gst_env_putvar(Gst *vm, GstTable *env, GstValue key, GstValue value);
|
||||
|
Loading…
Reference in New Issue
Block a user