| 1 |
;;; |
| 2 |
;;; Generates builtin symbols |
| 3 |
;;; |
| 4 |
|
| 5 |
(use scheme.list) |
| 6 |
(use file.util) |
| 7 |
(use gauche.cgen) |
| 8 |
(use gauche.sequence) |
| 9 |
|
| 10 |
(define *unit* |
| 11 |
(make <cgen-unit> |
| 12 |
:name "builtin-syms" |
| 13 |
:preamble "/* Generated from builtin-syms.scm. DO NOT EDIT\n\ |
| 14 |
This file may be changed by minor version up, and\n\ |
| 15 |
binaries including builtin-syms.h must be recompiled.\n\ |
| 16 |
That is, binary compatibility isn't guaranteed if you\n\ |
| 17 |
use SCM_SYM_*. */" |
| 18 |
:c-file "builtin-syms.c" |
| 19 |
:h-file "gauche/priv/builtin-syms.h" |
| 20 |
:init-prologue "static void init_builtin_syms(void)\n{" |
| 21 |
:init-epilogue "}" |
| 22 |
)) |
| 23 |
|
| 24 |
(define (main args) |
| 25 |
(parameterize ([cgen-current-unit *unit*]) |
| 26 |
(cgen-decl "#define LIBGAUCHE_BODY" |
| 27 |
"#include <gauche.h>" |
| 28 |
"#include <gauche/priv/configP.h>") |
| 29 |
|
| 30 |
(cgen-extern "SCM_EXTERN ScmSymbol Scm_BuiltinSymbols[];") |
| 31 |
(cgen-body "ScmSymbol Scm_BuiltinSymbols[] = {") |
| 32 |
(cgen-body "#define ENTRY(s) \ |
| 33 |
{{ SCM_CLASS_STATIC_TAG(Scm_SymbolClass) }, \ |
| 34 |
SCM_STRING(s), SCM_SYMBOL_FLAG_INTERNED }") |
| 35 |
(cgen-init "#define INTERN(s, i) \ |
| 36 |
Scm_HashTableSet(obtable, s, SCM_OBJ(&Scm_BuiltinSymbols[i]), 0)") |
| 37 |
|
| 38 |
(for-each-with-index |
| 39 |
(^[index entry] |
| 40 |
(let* ([str (cgen-literal (symbol->string (car entry)))] |
| 41 |
[strref (cgen-cexpr str)] |
| 42 |
[macro-name (cadr entry)]) |
| 43 |
(cgen-extern (format "#define ~a SCM_OBJ(&Scm_BuiltinSymbols[~a])" |
| 44 |
macro-name index)) |
| 45 |
(cgen-body (format "ENTRY(~a)," strref)) |
| 46 |
(cgen-init (format "INTERN(~a, ~a);" strref index)) |
| 47 |
)) |
| 48 |
(symbols)) |
| 49 |
|
| 50 |
(cgen-body "#undef ENTRY") |
| 51 |
(cgen-body "};") |
| 52 |
(cgen-init "#undef INTERN") |
| 53 |
|
| 54 |
(make-directory* "gauche/priv/") |
| 55 |
(cgen-emit-h (cgen-current-unit)) |
| 56 |
(cgen-emit-c (cgen-current-unit)) |
| 57 |
0)) |
| 58 |
|
| 59 |
;; add predefined symbols below ------------------------------- |
| 60 |
|
| 61 |
(define (symbols) |
| 62 |
'((quote SCM_SYM_QUOTE) |
| 63 |
(quasiquote SCM_SYM_QUASIQUOTE) |
| 64 |
(unquote SCM_SYM_UNQUOTE) |
| 65 |
(unquote-splicing SCM_SYM_UNQUOTE_SPLICING) |
| 66 |
(define SCM_SYM_DEFINE) |
| 67 |
(define-constant SCM_SYM_DEFINE_CONSTANT) |
| 68 |
(define-in-module SCM_SYM_DEFINE_IN_MODULE) |
| 69 |
(lambda SCM_SYM_LAMBDA) |
| 70 |
(if SCM_SYM_IF) |
| 71 |
(set! SCM_SYM_SET) |
| 72 |
(let SCM_SYM_LET) |
| 73 |
(let* SCM_SYM_LET_STAR) |
| 74 |
(letrec SCM_SYM_LETREC) |
| 75 |
(begin SCM_SYM_BEGIN) |
| 76 |
(when SCM_SYM_WHEN) |
| 77 |
(unless SCM_SYM_UNLESS) |
| 78 |
(and SCM_SYM_AND) |
| 79 |
(or SCM_SYM_OR) |
| 80 |
(cond SCM_SYM_COND) |
| 81 |
(case SCM_SYM_CASE) |
| 82 |
(else SCM_SYM_ELSE) |
| 83 |
(=> SCM_SYM_YIELDS) |
| 84 |
(do SCM_SYM_DO) |
| 85 |
(delay SCM_SYM_DELAY) |
| 86 |
(receive SCM_SYM_RECEIVE) |
| 87 |
(define-module SCM_SYM_DEFINE_MODULE) |
| 88 |
(with-module SCM_SYM_WITH_MODULE) |
| 89 |
(select-module SCM_SYM_SELECT_MODULE) |
| 90 |
(current-module SCM_SYM_CURRENT_MODULE) |
| 91 |
(import SCM_SYM_IMPORT) |
| 92 |
(export SCM_SYM_EXPORT) |
| 93 |
(rename SCM_SYM_RENAME) |
| 94 |
(define-macro SCM_SYM_DEFINE_MACRO) |
| 95 |
(define-syntax SCM_SYM_DEFINE_SYNTAX) |
| 96 |
(let-syntax SCM_SYM_LET_SYNTAX) |
| 97 |
(letrec-syntax SCM_SYM_LETREC_SYNTAX) |
| 98 |
(%syntax-rules SCM_SYM_SYNTAX_RULES_INT) |
| 99 |
(syntax-rules SCM_SYM_SYNTAX_RULES) |
| 100 |
(... SCM_SYM_ELLIPSIS) |
| 101 |
(_ SCM_SYM_UNDERBAR) |
| 102 |
(%macroexpand SCM_SYM_MACRO_EXPAND) |
| 103 |
(%macroexpand-1 SCM_SYM_MACRO_EXPAND_1) |
| 104 |
(%asm SCM_SYM_ASM) |
| 105 |
(name SCM_SYM_NAME) |
| 106 |
|
| 107 |
;; class category |
| 108 |
(builtin SCM_SYM_BUILTIN) |
| 109 |
(abstract SCM_SYM_ABSTRACT) |
| 110 |
(base SCM_SYM_BASE) |
| 111 |
|
| 112 |
;; proc |
| 113 |
(curried SCM_SYM_CURRIED) |
| 114 |
|
| 115 |
;; core |
| 116 |
(*cond-features* SCM_SYM_COND_FEATURES) |
| 117 |
|
| 118 |
;; modules |
| 119 |
(null SCM_SYM_NULL) |
| 120 |
(scheme SCM_SYM_SCHEME) |
| 121 |
(gauche SCM_SYM_GAUCHE) |
| 122 |
(gauche.gf SCM_SYM_GAUCHE_GF) |
| 123 |
(gauche.internal SCM_SYM_GAUCHE_INTERNAL) |
| 124 |
(keyword SCM_SYM_KEYWORD) |
| 125 |
(user SCM_SYM_USER) |
| 126 |
(|\x23| SCM_SYM_SHARP) ; |#| confuses emacs |
| 127 |
|
| 128 |
;; load |
| 129 |
(*load-path* SCM_SYM_LOAD_PATH) |
| 130 |
(*load-next* SCM_SYM_LOAD_NEXT) |
| 131 |
(*load-history* SCM_SYM_LOAD_HISTORY) |
| 132 |
(*load-port* SCM_SYM_LOAD_PORT) |
| 133 |
(*load-suffixes* SCM_SYM_LOAD_SUFFIXES) |
| 134 |
(*load-path-hooks* SCM_SYM_LOAD_PATH_HOOKS) |
| 135 |
(*dynamic-load-path* SCM_SYM_DYNAMIC_LOAD_PATH) |
| 136 |
|
| 137 |
;; reader, writer, compiler, vm |
| 138 |
(source-info SCM_SYM_SOURCE_INFO) |
| 139 |
(bind-info SCM_SYM_BIND_INFO) |
| 140 |
(arg-info SCM_SYM_ARG_INFO) |
| 141 |
(debug-print SCM_SYM_DEBUG_PRINT) |
| 142 |
(debug-funcall SCM_SYM_DEBUG_FUNCALL) |
| 143 |
(debug-thread-log SCM_SYM_DEBUG_THREAD_LOG) |
| 144 |
(debug-print-conditionally SCM_SYM_DEBUG_PRINT_CONDITIONALLY) |
| 145 |
(debug-funcall-conditionally SCM_SYM_DEBUG_FUNCALL_CONDITIONALLY) |
| 146 |
(define-reader-ctor SCM_SYM_DEFINE_READER_CTOR) |
| 147 |
(string-interpolate SCM_SYM_STRING_INTERPOLATE) |
| 148 |
(big-endian SCM_SYM_BIG_ENDIAN) ;; for binary.io, uvector |
| 149 |
(little-endian SCM_SYM_LITTLE_ENDIAN) ;; ditto |
| 150 |
(big SCM_SYM_BIG) |
| 151 |
(little SCM_SYM_LITTLE) |
| 152 |
(arm-little-endian SCM_SYM_ARM_LITTLE_ENDIAN) ;; ditto |
| 153 |
(%internal-eval SCM_SYM_INTERNAL_EVAL) |
| 154 |
(%internal-apply SCM_SYM_INTERNAL_APPLY) |
| 155 |
(%eval-before SCM_SYM_EVAL_BEFORE) |
| 156 |
(%eval-after SCM_SYM_EVAL_AFTER) |
| 157 |
(%toplevel SCM_SYM_TOPLEVEL) |
| 158 |
(syntax SCM_SYM_SYNTAX) |
| 159 |
(macro SCM_SYM_MACRO) |
| 160 |
(inline SCM_SYM_INLINE) |
| 161 |
(legacy SCM_SYM_LEGACY) |
| 162 |
(permissive SCM_SYM_PERMISSIVE) |
| 163 |
(warn-legacy SCM_SYM_WARN_LEGACY) |
| 164 |
(strict-r7 SCM_SYM_STRICT_R7) |
| 165 |
(reader-lexical-mode SCM_SYM_READER_LEXICAL_MODE) |
| 166 |
(unused-args SCM_SYM_UNUSED_ARGS) |
| 167 |
(next-method SCM_SYM_NEXT_METHOD) |
| 168 |
(source SCM_SYM_SOURCE) |
| 169 |
(definition SCM_SYM_DEFINITION) |
| 170 |
|
| 171 |
;; regexp |
| 172 |
(seq SCM_SYM_SEQ) |
| 173 |
(seq-case SCM_SYM_SEQ_CASE) |
| 174 |
(seq-uncase SCM_SYM_SEQ_UNCASE) |
| 175 |
(alt SCM_SYM_ALT) |
| 176 |
(rep SCM_SYM_REP) |
| 177 |
(rep-min SCM_SYM_REP_MIN) |
| 178 |
(rep-while SCM_SYM_REP_WHILE) |
| 179 |
(any SCM_SYM_ANY) |
| 180 |
(bos SCM_SYM_BOS) |
| 181 |
(eos SCM_SYM_EOS) |
| 182 |
(bol SCM_SYM_BOL) |
| 183 |
(eol SCM_SYM_EOL) |
| 184 |
(wb SCM_SYM_WB) |
| 185 |
(bow SCM_SYM_BOW) |
| 186 |
(eow SCM_SYM_EOW) |
| 187 |
(nwb SCM_SYM_NWB) |
| 188 |
(bog SCM_SYM_BOG) |
| 189 |
(eog SCM_SYM_EOG) |
| 190 |
(comp SCM_SYM_COMP) |
| 191 |
(* SCM_SYM_STAR) |
| 192 |
(*? SCM_SYM_STARQ) |
| 193 |
(*+ SCM_SYM_STARP) |
| 194 |
(+ SCM_SYM_PLUS) |
| 195 |
(+? SCM_SYM_PLUSQ) |
| 196 |
(++ SCM_SYM_PLUSP) |
| 197 |
(? SCM_SYM_QUESTION) |
| 198 |
(?? SCM_SYM_QUESTIONQ) |
| 199 |
(?+ SCM_SYM_QUESTIONP) |
| 200 |
(backref SCM_SYM_BACKREF) |
| 201 |
(once SCM_SYM_ONCE) |
| 202 |
(reg SCM_SYM_REG) |
| 203 |
(assert SCM_SYM_ASSERT) |
| 204 |
(nassert SCM_SYM_NASSERT) |
| 205 |
(lookbehind SCM_SYM_LOOKBEHIND) |
| 206 |
(nlookbehind SCM_SYM_NLOOKBEHIND) |
| 207 |
(cpat SCM_SYM_CPAT) |
| 208 |
(open-paren SCM_SYM_OPEN_PAREN) |
| 209 |
(close-paren SCM_SYM_CLOSE_PAREN) |
| 210 |
|
| 211 |
;; system |
| 212 |
(directory SCM_SYM_DIRECTORY) |
| 213 |
(regular SCM_SYM_REGULAR) |
| 214 |
(character SCM_SYM_CHARACTER) |
| 215 |
(block SCM_SYM_BLOCK) |
| 216 |
(fifo SCM_SYM_FIFO) |
| 217 |
(symlink SCM_SYM_SYMLINK) |
| 218 |
(socket SCM_SYM_SOCKET) |
| 219 |
(time-utc SCM_SYM_TIME_UTC) |
| 220 |
(time-duration SCM_SYM_TIME_DURATION) |
| 221 |
(called SCM_SYM_CALLED) |
| 222 |
|
| 223 |
;; source info tracking |
| 224 |
(original SCM_SYM_ORIGINAL) |
| 225 |
(error SCM_SYM_ERROR) |
| 226 |
(car SCM_SYM_CAR) |
| 227 |
(cdr SCM_SYM_CDR) |
| 228 |
(cadr SCM_SYM_CADR) |
| 229 |
(cddr SCM_SYM_CDDR) |
| 230 |
(cons SCM_SYM_CONS) |
| 231 |
(list SCM_SYM_LIST) |
| 232 |
(null? SCM_SYM_NULLP) |
| 233 |
(let1 SCM_SYM_LET1) |
| 234 |
(loop SCM_SYM_LOOP) |
| 235 |
(^ SCM_SYM_CARET) |
| 236 |
(apply SCM_SYM_APPLY) |
| 237 |
(not SCM_SYM_NOT) |
| 238 |
(eq? SCM_SYM_EQP) |
| 239 |
|
| 240 |
;; parameter arg |
| 241 |
(thread SCM_SYM_THREAD) |
| 242 |
(shared SCM_SYM_SHARED) |
| 243 |
)) |