58 lines
1.5 KiB
Markdown
58 lines
1.5 KiB
Markdown
|
---
|
|||
|
date: 2024-10-20 12:02
|
|||
|
---
|
|||
|
#mimium
|
|||
|
|
|||
|
ツリー形式からBasicBlockのインストラクション形式に変える
|
|||
|
|
|||
|
Stateのこととupvalueを両方処理しなくてはならない
|
|||
|
|
|||
|
StateSize計算とUpvalue計算の両方をtraitとして切り出す方がいいのかな
|
|||
|
|
|||
|
|
|||
|
## 値
|
|||
|
|
|||
|
$$
|
|||
|
\begin{align}
|
|||
|
v \; ::= & \quad R \\
|
|||
|
| & (\lambda x:\tau.e, [\Gamma, x:e],StateStorage(p,Vec)) \quad & [Closure]\\
|
|||
|
\end{align}
|
|||
|
$$
|
|||
|
|
|||
|
$$
|
|||
|
\begin{align}
|
|||
|
e \; ::=& \quad x \quad x \in \mathbb{V} \quad & [value]\\
|
|||
|
|& \quad \lambda x.e \quad & [lambda]\\
|
|||
|
|& \quad e \; e \quad & [app(global,stateful)]\\
|
|||
|
|& \quad appcls \; e \; e \quad & [appclosure]\\
|
|||
|
|& \quad fix \; x.e \quad & [fixpoint]\\
|
|||
|
|& \quad getstate \; e \; I_n \; I_s \quad & [feed] \\
|
|||
|
|& \quad delay \; e \; e & [delay]\\
|
|||
|
\end{align}
|
|||
|
$$
|
|||
|
|
|||
|
結局[[The w-calculus a synchronous framework for the verified modelling of digital signal processing algorithms|W計算]]のStaged Interpreterと変わらんかもな
|
|||
|
|
|||
|
そうすると型付けの時点でクロージャ相当の項とグローバル関数適用の項は分かれることになる?エフェクトとして考えるのが妥当なのかな
|
|||
|
|
|||
|
## 型
|
|||
|
|
|||
|
$$
|
|||
|
\begin{align}
|
|||
|
\tau ::=&\quad R_a \quad & a \in \mathbb{N}\\
|
|||
|
|&\quad I_n \quad &n \in \mathbb{N} \\\
|
|||
|
|&\quad \tau → \tau \quad \\
|
|||
|
% |&\quad \langle \tau \rangle
|
|||
|
\end{align}
|
|||
|
$$
|
|||
|
|
|||
|
## コンパイル
|
|||
|
|
|||
|
```ocaml
|
|||
|
let compiler = fun e -> match e with
|
|||
|
Id(x) ->
|
|||
|
| App(e1,e2)->
|
|||
|
| Feed(x,e) ->
|
|||
|
|
|||
|
|
|||
|
```
|