diff --git a/include/chibi/sexp.h b/include/chibi/sexp.h index 16f0488f..1be0e3f2 100755 --- a/include/chibi/sexp.h +++ b/include/chibi/sexp.h @@ -1181,6 +1181,7 @@ SEXP_API sexp sexp_substring_op (sexp ctx, sexp self, sexp_sint_t n, sexp str, s SEXP_API sexp sexp_string_concatenate_op (sexp ctx, sexp self, sexp_sint_t n, sexp str_ls, sexp sep); SEXP_API sexp sexp_intern (sexp ctx, const char *str, sexp_sint_t len); SEXP_API sexp sexp_string_to_symbol_op (sexp ctx, sexp self, sexp_sint_t n, sexp str); +SEXP_API sexp sexp_symbol_to_string_op (sexp ctx, sexp self, sexp_sint_t n, sexp sym); SEXP_API sexp sexp_string_to_number_op (sexp ctx, sexp self, sexp_sint_t n, sexp str, sexp b); SEXP_API sexp sexp_flonump_op (sexp ctx, sexp self, sexp_sint_t n, sexp x); SEXP_API sexp sexp_make_vector_op (sexp ctx, sexp self, sexp_sint_t n, sexp len, sexp dflt); diff --git a/opcodes.c b/opcodes.c index 8e47d6c1..559ce331 100644 --- a/opcodes.c +++ b/opcodes.c @@ -161,6 +161,7 @@ _FN2OPT(_I(SEXP_STRING), _I(SEXP_FIXNUM), _I(SEXP_FIXNUM), "make-bytevector", SE _FN2OPT(_I(SEXP_NUMBER), _I(SEXP_STRING), _I(SEXP_FIXNUM), "string->number", SEXP_TEN, sexp_string_to_number_op), _FN3(_I(SEXP_FIXNUM), _I(SEXP_STRING), _I(SEXP_STRING), _I(SEXP_BOOLEAN), "string-cmp", 0, sexp_string_cmp_op), _FN1(_I(SEXP_SYMBOL), _I(SEXP_STRING), "string->symbol", 0, sexp_string_to_symbol_op), +_FN1(_I(SEXP_STRING), _I(SEXP_SYMBOL), "symbol->string", 0, sexp_symbol_to_string_op), _FN2OPT(_I(SEXP_STRING), SEXP_NULL, _I(SEXP_STRING), "string-concatenate", SEXP_FALSE, sexp_string_concatenate_op), _FN2(_I(SEXP_OBJECT), _I(SEXP_OBJECT), SEXP_NULL, "memq", 0, sexp_memq_op), _FN2(_I(SEXP_OBJECT), _I(SEXP_OBJECT), SEXP_NULL, "assq", 0, sexp_assq_op), diff --git a/sexp.c b/sexp.c index 44e18590..1fe7fc81 100644 --- a/sexp.c +++ b/sexp.c @@ -2620,6 +2620,14 @@ sexp sexp_write_to_string (sexp ctx, sexp obj) { return str; } +sexp sexp_symbol_to_string_op (sexp ctx, sexp self, sexp_sint_t n, sexp sym) { +#if SEXP_USE_HUFF_SYMS + if (sexp_isymbolp(sym)) return sexp_write_to_string(ctx, sym); +#endif + sexp_assert_type(ctx, sexp_lsymbolp, SEXP_SYMBOL, sym); + return sexp_c_string(ctx, sexp_symbol_data(sym), sexp_symbol_length(sym)); +} + void sexp_init (void) { #if SEXP_USE_GLOBAL_SYMBOLS int i;