gencomp 確認 (10)
compile-toplevel-form 手続きのコメントを読んでみます。
gencomp が compile された code のための C なリテラルを生成する時、以下の mapping scheme を使う。
1.compile された code からニーモニックを取り出すのに vm-code->list を使う
2.ニーモニックを target な compiler の code に map するために vm-find-insn-info を使う
ええと、vm-code->list は gauche.internal にて定義。実体はどこだ。
と言いつつ以下なソレが出てきた。intlib.stub にて以下。
(define-cproc vm-code->list (code::<compiled-code>) (call "Scm_CompiledCodeToList"))
.stub って何だば、と言いつつ src/Makefile 見たらルール設定してます。
.stub.c: $(HOSTGOSH) ./genstub -D LIBGAUCHE_BODY $<
以下なコメントあり。
;; Create a subr function. Body can be: ;; (code <C-code> ...) ;; <C-code> is inserted at this position. Useful to insert ;; extra code before 'call' or 'expr' spec. ;; (call [<rettype>] <C-function-name>) ;; Calls C-function. If <rettype> is omitted, C-function ;; is assumed to return ScmObj. Otherwise, a boxer of ;; <rettype> is used. As a special case, if <rettype> is ;; <void>, the return value of C-function is ignored and ;; the function returns #<undef>. (ry
で、上記の Scm_CompiledCodeToList の定義は code.c にある模様。中身の確認は別途で、次の vm-find-insn-info は lib/gauche/vm/insn.scm にて定義されている模様。
;; opcode mnemonic -> <vm-insn-info> (define (vm-find-insn-info mnemonic) (cond ((assq mnemonic (class-slot-ref <vm-insn-info> 'all-insns)) => cdr) (else (error "No such VM instruction:" mnemonic))))
中身確認は別途で。今日は (も) へろへろなのでもう寝ます。ちなみに明日のエントリ投入も微妙な情勢。昼間に上記の手続き読んでナニする可能性はあるかも (何