Skip to content

h8gi/rgors

Repository files navigation

scheme on golang

heap based

registers

a
the accumulator,
x
the next expression,
e
the current environment,
r
the current value rib, and
s
the current stack.

a : accumulator

定数や変数の値をのせる。 関数への実引数を保存。 ifのテスト。計算の最終結果。

x : next expression

次の命令。素のschemeではなく、コンパイル済みのものを使用する。

e : current environment

関数適用(application)で一旦消える。どこかに保存する… (((var …) . (val …)) . parentenv)

r : current value rib

よくわからん。関数の引数列の保存?

s : current stack

call frame の保存。applicationスタートの前に追加される。return で削除(pop?) call/ccで保存される?

Assembly code

(halt)

仮想マシンを停止。 accumulatorの値を計算全体の返り値とする。

(refer var x)

現在の環境からvarを探索し accumulatorに。次のxへ。

(constant obj x)

accumulatorにobjを。xへ

(close vars body x )

vars,body,envからクロージャを作成し、accumulatorにセット。 xへ

(test then else)

accumulatorを真偽値とし、thenかelseへ

(assign var x)

現在の環境で、変数varが束縛されている場所の値を変更する。 値はaccumulator。xへ。

(conti x)

creates a continuation from the current stack, places this continuation in the accumulator, and sets the next expression to x.

(nuate s var)

restores s to be the current stack, sets the accumulator to the value of var in the current environment, and sets the next expression to (return) (see below).

(frame x ret)

環境,rib,retからフレームを作り、stackに積む。 現在のripは空に

(argument x)

accumulatorを現在のribに追加 xへ。

(apply)

accumulatorのclosureをribにapply applies the closure in the accumulator to the list of values in the current rib. Precisely, this instruction extends the closure’s environment with the closure’s variable list and the current rib, sets the current environment to this new environment, sets the current rib to the empty list, and sets the next expression to the closure’s body.

(return)

removes the first frame from the stack and resets the current environment, the current rib, the next expression, and the current stack.

links

three imp

情報科学実験 II: Scheme言語処理系の作成

About

scheme on golang

Resources

Stars

Watchers

Forks

Packages

No packages published