initialize with global scope
This commit is contained in:
parent
b2c74552f2
commit
35cf4e1fcd
|
@ -96,6 +96,9 @@ typedef struct analyze_state {
|
||||||
pic_sym sGSET, sLSET, sCSET;
|
pic_sym sGSET, sLSET, sCSET;
|
||||||
} analyze_state;
|
} analyze_state;
|
||||||
|
|
||||||
|
static void push_scope(analyze_state *, pic_value);
|
||||||
|
static void pop_scope(analyze_state *);
|
||||||
|
|
||||||
#define register_symbol(pic, state, slot, name) do { \
|
#define register_symbol(pic, state, slot, name) do { \
|
||||||
state->slot = pic_intern_cstr(pic, name); \
|
state->slot = pic_intern_cstr(pic, name); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
@ -115,7 +118,7 @@ new_analyze_state(pic_state *pic)
|
||||||
|
|
||||||
state = (analyze_state *)pic_alloc(pic, sizeof(analyze_state));
|
state = (analyze_state *)pic_alloc(pic, sizeof(analyze_state));
|
||||||
state->pic = pic;
|
state->pic = pic;
|
||||||
state->scope = global_scope(pic);
|
state->scope = NULL;
|
||||||
|
|
||||||
stdlib = pic_find_library(pic, pic_parse(pic, "(scheme base)"));
|
stdlib = pic_find_library(pic, pic_parse(pic, "(scheme base)"));
|
||||||
|
|
||||||
|
@ -143,6 +146,9 @@ new_analyze_state(pic_state *pic)
|
||||||
register_symbol(pic, state, sLREF, "lref");
|
register_symbol(pic, state, sLREF, "lref");
|
||||||
register_symbol(pic, state, sCREF, "cref");
|
register_symbol(pic, state, sCREF, "cref");
|
||||||
|
|
||||||
|
/* push initial scope */
|
||||||
|
push_scope(state, pic_nil_value());
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,12 +248,6 @@ define_var(analyze_state *state, const char *name)
|
||||||
xh_put(scope->dirty_flags, name, 0);
|
xh_put(scope->dirty_flags, name, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
is_global_scope(analyze_scope *scope)
|
|
||||||
{
|
|
||||||
return scope->up == NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
new_cref(analyze_state *state, int depth, pic_sym sym)
|
new_cref(analyze_state *state, int depth, pic_sym sym)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue