開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Scheme (プログラミング言語)
- MIT/GNU Scheme (処理系)
計算機プログラムの構造と解釈(Gerald Jay Sussman(原著)、Julie Sussman(原著)、Harold Abelson(原著)、和田 英一(翻訳)、ピアソンエデュケーション、原書: Structure and Interpretation of Computer Programs (MIT Electrical Engineering and Computer Science)(SICP))の5(レジスタ計算機での計算)、5.5(翻訳系)、翻訳系の概観、5.5.5(翻訳したコードの例)、問題 5.38-a.を解いてみる。
その他参考書籍
問題 5.38-a.
コード(BBEdit)
sample.scm
(define (spread-arguments operand-codes)
(if (null? operand-codes)
(make-instruction-sequence
'((assign arg1 (const ()))
(assign arg2 (const ()))))
(let ((op1 (compile (car operand-codes) 'arg1 'next))
(op2 (compile (cadr operand-codes) 'arg2 'next)))
(append-instruction-sequences
op1
(append-instruction-sequences
(make-instruction-sequence '(arg1) '() '((save arg1)))
(append-instruction-sequences
op2
(make-instruction-sequence '() '(arg1) '((restore arg1)))))))))
0 コメント:
コメントを投稿