remove pic_sym_value
This commit is contained in:
parent
f349e4148e
commit
fa1b681eba
|
@ -257,7 +257,7 @@ define_var(analyze_state *state, pic_sym sym)
|
||||||
analyze_scope *scope = state->scope;
|
analyze_scope *scope = state->scope;
|
||||||
|
|
||||||
if (lookup_scope(scope, sym)) {
|
if (lookup_scope(scope, sym)) {
|
||||||
pic_warnf(pic, "redefining variable: ~s", pic_sym_value(sym));
|
pic_warnf(pic, "redefining variable: ~s", pic_obj_value(sym));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ analyze(analyze_state *state, pic_value obj, bool tailpos)
|
||||||
/* pass through */
|
/* pass through */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res = pic_list2(pic, pic_sym_value(state->sRETURN), res);
|
res = pic_list2(pic, pic_obj_value(state->sRETURN), res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ analyze_global_var(analyze_state *state, pic_sym sym)
|
||||||
{
|
{
|
||||||
pic_state *pic = state->pic;
|
pic_state *pic = state->pic;
|
||||||
|
|
||||||
return pic_list2(pic, pic_sym_value(state->sGREF), pic_sym_value(sym));
|
return pic_list2(pic, pic_obj_value(state->sGREF), pic_obj_value(sym));
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -306,7 +306,7 @@ analyze_local_var(analyze_state *state, pic_sym sym)
|
||||||
{
|
{
|
||||||
pic_state *pic = state->pic;
|
pic_state *pic = state->pic;
|
||||||
|
|
||||||
return pic_list2(pic, pic_sym_value(state->sLREF), pic_sym_value(sym));
|
return pic_list2(pic, pic_obj_value(state->sLREF), pic_obj_value(sym));
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -314,7 +314,7 @@ analyze_free_var(analyze_state *state, pic_sym sym, int depth)
|
||||||
{
|
{
|
||||||
pic_state *pic = state->pic;
|
pic_state *pic = state->pic;
|
||||||
|
|
||||||
return pic_list3(pic, pic_sym_value(state->sCREF), pic_int_value(depth), pic_sym_value(sym));
|
return pic_list3(pic, pic_obj_value(state->sCREF), pic_int_value(depth), pic_obj_value(sym));
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -343,7 +343,7 @@ analyze_defer(analyze_state *state, pic_value name, pic_value formal, pic_value
|
||||||
const pic_sym sNOWHERE = pic_intern_cstr(pic, " nowhere ");
|
const pic_sym sNOWHERE = pic_intern_cstr(pic, " nowhere ");
|
||||||
pic_value skel;
|
pic_value skel;
|
||||||
|
|
||||||
skel = pic_list2(pic, pic_sym_value(state->sGREF), pic_sym_value(sNOWHERE));
|
skel = pic_list2(pic, pic_obj_value(state->sGREF), pic_obj_value(sNOWHERE));
|
||||||
|
|
||||||
pic_push(pic, pic_list4(pic, name, formal, body, skel), state->scope->defer);
|
pic_push(pic, pic_list4(pic, name, formal, body, skel), state->scope->defer);
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ analyze_procedure(analyze_state *state, pic_value name, pic_value formals, pic_v
|
||||||
args = pic_nil_value();
|
args = pic_nil_value();
|
||||||
for (i = xv_size(&scope->args); i > 0; --i) {
|
for (i = xv_size(&scope->args); i > 0; --i) {
|
||||||
var = xv_get(&scope->args, i - 1);
|
var = xv_get(&scope->args, i - 1);
|
||||||
pic_push(pic, pic_sym_value(*var), args);
|
pic_push(pic, pic_obj_value(*var), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
varg = scope->varg
|
varg = scope->varg
|
||||||
|
@ -396,20 +396,20 @@ analyze_procedure(analyze_state *state, pic_value name, pic_value formals, pic_v
|
||||||
: pic_false_value();
|
: pic_false_value();
|
||||||
|
|
||||||
/* To know what kind of local variables are defined, analyze body at first. */
|
/* To know what kind of local variables are defined, analyze body at first. */
|
||||||
body = analyze(state, pic_cons(pic, pic_sym_value(pic->rBEGIN), body_exprs), true);
|
body = analyze(state, pic_cons(pic, pic_obj_value(pic->rBEGIN), body_exprs), true);
|
||||||
|
|
||||||
analyze_deferred(state);
|
analyze_deferred(state);
|
||||||
|
|
||||||
locals = pic_nil_value();
|
locals = pic_nil_value();
|
||||||
for (i = xv_size(&scope->locals); i > 0; --i) {
|
for (i = xv_size(&scope->locals); i > 0; --i) {
|
||||||
var = xv_get(&scope->locals, i - 1);
|
var = xv_get(&scope->locals, i - 1);
|
||||||
pic_push(pic, pic_sym_value(*var), locals);
|
pic_push(pic, pic_obj_value(*var), locals);
|
||||||
}
|
}
|
||||||
|
|
||||||
captures = pic_nil_value();
|
captures = pic_nil_value();
|
||||||
for (i = xv_size(&scope->captures); i > 0; --i) {
|
for (i = xv_size(&scope->captures); i > 0; --i) {
|
||||||
var = xv_get(&scope->captures, i - 1);
|
var = xv_get(&scope->captures, i - 1);
|
||||||
pic_push(pic, pic_sym_value(*var), captures);
|
pic_push(pic, pic_obj_value(*var), captures);
|
||||||
}
|
}
|
||||||
|
|
||||||
pop_scope(state);
|
pop_scope(state);
|
||||||
|
@ -418,7 +418,7 @@ analyze_procedure(analyze_state *state, pic_value name, pic_value formals, pic_v
|
||||||
pic_errorf(pic, "invalid formal syntax: ~s", args);
|
pic_errorf(pic, "invalid formal syntax: ~s", args);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pic_list7(pic, pic_sym_value(pic->sLAMBDA), name, args, locals, varg, captures, body);
|
return pic_list7(pic, pic_obj_value(pic->sLAMBDA), name, args, locals, varg, captures, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -472,7 +472,7 @@ analyze_define(analyze_state *state, pic_value obj)
|
||||||
formals = pic_list_ref(pic, pic_list_ref(pic, obj, 2), 1);
|
formals = pic_list_ref(pic, pic_list_ref(pic, obj, 2), 1);
|
||||||
body_exprs = pic_list_tail(pic, pic_list_ref(pic, obj, 2), 2);
|
body_exprs = pic_list_tail(pic, pic_list_ref(pic, obj, 2), 2);
|
||||||
|
|
||||||
val = analyze_defer(state, pic_sym_value(sym), formals, body_exprs);
|
val = analyze_defer(state, pic_obj_value(sym), formals, body_exprs);
|
||||||
} else {
|
} else {
|
||||||
if (pic_length(pic, obj) != 3) {
|
if (pic_length(pic, obj) != 3) {
|
||||||
pic_errorf(pic, "syntax error");
|
pic_errorf(pic, "syntax error");
|
||||||
|
@ -480,7 +480,7 @@ analyze_define(analyze_state *state, pic_value obj)
|
||||||
val = analyze(state, pic_list_ref(pic, obj, 2), false);
|
val = analyze(state, pic_list_ref(pic, obj, 2), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pic_list3(pic, pic_sym_value(pic->sSETBANG), var, val);
|
return pic_list3(pic, pic_obj_value(pic->sSETBANG), var, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -505,7 +505,7 @@ analyze_if(analyze_state *state, pic_value obj, bool tailpos)
|
||||||
if_true = analyze(state, if_true, tailpos);
|
if_true = analyze(state, if_true, tailpos);
|
||||||
if_false = analyze(state, if_false, tailpos);
|
if_false = analyze(state, if_false, tailpos);
|
||||||
|
|
||||||
return pic_list4(pic, pic_sym_value(pic->sIF), cond, if_true, if_false);
|
return pic_list4(pic, pic_obj_value(pic->sIF), cond, if_true, if_false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -521,7 +521,7 @@ analyze_begin(analyze_state *state, pic_value obj, bool tailpos)
|
||||||
case 2:
|
case 2:
|
||||||
return analyze(state, pic_list_ref(pic, obj, 1), tailpos);
|
return analyze(state, pic_list_ref(pic, obj, 1), tailpos);
|
||||||
default:
|
default:
|
||||||
seq = pic_list1(pic, pic_sym_value(pic->sBEGIN));
|
seq = pic_list1(pic, pic_obj_value(pic->sBEGIN));
|
||||||
for (obj = pic_cdr(pic, obj); ! pic_nil_p(obj); obj = pic_cdr(pic, obj)) {
|
for (obj = pic_cdr(pic, obj); ! pic_nil_p(obj); obj = pic_cdr(pic, obj)) {
|
||||||
if (pic_nil_p(pic_cdr(pic, obj))) {
|
if (pic_nil_p(pic_cdr(pic, obj))) {
|
||||||
tail = tailpos;
|
tail = tailpos;
|
||||||
|
@ -554,7 +554,7 @@ analyze_set(analyze_state *state, pic_value obj)
|
||||||
var = analyze(state, var, false);
|
var = analyze(state, var, false);
|
||||||
val = analyze(state, val, false);
|
val = analyze(state, val, false);
|
||||||
|
|
||||||
return pic_list3(pic, pic_sym_value(pic->sSETBANG), var, val);
|
return pic_list3(pic, pic_obj_value(pic->sSETBANG), var, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -565,7 +565,7 @@ analyze_quote(analyze_state *state, pic_value obj)
|
||||||
if (pic_length(pic, obj) != 2) {
|
if (pic_length(pic, obj) != 2) {
|
||||||
pic_errorf(pic, "syntax error");
|
pic_errorf(pic, "syntax error");
|
||||||
}
|
}
|
||||||
return pic_list2(pic, pic_sym_value(pic->sQUOTE), pic_list_ref(pic, obj, 1));
|
return pic_list2(pic, pic_obj_value(pic->sQUOTE), pic_list_ref(pic, obj, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ARGC_ASSERT_GE(n) do { \
|
#define ARGC_ASSERT_GE(n) do { \
|
||||||
|
@ -577,7 +577,7 @@ analyze_quote(analyze_state *state, pic_value obj)
|
||||||
#define FOLD_ARGS(sym) do { \
|
#define FOLD_ARGS(sym) do { \
|
||||||
obj = analyze(state, pic_car(pic, args), false); \
|
obj = analyze(state, pic_car(pic, args), false); \
|
||||||
pic_for_each (arg, pic_cdr(pic, args)) { \
|
pic_for_each (arg, pic_cdr(pic, args)) { \
|
||||||
obj = pic_list3(pic, pic_sym_value(sym), obj, \
|
obj = pic_list3(pic, pic_obj_value(sym), obj, \
|
||||||
analyze(state, arg, false)); \
|
analyze(state, arg, false)); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
@ -591,7 +591,7 @@ analyze_add(analyze_state *state, pic_value obj, bool tailpos)
|
||||||
ARGC_ASSERT_GE(0);
|
ARGC_ASSERT_GE(0);
|
||||||
switch (pic_length(pic, obj)) {
|
switch (pic_length(pic, obj)) {
|
||||||
case 1:
|
case 1:
|
||||||
return pic_list2(pic, pic_sym_value(pic->sQUOTE), pic_int_value(0));
|
return pic_list2(pic, pic_obj_value(pic->sQUOTE), pic_int_value(0));
|
||||||
case 2:
|
case 2:
|
||||||
return analyze(state, pic_car(pic, pic_cdr(pic, obj)), tailpos);
|
return analyze(state, pic_car(pic, pic_cdr(pic, obj)), tailpos);
|
||||||
default:
|
default:
|
||||||
|
@ -610,7 +610,7 @@ analyze_sub(analyze_state *state, pic_value obj)
|
||||||
ARGC_ASSERT_GE(1);
|
ARGC_ASSERT_GE(1);
|
||||||
switch (pic_length(pic, obj)) {
|
switch (pic_length(pic, obj)) {
|
||||||
case 2:
|
case 2:
|
||||||
return pic_list2(pic, pic_sym_value(pic->sMINUS),
|
return pic_list2(pic, pic_obj_value(pic->sMINUS),
|
||||||
analyze(state, pic_car(pic, pic_cdr(pic, obj)), false));
|
analyze(state, pic_car(pic, pic_cdr(pic, obj)), false));
|
||||||
default:
|
default:
|
||||||
args = pic_cdr(pic, obj);
|
args = pic_cdr(pic, obj);
|
||||||
|
@ -628,7 +628,7 @@ analyze_mul(analyze_state *state, pic_value obj, bool tailpos)
|
||||||
ARGC_ASSERT_GE(0);
|
ARGC_ASSERT_GE(0);
|
||||||
switch (pic_length(pic, obj)) {
|
switch (pic_length(pic, obj)) {
|
||||||
case 1:
|
case 1:
|
||||||
return pic_list2(pic, pic_sym_value(pic->sQUOTE), pic_int_value(1));
|
return pic_list2(pic, pic_obj_value(pic->sQUOTE), pic_int_value(1));
|
||||||
case 2:
|
case 2:
|
||||||
return analyze(state, pic_car(pic, pic_cdr(pic, obj)), tailpos);
|
return analyze(state, pic_car(pic, pic_cdr(pic, obj)), tailpos);
|
||||||
default:
|
default:
|
||||||
|
@ -669,7 +669,7 @@ analyze_call(analyze_state *state, pic_value obj, bool tailpos)
|
||||||
} else {
|
} else {
|
||||||
call = state->sTAILCALL;
|
call = state->sTAILCALL;
|
||||||
}
|
}
|
||||||
seq = pic_list1(pic, pic_sym_value(call));
|
seq = pic_list1(pic, pic_obj_value(call));
|
||||||
pic_for_each (elt, obj) {
|
pic_for_each (elt, obj) {
|
||||||
seq = pic_cons(pic, analyze(state, elt, false), seq);
|
seq = pic_cons(pic, analyze(state, elt, false), seq);
|
||||||
}
|
}
|
||||||
|
@ -686,7 +686,7 @@ analyze_values(analyze_state *state, pic_value obj, bool tailpos)
|
||||||
return analyze_call(state, obj, false);
|
return analyze_call(state, obj, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
seq = pic_list1(pic, pic_sym_value(state->sRETURN));
|
seq = pic_list1(pic, pic_obj_value(state->sRETURN));
|
||||||
pic_for_each (v, pic_cdr(pic, obj)) {
|
pic_for_each (v, pic_cdr(pic, obj)) {
|
||||||
seq = pic_cons(pic, analyze(state, v, false), seq);
|
seq = pic_cons(pic, analyze(state, v, false), seq);
|
||||||
}
|
}
|
||||||
|
@ -711,7 +711,7 @@ analyze_call_with_values(analyze_state *state, pic_value obj, bool tailpos)
|
||||||
}
|
}
|
||||||
prod = analyze(state, pic_list_ref(pic, obj, 1), false);
|
prod = analyze(state, pic_list_ref(pic, obj, 1), false);
|
||||||
cnsm = analyze(state, pic_list_ref(pic, obj, 2), false);
|
cnsm = analyze(state, pic_list_ref(pic, obj, 2), false);
|
||||||
return pic_list3(pic, pic_sym_value(call), prod, cnsm);
|
return pic_list3(pic, pic_obj_value(call), prod, cnsm);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ARGC_ASSERT(n) do { \
|
#define ARGC_ASSERT(n) do { \
|
||||||
|
@ -728,12 +728,12 @@ analyze_call_with_values(analyze_state *state, pic_value obj, bool tailpos)
|
||||||
|
|
||||||
#define CONSTRUCT_OP1(op) \
|
#define CONSTRUCT_OP1(op) \
|
||||||
pic_list2(pic, \
|
pic_list2(pic, \
|
||||||
pic_sym_value(op), \
|
pic_obj_value(op), \
|
||||||
analyze(state, pic_list_ref(pic, obj, 1), false))
|
analyze(state, pic_list_ref(pic, obj, 1), false))
|
||||||
|
|
||||||
#define CONSTRUCT_OP2(op) \
|
#define CONSTRUCT_OP2(op) \
|
||||||
pic_list3(pic, \
|
pic_list3(pic, \
|
||||||
pic_sym_value(op), \
|
pic_obj_value(op), \
|
||||||
analyze(state, pic_list_ref(pic, obj, 1), false), \
|
analyze(state, pic_list_ref(pic, obj, 1), false), \
|
||||||
analyze(state, pic_list_ref(pic, obj, 2), false))
|
analyze(state, pic_list_ref(pic, obj, 2), false))
|
||||||
|
|
||||||
|
@ -847,7 +847,7 @@ analyze_node(analyze_state *state, pic_value obj, bool tailpos)
|
||||||
return analyze_call(state, obj, tailpos);
|
return analyze_call(state, obj, tailpos);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return pic_list2(pic, pic_sym_value(pic->sQUOTE), obj);
|
return pic_list2(pic, pic_obj_value(pic->sQUOTE), obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ pic_print_backtrace(pic_state *pic)
|
||||||
|
|
||||||
e = pic_error_ptr(pic->err);
|
e = pic_error_ptr(pic->err);
|
||||||
if (e->type != pic_intern_cstr(pic, "")) {
|
if (e->type != pic_intern_cstr(pic, "")) {
|
||||||
trace = pic_format(pic, "~s ", pic_sym_value(e->type));
|
trace = pic_format(pic, "~s ", pic_obj_value(e->type));
|
||||||
} else {
|
} else {
|
||||||
trace = pic_make_str(pic, NULL, 0);
|
trace = pic_make_str(pic, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ pic_dict_ref(pic_state *pic, struct pic_dict *dict, pic_sym key)
|
||||||
|
|
||||||
e = xh_get_ptr(&dict->hash, key);
|
e = xh_get_ptr(&dict->hash, key);
|
||||||
if (! e) {
|
if (! e) {
|
||||||
pic_errorf(pic, "element not found for a key: ~s", pic_sym_value(key));
|
pic_errorf(pic, "element not found for a key: ~s", pic_obj_value(key));
|
||||||
}
|
}
|
||||||
return xh_val(e, pic_value);
|
return xh_val(e, pic_value);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ void
|
||||||
pic_dict_del(pic_state *pic, struct pic_dict *dict, pic_sym key)
|
pic_dict_del(pic_state *pic, struct pic_dict *dict, pic_sym key)
|
||||||
{
|
{
|
||||||
if (xh_get_ptr(&dict->hash, key) == NULL) {
|
if (xh_get_ptr(&dict->hash, key) == NULL) {
|
||||||
pic_errorf(pic, "no slot named ~s found in dictionary", pic_sym_value(key));
|
pic_errorf(pic, "no slot named ~s found in dictionary", pic_obj_value(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
xh_del_ptr(&dict->hash, key);
|
xh_del_ptr(&dict->hash, key);
|
||||||
|
@ -186,7 +186,7 @@ pic_dict_dictionary_map(pic_state *pic)
|
||||||
if (it[i] == NULL) {
|
if (it[i] == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pic_push(pic, pic_sym_value(xh_key(it[i], pic_sym)), arg);
|
pic_push(pic, pic_obj_value(xh_key(it[i], pic_sym)), arg);
|
||||||
it[i] = xh_next(it[i]);
|
it[i] = xh_next(it[i]);
|
||||||
}
|
}
|
||||||
if (i != argc) {
|
if (i != argc) {
|
||||||
|
@ -232,7 +232,7 @@ pic_dict_dictionary_for_each(pic_state *pic)
|
||||||
if (it[i] == NULL) {
|
if (it[i] == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pic_push(pic, pic_sym_value(xh_key(it[i], pic_sym)), arg);
|
pic_push(pic, pic_obj_value(xh_key(it[i], pic_sym)), arg);
|
||||||
it[i] = xh_next(it[i]);
|
it[i] = xh_next(it[i]);
|
||||||
}
|
}
|
||||||
if (i != argc) {
|
if (i != argc) {
|
||||||
|
@ -261,7 +261,7 @@ pic_dict_dictionary_to_alist(pic_state *pic)
|
||||||
pic_get_args(pic, "d", &dict);
|
pic_get_args(pic, "d", &dict);
|
||||||
|
|
||||||
for (it = xh_begin(&dict->hash); it != NULL; it = xh_next(it)) {
|
for (it = xh_begin(&dict->hash); it != NULL; it = xh_next(it)) {
|
||||||
item = pic_cons(pic, pic_sym_value(xh_key(it, pic_sym)), xh_val(it, pic_value));
|
item = pic_cons(pic, pic_obj_value(xh_key(it, pic_sym)), xh_val(it, pic_value));
|
||||||
pic_push(pic, item, alist);
|
pic_push(pic, item, alist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ pic_dict_dictionary_to_plist(pic_state *pic)
|
||||||
pic_get_args(pic, "d", &dict);
|
pic_get_args(pic, "d", &dict);
|
||||||
|
|
||||||
for (it = xh_begin(&dict->hash); it != NULL; it = xh_next(it)) {
|
for (it = xh_begin(&dict->hash); it != NULL; it = xh_next(it)) {
|
||||||
pic_push(pic, pic_sym_value(xh_key(it, pic_sym)), plist);
|
pic_push(pic, pic_obj_value(xh_key(it, pic_sym)), plist);
|
||||||
pic_push(pic, xh_val(it, pic_value), plist);
|
pic_push(pic, xh_val(it, pic_value), plist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -302,7 +302,7 @@ pic_error_error_object_type(pic_state *pic)
|
||||||
|
|
||||||
pic_get_args(pic, "e", &e);
|
pic_get_args(pic, "e", &e);
|
||||||
|
|
||||||
return pic_sym_value(e->type);
|
return pic_obj_value(e->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -52,7 +52,6 @@ extern "C" {
|
||||||
#include "picrin/value.h"
|
#include "picrin/value.h"
|
||||||
|
|
||||||
#define pic_sym(v) pic_ptr(v)
|
#define pic_sym(v) pic_ptr(v)
|
||||||
#define pic_sym_value(v) pic_obj_value(v)
|
|
||||||
#define pic_sym_p(v) (pic_type(v) == PIC_TT_SYMBOL)
|
#define pic_sym_p(v) (pic_type(v) == PIC_TT_SYMBOL)
|
||||||
|
|
||||||
typedef struct pic_code pic_code;
|
typedef struct pic_code pic_code;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
void
|
void
|
||||||
pic_add_feature(pic_state *pic, const char *feature)
|
pic_add_feature(pic_state *pic, const char *feature)
|
||||||
{
|
{
|
||||||
pic_push(pic, pic_sym_value(pic_intern_cstr(pic, feature)), pic->features);
|
pic_push(pic, pic_obj_value(pic_intern_cstr(pic, feature)), pic->features);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pic_init_bool(pic_state *);
|
void pic_init_bool(pic_state *);
|
||||||
|
|
|
@ -104,7 +104,7 @@ import_table(pic_state *pic, pic_value spec, struct pic_dict *imports)
|
||||||
|
|
||||||
prefix = pic_list_ref(pic, spec, 2);
|
prefix = pic_list_ref(pic, spec, 2);
|
||||||
pic_dict_for_each (sym, table) {
|
pic_dict_for_each (sym, table) {
|
||||||
id = pic_intern(pic, pic_format(pic, "~s~s", prefix, pic_sym_value(sym)));
|
id = pic_intern(pic, pic_format(pic, "~s~s", prefix, pic_obj_value(sym)));
|
||||||
pic_dict_set(pic, imports, id, pic_dict_ref(pic, table, sym));
|
pic_dict_set(pic, imports, id, pic_dict_ref(pic, table, sym));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -155,7 +155,7 @@ export(pic_state *pic, pic_value spec)
|
||||||
goto fail;
|
goto fail;
|
||||||
if (! (pic_length(pic, spec) == 3))
|
if (! (pic_length(pic, spec) == 3))
|
||||||
goto fail;
|
goto fail;
|
||||||
if (! pic_eq_p(pic_car(pic, spec), pic_sym_value(sRENAME)))
|
if (! pic_eq_p(pic_car(pic, spec), pic_obj_value(sRENAME)))
|
||||||
goto fail;
|
goto fail;
|
||||||
if (! pic_sym_p(a = pic_list_ref(pic, spec, 1)))
|
if (! pic_sym_p(a = pic_list_ref(pic, spec, 1)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -171,7 +171,7 @@ export(pic_state *pic, pic_value spec)
|
||||||
printf("* exporting %s as %s\n", pic_symbol_name(pic, pic_sym(b)), pic_symbol_name(pic, rename));
|
printf("* exporting %s as %s\n", pic_symbol_name(pic, pic_sym(b)), pic_symbol_name(pic, rename));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pic_dict_set(pic, pic->lib->exports, pic_sym(b), pic_sym_value(rename));
|
pic_dict_set(pic, pic->lib->exports, pic_sym(b), pic_obj_value(rename));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ pic_import_library(pic_state *pic, struct pic_lib *lib)
|
||||||
void
|
void
|
||||||
pic_export(pic_state *pic, pic_sym sym)
|
pic_export(pic_state *pic, pic_sym sym)
|
||||||
{
|
{
|
||||||
export(pic, pic_sym_value(sym));
|
export(pic, pic_obj_value(sym));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -203,7 +203,7 @@ condexpand(pic_state *pic, pic_value clause)
|
||||||
pic_sym tag;
|
pic_sym tag;
|
||||||
pic_value c, feature;
|
pic_value c, feature;
|
||||||
|
|
||||||
if (pic_eq_p(clause, pic_sym_value(pic->sELSE))) {
|
if (pic_eq_p(clause, pic_obj_value(pic->sELSE))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (pic_sym_p(clause)) {
|
if (pic_sym_p(clause)) {
|
||||||
|
@ -254,7 +254,7 @@ pic_lib_condexpand(pic_state *pic)
|
||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
if (condexpand(pic, pic_car(pic, clauses[i]))) {
|
if (condexpand(pic, pic_car(pic, clauses[i]))) {
|
||||||
return pic_cons(pic, pic_sym_value(pic->rBEGIN), pic_cdr(pic, clauses[i]));
|
return pic_cons(pic, pic_obj_value(pic->rBEGIN), pic_cdr(pic, clauses[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ pic_add_rename(pic_state *pic, struct pic_senv *senv, pic_sym sym)
|
||||||
void
|
void
|
||||||
pic_put_rename(pic_state *pic, struct pic_senv *senv, pic_sym sym, pic_sym rename)
|
pic_put_rename(pic_state *pic, struct pic_senv *senv, pic_sym sym, pic_sym rename)
|
||||||
{
|
{
|
||||||
pic_dict_set(pic, senv->map, sym, pic_sym_value(rename));
|
pic_dict_set(pic, senv->map, sym, pic_obj_value(rename));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -82,13 +82,13 @@ static pic_value macroexpand_lambda(pic_state *, pic_value, struct pic_senv *);
|
||||||
static pic_value
|
static pic_value
|
||||||
macroexpand_symbol(pic_state *pic, pic_sym sym, struct pic_senv *senv)
|
macroexpand_symbol(pic_state *pic, pic_sym sym, struct pic_senv *senv)
|
||||||
{
|
{
|
||||||
return pic_sym_value(make_identifier(pic, sym, senv));
|
return pic_obj_value(make_identifier(pic, sym, senv));
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
macroexpand_quote(pic_state *pic, pic_value expr)
|
macroexpand_quote(pic_state *pic, pic_value expr)
|
||||||
{
|
{
|
||||||
return pic_cons(pic, pic_sym_value(pic->rQUOTE), pic_cdr(pic, expr));
|
return pic_cons(pic, pic_obj_value(pic->rQUOTE), pic_cdr(pic, expr));
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -172,7 +172,7 @@ macroexpand_lambda(pic_state *pic, pic_value expr, struct pic_senv *senv)
|
||||||
|
|
||||||
macroexpand_deferred(pic, in);
|
macroexpand_deferred(pic, in);
|
||||||
|
|
||||||
return pic_cons(pic, pic_sym_value(pic->rLAMBDA), pic_cons(pic, formal, body));
|
return pic_cons(pic, pic_obj_value(pic->rLAMBDA), pic_cons(pic, formal, body));
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -185,7 +185,7 @@ macroexpand_define(pic_state *pic, pic_value expr, struct pic_senv *senv)
|
||||||
var = pic_car(pic, pic_cadr(pic, expr));
|
var = pic_car(pic, pic_cadr(pic, expr));
|
||||||
val = pic_cdr(pic, pic_cadr(pic, expr));
|
val = pic_cdr(pic, pic_cadr(pic, expr));
|
||||||
|
|
||||||
expr = pic_list3(pic, pic_sym_value(pic->rDEFINE), var, pic_cons(pic, pic_sym_value(pic->rLAMBDA), pic_cons(pic, val, pic_cddr(pic, expr))));
|
expr = pic_list3(pic, pic_obj_value(pic->rDEFINE), var, pic_cons(pic, pic_obj_value(pic->rLAMBDA), pic_cons(pic, val, pic_cddr(pic, expr))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pic_length(pic, expr) != 3) {
|
if (pic_length(pic, expr) != 3) {
|
||||||
|
@ -202,7 +202,7 @@ macroexpand_define(pic_state *pic, pic_value expr, struct pic_senv *senv)
|
||||||
}
|
}
|
||||||
val = macroexpand(pic, pic_list_ref(pic, expr, 2), senv);
|
val = macroexpand(pic, pic_list_ref(pic, expr, 2), senv);
|
||||||
|
|
||||||
return pic_list3(pic, pic_sym_value(pic->rDEFINE), pic_sym_value(rename), val);
|
return pic_list3(pic, pic_obj_value(pic->rDEFINE), pic_obj_value(rename), val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -223,7 +223,7 @@ macroexpand_defsyntax(pic_state *pic, pic_value expr, struct pic_senv *senv)
|
||||||
if (! pic_find_rename(pic, senv, sym, &rename)) {
|
if (! pic_find_rename(pic, senv, sym, &rename)) {
|
||||||
rename = pic_add_rename(pic, senv, sym);
|
rename = pic_add_rename(pic, senv, sym);
|
||||||
} else {
|
} else {
|
||||||
pic_warnf(pic, "redefining syntax variable: ~s", pic_sym_value(sym));
|
pic_warnf(pic, "redefining syntax variable: ~s", pic_obj_value(sym));
|
||||||
}
|
}
|
||||||
|
|
||||||
val = pic_cadr(pic, pic_cdr(pic, expr));
|
val = pic_cadr(pic, pic_cdr(pic, expr));
|
||||||
|
@ -468,7 +468,7 @@ pic_identifier_eq_p(pic_state *pic, struct pic_senv *env1, pic_sym sym1, struct
|
||||||
b = sym2;
|
b = sym2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pic_eq_p(pic_sym_value(a), pic_sym_value(b));
|
return pic_eq_p(pic_obj_value(a), pic_obj_value(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -491,7 +491,7 @@ pic_macro_make_identifier(pic_state *pic)
|
||||||
|
|
||||||
pic_assert_type(pic, obj, senv);
|
pic_assert_type(pic, obj, senv);
|
||||||
|
|
||||||
return pic_sym_value(make_identifier(pic, sym, pic_senv_ptr(obj)));
|
return pic_obj_value(make_identifier(pic, sym, pic_senv_ptr(obj)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
|
|
@ -166,7 +166,7 @@ read_quote(pic_state *pic, struct pic_port *port, const char *str)
|
||||||
{
|
{
|
||||||
PIC_UNUSED(str);
|
PIC_UNUSED(str);
|
||||||
|
|
||||||
return pic_list2(pic, pic_sym_value(pic->sQUOTE), read(pic, port, next(port)));
|
return pic_list2(pic, pic_obj_value(pic->sQUOTE), read(pic, port, next(port)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -174,7 +174,7 @@ read_quasiquote(pic_state *pic, struct pic_port *port, const char *str)
|
||||||
{
|
{
|
||||||
PIC_UNUSED(str);
|
PIC_UNUSED(str);
|
||||||
|
|
||||||
return pic_list2(pic, pic_sym_value(pic->sQUASIQUOTE), read(pic, port, next(port)));
|
return pic_list2(pic, pic_obj_value(pic->sQUASIQUOTE), read(pic, port, next(port)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -182,7 +182,7 @@ read_unquote(pic_state *pic, struct pic_port *port, const char *str)
|
||||||
{
|
{
|
||||||
PIC_UNUSED(str);
|
PIC_UNUSED(str);
|
||||||
|
|
||||||
return pic_list2(pic, pic_sym_value(pic->sUNQUOTE), read(pic, port, next(port)));
|
return pic_list2(pic, pic_obj_value(pic->sUNQUOTE), read(pic, port, next(port)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -190,7 +190,7 @@ read_unquote_splicing(pic_state *pic, struct pic_port *port, const char *str)
|
||||||
{
|
{
|
||||||
PIC_UNUSED(str);
|
PIC_UNUSED(str);
|
||||||
|
|
||||||
return pic_list2(pic, pic_sym_value(pic->sUNQUOTE_SPLICING), read(pic, port, next(port)));
|
return pic_list2(pic, pic_obj_value(pic->sUNQUOTE_SPLICING), read(pic, port, next(port)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -226,7 +226,7 @@ read_symbol(pic_state *pic, struct pic_port *port, const char *str)
|
||||||
sym = pic_intern_cstr(pic, buf);
|
sym = pic_intern_cstr(pic, buf);
|
||||||
pic_free(pic, buf);
|
pic_free(pic, buf);
|
||||||
|
|
||||||
return pic_sym_value(sym);
|
return pic_obj_value(sym);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
|
@ -490,7 +490,7 @@ read_pipe(pic_state *pic, struct pic_port *port, const char *str)
|
||||||
sym = pic_intern_cstr(pic, buf);
|
sym = pic_intern_cstr(pic, buf);
|
||||||
pic_free(pic, buf);
|
pic_free(pic, buf);
|
||||||
|
|
||||||
return pic_sym_value(sym);
|
return pic_obj_value(sym);
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
|
|
@ -32,7 +32,7 @@ pic_value
|
||||||
pic_record_ref(pic_state *pic, struct pic_record *rec, pic_sym slot)
|
pic_record_ref(pic_state *pic, struct pic_record *rec, pic_sym slot)
|
||||||
{
|
{
|
||||||
if (! pic_dict_has(pic, rec->data, slot)) {
|
if (! pic_dict_has(pic, rec->data, slot)) {
|
||||||
pic_errorf(pic, "slot named ~s is not found for record: ~s", pic_sym_value(slot), rec);
|
pic_errorf(pic, "slot named ~s is not found for record: ~s", pic_obj_value(slot), rec);
|
||||||
}
|
}
|
||||||
return pic_dict_ref(pic, rec->data, slot);
|
return pic_dict_ref(pic, rec->data, slot);
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ pic_symbol_string_to_symbol(pic_state *pic)
|
||||||
|
|
||||||
pic_get_args(pic, "s", &str);
|
pic_get_args(pic, "s", &str);
|
||||||
|
|
||||||
return pic_sym_value(pic_intern(pic, str));
|
return pic_obj_value(pic_intern(pic, str));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -17,7 +17,7 @@ is_tagged(pic_state *pic, pic_sym tag, pic_value pair)
|
||||||
{
|
{
|
||||||
return pic_pair_p(pic_cdr(pic, pair))
|
return pic_pair_p(pic_cdr(pic, pair))
|
||||||
&& pic_nil_p(pic_cddr(pic, pair))
|
&& pic_nil_p(pic_cddr(pic, pair))
|
||||||
&& pic_eq_p(pic_car(pic, pair), pic_sym_value(tag));
|
&& pic_eq_p(pic_car(pic, pair), pic_obj_value(tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
Loading…
Reference in New Issue