2013年12月10日火曜日

開発環境

計算機プログラムの構造と解釈(Gerald Jay Sussman(原著)、Julie Sussman(原著)、Harold Abelson(原著)、和田 英一(翻訳)、ピアソンエデュケーション、原書: Structure and Interpretation of Computer Programs (MIT Electrical Engineering and Computer Science)(SICP))の5(レジスタ計算機での計算)、5.4(積極制御評価器)、5.4.1(積極制御評価器の中核)、単純式の評価、手続き作用の評価、手続き作用、5.4.2(並びの評価と末尾再帰)、末尾再帰、5.4.3(条件式、代入および定義)、代入と定義、問題 5.25.を解いてみる。

その他参考書籍

問題 5.25.

修正、追加箇所。

;;
ev-application
  (save continue)
  (save env)
  (assign unev (op operands) (reg exp))
  (save unev)
  (assign exp (op operator) (reg exp))
  (assign continue (label ev-appl-did-operator))
  (goto (label ev-actual-value))
ev-application
  (save continue)
  (save env)
  (assign unev (op operands) (reg exp))
  (save unev)
  (assign exp (op operator) (reg exp))
  (assign continue (label ev-appl-did-operator))
  (goto (label ev-actual-value))
ev-appl-did-operator
  (restore unev)
  (restore env)
  (assign argl (op empty-arglist))
  (assign proc (reg val))
  (test (op no-operands?) (reg unev))
  (branch (label apply-dispatch))
  (save proc)
ev-appl-operand-loop
  (save argl)
  (assign exp (op first-operand) (reg unev))
  (test (op last-operand?) (reg unev))
  (branch (label ev-appl-last-arg))
  (assign continue (label ev-appl-accumulate-arg))
  (restore argl)
  (restore proc)
  (save proc)
  (save argl)
  (test (op compound-procedure?) (reg proc))
  (branch (label ev-delay-it))
  (goto (label actual-value))
;;
ev-appl-last-arg
  (assign continue (label ev-appl-accum-last-arg))
  (restore argl)
  (restore proc)
  (save proc)
  (save argl)
  (test (op compound-procedure?) (reg proc))
  (branch (label delay-it))
  (goto (label actual-value))
;;
ev-actual-value
  (save continue)
  (save env)
  (save exp)
  (assign continue (label ev-force-it))
  (goto (label eval-dispatch))
ev-force-it
  (test (op thunk?) (reg val)
  (branch (label ev-thunk))
  (restore exp)
  (restore env)
  (restore continue)
  (goto (reg continue))
ev-thunk
  (assign exp (op thunk-exp) (reg val))
  (assign env (op thunk-env) (reg val))
  (goto (label ev-actual-value))
ev-delay-it
  (assign val (op delay-it) (reg exp) (reg env))
  (goto (reg continue))

まだ積極制御評価器の実装し終わってないから、実装したら入出力も試してみることに。

0 コメント:

コメントを投稿