From bcb58f0326c205e40a084bfe42b6e79b1fa69f43 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 14 Oct 2018 07:38:51 +0200 Subject: [PATCH] core: Add cstring_to_symbol. * src/mes.c (make_symbol): Rename from lookup_symbol_. Update callers. (cstring_to_symbol): New function. * src/reader.c (reader_read_identifier_or_number): Use it. --- build-aux/mes-snarf.scm | 4 ++-- mes/module/mes/type-0.mes | 3 --- src/mes.c | 8 +++++++- src/reader.c | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/build-aux/mes-snarf.scm b/build-aux/mes-snarf.scm index 910ccdee..1bc4ffc6 100755 --- a/build-aux/mes-snarf.scm +++ b/build-aux/mes-snarf.scm @@ -146,8 +146,8 @@ exec ${GUILE-guile} --no-auto-compile -L $(dirname $0) -C $(dirname $0) -e '(mes (format #f "g_cells[cell_~a].string = MAKE_STRING (scm_~a.string);\n" (function.name f) (function.name f)) (format #f "g_cells[cell_~a].car = MAKE_STRING (scm_~a.car);\n" (function.name f) (function.name f))) (if %gcc? - (format #f "a = acons (lookup_symbol_ (scm_~a.string), ~a, a);\n\n" (function.name f) (function-cell-name f)) - (format #f "a = acons (lookup_symbol_ (scm_~a.car), ~a, a);\n\n" (function.name f) (function-cell-name f))))) + (format #f "a = acons (make_symbol (scm_~a.string), ~a, a);\n\n" (function.name f) (function-cell-name f)) + (format #f "a = acons (make_symbol (scm_~a.car), ~a, a);\n\n" (function.name f) (function-cell-name f))))) (define (disjoin . predicates) (lambda (. arguments) diff --git a/mes/module/mes/type-0.mes b/mes/module/mes/type-0.mes index 5c710215..a7b1059c 100644 --- a/mes/module/mes/type-0.mes +++ b/mes/module/mes/type-0.mes @@ -128,9 +128,6 @@ (define (symbol->keyword s) (core:make-cell (symbol->list s) 0)) -(define (list->symbol lst) - (core:lookup-symbol lst)) - (define (symbol->list s) (core:car s)) diff --git a/src/mes.c b/src/mes.c index 1d0fbe76..b1c405a1 100644 --- a/src/mes.c +++ b/src/mes.c @@ -415,7 +415,7 @@ list_of_char_equal_p (SCM a, SCM b) ///((internal)) } SCM -lookup_symbol_ (SCM s) +list_to_symbol (SCM s) { SCM x = g_symbols; while (x) @@ -585,6 +585,12 @@ cstring_to_list (char const* s) return string_to_list (s, strlen (s)); } +SCM +cstring_to_symbol (char const *s) +{ + return list_to_symbol (cstring_to_list (s)); +} + // extra lib SCM assert_defined (SCM x, SCM e) ///((internal)) diff --git a/src/reader.c b/src/reader.c index b85c35bc..99b25fdf 100644 --- a/src/reader.c +++ b/src/reader.c @@ -103,7 +103,7 @@ reader_read_identifier_or_number (int c) } unreadchar (c); buf[i] = 0; - return lookup_symbol_ (cstring_to_list (buf)); + return cstring_to_symbol (buf); } SCM