annotate slide/index.md @ 127:96f3e9f1de35

update
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 07 Feb 2021 20:08:26 +0900
parents e1e0a87b98f8
children 6808add38dfe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 ---
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 marp: true
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 title: GearsOSのメタ計算
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 paginate: true
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 ---
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
116
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
8 # GearsOSのメタ計算
26
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 - 清水 隆博
116
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
11 - 琉球大学理工学研究科
26
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 - 198584B
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 - 河野研
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
116
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
15 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
16 # 研究発表の構成
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
17 - 研究目的
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
18 - CbC、GearsOSの基礎概念
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
19 - GearsOSの新機能
116
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
20 - 本研究での新たなGearsOSのシステムの解説
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
21 - GearsOSのInterfaceシステムの改善
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
22 - Perlトランスパイラの改善
116
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
23
26
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 ---
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 # 研究目的
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
29 - OSとアプリケーションの信頼性の保証したい
26
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 - OSそのものも巨大なプログラム
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
31 - プログラムの信頼性の保証にはテストが使われる
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
32 - 並列並行処理などのバグや、そもそもOSを構成する処理が巨大
26
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 - テストコードで信頼性を保証しきれない
116
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
34 - 形式手法を用いてテストに頼らず信頼性を保証したい
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
35 - 既存のソースコードに形式手法を導入できるフレームワークを構築したい
26
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 ---
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 # ノーマルレベルとメタレベルを用いた信頼性の向上
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 - プログラムの実行部分は以下の2つからなる
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 - 入力と出力の関係を決める計算(ノーマルレベル)
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 - プログラムを実行したり、 信頼性を保証するために必要な計算(メタレベル)
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 - メタレベルの例
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 - メモリやCPUの資源管理
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 - システムコールの動作(副作用)
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 - 並行実行(他のプロセスとの干渉)
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 - モデル検査(可能な実行を列挙する方式の実行)
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 - 証明(入力時と出力時の論理的な条件)、(invariant)
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 - メタレベルの計算として信頼性を保証する
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 ---
116
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
53 # メタレベルの計算とGearsOS
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
54 - ノーマルレベル、メタレベルを一貫して記述できる言語CbCを用いてGearsOSを開発している
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
55 - CbCを使うとメタレベルの処理を分離して書ける
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
56 - メタレベルの処理を全部手で書くのは面倒
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
57 - メタレベルの処理を自動生成してくれるフレームワークを導入したい
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
58 - フレームワークに乗って実装すると等価なCbCに変換される
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
59 - CbCレベルではメタレベルの処理とノーマルレベルの処理が見れる
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
60 - メタ計算を自分で定義できるようにしたい
124
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
61 - 実装のコードをほとんど変えずにモデル検査を導入できるようにしたい
116
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
62
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
63 ---
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
64 # GearsOSのメタ計算フレームワーク
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
65 - GearsOSはPerlを中心としたメタコード生成のフレームワークが構築されている
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
66 - 計算に必要なデータの入出力のメタ計算を主に生成していた
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
67 - メタレベルの処理は従来のものは手動で作る方が多かった
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
68 - 計算で使うすべてのデータ構造の管理
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
69 - 別のInterfaceの出力を受けるメタレベルのデータ管理など
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
70 - Perlでメタレベルに変換された後で気づくエラーも多い
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
71 - 変換する前の時点でコード自体は間違えている
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
72 - 変換されてしまった後なのでコードを見比べないと原因が不明
26
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 ---
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
75 # GearsOSのメタ計算フレームワークとInterface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
76 - CbCには無いモジュール化の仕組みとしてInterfaceがある
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
77 - Perlフレームワーク上に構築
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
78 - コンパイル時に等価な純粋なCbCに変換する
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
79 - Interfaceの機能が他の言語のInterfaceの機能とギャップがあった
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
80 - 実装していないAPIがあっても、変換前の時点でエラーが出ないなど
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
81 - Interfaceの定義ファイルもあるものと無いものがあった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
82 - トランスパイラで統一な処理が出来ない
26
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 ---
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
85 # Perlを中心としたフレームワークによるメタ計算の生成
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
86 - GearsOSの例題を作製する場合も、コピペや手書きが多発していた
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
87 - フレームワークに実装したAPIを使って自動生成に変更したい
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
88 - Interfaceの機能充実も、 メタ計算の生成もCbCで行うのは難しい
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
89 - Perlを中心としたフレームワークを活用したい
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
90 - コード変換(トランスパイル)を行うために必要な環境の整備もする必要がある
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
91 - Perlを中心としたトランスパイルシステムの整備、拡張を行った
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
92 - GearsOSのメタ計算の生成がより柔軟かつ高い信頼性で可能となった
116
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
93
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
94 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
95 # GearsOSの基礎概念
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
96 - CodeGear、DataGear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
97 - Interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
98 - GearsOSのビルドシステム
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
99 - cmake
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
100 - Perlトランスパイラ
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
101
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
102 ---
26
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 # CbCとCodeGear(ノーマルレベル)
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 - 軽量継続で表現する単位をCodeGearと呼ぶ
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 - CodeGearはCの関数とアセンブラの中間の様に使える
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 - CodeGearは返り値の型の代わりに`__code`で宣言する
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
108 ```c
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
109 __code insertTest2(struct StackTestImpl3* stackTest, struct Stack* stack, __code next(...)) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
110 String* str = &ALLOCATE(context, String)->String;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
111 str->size = 100;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
112 goto stack->push((union Data*)str, pop2Test);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
113 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
114 ```
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
115
26
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 ---
116
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
118 # DataGear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
119 - GearsOSで扱うデータの単位
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
120 - Cの構造体の形でメタレベルでは表現される
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
121 - GearsOS自体の処理にかかわるMetaDataGearが存在する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
122 - Context(プロセス)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
123 - TaskManager
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
124 - Worker
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
125 - ...
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
126 - DataGearの定義ではInterfaceシステムが使用できる
26
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 ---
117
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
129 # Context(1)
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
130 - 従来のOSのプロセスに相当する機能(MetaDataGear)
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
131 - GearsOSでcontextを触るのはメタ計算部分だけ
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
132 - ノーマルレベルではcontextに降れない
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
133 - 従来は手書きでヘッダファイルの中に定義
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
134 - context.h
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
135 - Context自体は構造体で定義されている
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
136 - Contextの要素にDataGearの型がすべてはいった共用体がある
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
137 - context.hで同様に定義
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
138 ---
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
139 # Context(2)
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
140 - GearsOSでのプログラム実行に必要な情報を持っている
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
141 - DataGearの型定義
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
142 - CodeGearの名前とStubCodeGearへの対応
119
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 118
diff changeset
143 - goto時に引数を書き込むDataGearごとの場所
117
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
144 - DataGearを管理するヒープ情報
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
145 ![w:532 h:10cm](./context.svg)
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
146
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
147
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
148 ---
116
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
149 # Interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
150 - GearsOSのモジュール化の仕組み
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
151 - Interface はある Data Gear と、それに対する操作(API)を行う Code Gear とその操作に用いる Data Gear の集合を表現する。
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
152 - JavaのInteface、Haskellの型クラスに相当する
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
153 - ContextにInterfaceの引数の保存場所がある
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
154 - goto時にStubCodeGearでデータをとってくる
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
155 - `goto interfaceName->method()`のようにAPIを呼び出す
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
156 - Perlトランスパイラが`goto meta()`に書き直す
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
157 - `goto meta`はcontextから引数を取り出すMetaCodeGearに継続させるもの
26
657784b3bae1 add slide
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158
116
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 31
diff changeset
159 ---
119
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 118
diff changeset
160 # GearsOSのビルドシステム
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
161 - CMakeとPerlを使ってビルドする
119
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 118
diff changeset
162 - CMakeはMakefileやbuild.ninjaを生成する
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
163 - Perlは2種類のスクリプトが自動的に呼ばれる
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
164 - Perlでエラーを出すとCMakeがビルドを止める
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
165 - 従来はエラーを出していなかったので怪しいコードを生成しても止まらない
120
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 119
diff changeset
166 ![w:632 h:10cm](./geasflow1.svg)
119
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 118
diff changeset
167
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 118
diff changeset
168 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 118
diff changeset
169 # GearsOSのビルドシステム
121
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
170 - generate_stub.pl
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
171 - GearsOSで拡張したCbCを1行ずつ読む
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
172 - 純粋なCbCに変形したものを生成する
120
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 119
diff changeset
173 - CbCコンパイラがコンパイルする前にコードを変換する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 119
diff changeset
174 - ユーザーが書いたGearsOSのソースコードにメタ情報をつける
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
175 - コードからコードを生成する、トランスパイラ
121
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
176 - generate\_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
177 - Contextに関係するファイルを生成する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
178 - Contextの初期化ルーチン
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
179 - CodeGear/DataGearの番号(enum)
120
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 119
diff changeset
180 - 変換したプロジェクトで使うすべてのCbCファイルを入力で受け取る
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 119
diff changeset
181 - すべてのCbCファイルを読み込み、使用しているCodeGearなどの情報を取得
119
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 118
diff changeset
182
117
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
183
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
184
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
185 ---
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
186 # 主なGearsOSに導入された新機能
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
187 - Interfaceシステムの強化
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
188 - 手書きからの解放
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
189 - MetaCodeGearの入れ替え機能の追加
121
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
190
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
191 ---
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
192 # Interfaceシステムの強化
121
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
193 - Interface構文の簡素化
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
194 - より簡潔に明確に記述できるように定義した。
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
195 - Interfaceの実装の型の導入
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
196 - GearsOSでの型定義の方法に一貫性が生まれた
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
197 - Interfaceの引数の確認
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
198 - Interfaceで未定義のAPIの検知
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
199 - InterfaceにないAPIの呼び出しの検知
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
200 - コード変換前にPerlレベルでエラーを発生させた
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
201 ---
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
202 # 手書きからの解放
121
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
203 - Interfaceの雛形ファイルの作製スクリプトの導入
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
204 - 別のInterfaceからの出力を取得するStubの自動生成
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
205 - 実装のCodeGear名からメタ情報の切り離し
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
206 - メタな型情報はビルド時に付与される
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
207 - DataGearの型集合ファイルであるcontext.hの自動生成
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
208 - GearsOSの初期化ルーチンの自動生成
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
209
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
210 ---
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
211 # GearsOSの新機能
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
212 - **自由なMetaCodeGearの作製、継続の入れ替え機能**
121
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
213 - Perlトランスパイラの変換ルーチンのデバッグ機能の追加
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
214 - ジェネリクスのサポート
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
215
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 120
diff changeset
216
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
217 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
218 # Interfaceの改良
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
219 - 従来のInterfaceにまつわるPerlのフレームワークを改良した
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
220 - CbCの変換後のコードでなく、Perlレベルでエラー検知可能になった
117
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
221
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
222 ---
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
223 # Interfaceの定義構文の改良
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
224 - 従来は引数とCodeGearの定義を別けて記述していた
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
225 - Interfaceの宣言なので、書ける変数は引数/出力のもののみ
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
226 - Javaのクラス変数やインスタンス変数のようなものだと思われてしまった
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
227 - GearsOSに慣れてない
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
228 - シンタックスが問題
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
229 - シンタックスをgolangやJavaのInterfaceを参考に簡潔なものにした
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
230
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
231
117
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
232 ---
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
233 # 従来のInterface
124
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
234 - 引数の組とAPI(CodeGear)は別けて記述する必要があった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
235 ```c
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
236 typedef struct Stack<Type, Impl>{
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
237 union Data* stack;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
238 union Data* data;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
239 union Data* data1;
117
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
240
124
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
241
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
242 __code whenEmpty(...);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
243 __code clear(Impl* stack,__code next(...));
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
244 __code push(Impl* stack,Type* data, __code next(...));
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
245 __code pop(Impl* stack, __code next(Type* data, ...));
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
246 __code pop2(Impl* stack, __code next(Type* data, Type* data1, ...));
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
247 __code isEmpty(Impl* stack, __code next(...), __code whenEmpty(...));
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
248 __code get(Impl* stack, __code next(Type* data, ...));
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
249 __code get2(Impl* stack, __code next(Type* data, Type* data1, ...));
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
250 __code next(...);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
251 } Stack;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
252 ```
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
253
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
254 ---
117
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
255 # 定義し直したInterface構文
124
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
256 - APIのみを記述すれば良くなった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
257 ```c
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
258 typedef struct Stack<>{
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
259 __code whenEmpty(...);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
260 __code clear(Impl* stack,__code next(...));
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
261 __code push(Impl* stack,Type* data, __code next(...));
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
262 __code pop(Impl* stack, __code next(Type* data, ...));
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
263 __code pop2(Impl* stack, __code next(Type* data, Type* data1, ...));
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
264 __code isEmpty(Impl* stack, __code next(...), __code whenEmpty(...));
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
265 __code get(Impl* stack, __code next(Type* data, ...));
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
266 __code get2(Impl* stack, __code next(Type* data, Type* data1, ...));
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
267 __code next(...);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
268 } Stack;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
269 ```
117
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
270
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
271 ---
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
272 # Implementの型定義ファイルの導入
124
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
273 - Interfaceは型定義ファイルがあったが、実装側はなかった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
274 - context.h上にメタな構造体に直した実装の型を手で書いていた
117
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
275 - これはメタ情報なので手で書きたくない
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
276 - 型定義の一貫性がない
124
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
277 - 実装側にも型定義ファイルを導入して一貫性を持たせたい
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
278 - Perlトランスパイラフレームワークで利用可能
117
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
279
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
280 ---
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
281 # Implementの型定義
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
282 - 基本はInterfaceと同じシンタックス
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
283 - どのInterfaceを実装しているかを`Impl`の後ろに書く
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
284 - Implの場合はフィールド変数を定義できる
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
285 - `実装名.h`の命名規則 (`PhilsImp.h` )
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
286 ```c
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
287 typedef struct PhilsImpl <> impl Phils {
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
288 int self;
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
289 struct AtomicT_int* Leftfork;
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
290 struct AtomicT_int* Rightfork;
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
291 __code next(...);
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
292 } PhilsImpl;
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
293 ```
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
294 ---
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
295 # Interfaceの実装時の型名の省略
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
296 - 従来は型名を必ず書かなければならなかった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
297 - これはメタ情報なので変換時に書き換える
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
298 ### 従来
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
299
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
300 ```c
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
301 __code pickup_lforkPhilsImpl(struct PhilsImpl* phils, __code next(...)) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
302 struct AtomicT_int* left_fork = phils->Leftfork;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
303 goto left_fork->checkAndSet(-1, phils->self, pickup_rforkPhilsImpl, eatingPhilsImpl);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
304
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
305 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
306 ```
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
307 ### 現在
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
308
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
309 ```c
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
310 __code pickup_lfork(struct PhilsImpl* phils, __code next(...)) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
311 struct AtomicT_int* left_fork = phils->Leftfork;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
312 goto left_fork->checkAndSet(-1, phils->self, pickup_rfork, eating);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
313
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
314 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
315 ```
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
316
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
317 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
318 ### トランスパイル前
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
319 ```c
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
320 __code pickup_lfork(struct PhilsImpl* phils, __code next(...)) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
321 struct AtomicT_int* left_fork = phils->Leftfork;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
322 goto left_fork->checkAndSet(-1, phils->self, pickup_rfork, eating);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
323
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
324 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
325 ```
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
326 ### トランスパイル後
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
327 ```c
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
328 __code pickup_lforkPhilsImpl(struct Context *context,struct PhilsImpl* phils, enum Code next) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
329 struct AtomicT_int* left_fork = phils->Leftfork;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
330 Gearef(context, AtomicT_int)->atomicT_int = (union Data*) left_fork;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
331 Gearef(context, AtomicT_int)->oldData = -1;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
332 Gearef(context, AtomicT_int)->newData = phils->self;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
333 Gearef(context, AtomicT_int)->next = C_pickup_rforkPhilsImpl;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
334 Gearef(context, AtomicT_int)->fail = C_eatingPhilsImpl;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
335 goto meta(context, left_fork->checkAndSet);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
336
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
337 }
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
338 ```
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
339 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
340 # Interfaceのパーサーの導入
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
341 - PerlでのInterfaceの情報の取得は、CbC自体のファイルの解析処理と共通だった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
342 - Interfaceならではの情報が取れない
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
343 - スクリプトに直接書かれているので他のツールが使えない
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
344 - モジュール化したInterfaceのパーサーを導入した
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
345 - Perlフレームワークを使う一連のツールの作製が可能になった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
346 - InterfaceとImplを見た実装の雛形ファイルの作製ツール
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
347 - コード変換時にInterfaceのAPIに関連するチェック機能
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
348
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
349
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
350 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
351 # Interfaceの実装の雛形生成コマンドの実装
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
352 - Interfaceと実装する型が決まると、最低限書かないといけないCodeGearが決まる
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
353 - 従来は手作業でCbCファイルにCodeGearの定義を書いて実装していた
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
354 - コンストラクタも手書き
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
355 - JavaはIDEで、golangはコマンドとして雛形を生成するものを用意している
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
356 - GearsOSでも導入した
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
357 - 実装の型ファイルを引数で渡すと雛形を生成する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
358 ```shell
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
359 $perl too/impl2cbc.pl SingleLinkedStack.h
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
360 ```
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
361
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
362 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
363 # 生成された雛形cbcの一部
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
364 - 各CodeGearに実装したい内容をすぐに書き始めることが可能になった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
365 - 自動生成されるのでエラーの発生も抑えられる
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
366
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
367 ```c
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
368 #include "../../../context.h"
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
369 #interface "Stack.h"
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
370
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
371 Stack* createSingleLinkedStack(struct Context* context) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
372 struct Stack* stack = new Stack();
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
373 struct SingleLinkedStack* single_linked_stack = new SingleLinkedStack();
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
374 stack->stack = (union Data*)single_linked_stack;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
375 ...
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
376 stack->pop2 = C_pop2SingleLinkedStack;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
377 stack->get2 = C_get2SingleLinkedStack;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
378 return stack;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
379 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
380 ...
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
381
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
382 __code push(struct SingleLinkedStack* stack,union Data* data, __code next(...)) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
383
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
384 goto next(...);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
385 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
386 ```
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
387
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
388 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
389 # PerlトランスパイラでのInterfaceのエラー生成
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
390 - Interfaceの実装時に様々なミスをする可能性がある
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
391 - APIを完全に実装していない
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
392 - 呼び出しの引数を間違えている
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
393 - 無いAPIを呼び出している
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
394 - 従来は変換した後CbCコンパイラがコンパイルする際や、実行時にしかエラーが出なかった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
395 - どの記述でエラーが出たのかの特定が困難
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
396 - CbCコンパイラがコンパイルする前にトランスパイラで検知したい
127
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 125
diff changeset
397
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 125
diff changeset
398 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 125
diff changeset
399 # 実装をし忘れているAPIがあった場合のエラー終了
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 125
diff changeset
400 - PerlトランスパイラでのInterfaceのエラー生成
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 125
diff changeset
401 - CbCコンパイラが動く前にエラーを検知
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
402
127
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 125
diff changeset
403 ```
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 125
diff changeset
404 [ 33%] Generating c/examples/DPP2/PhilsImpl.c
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 125
diff changeset
405 [ERROR] Not define eating at examples/DPP2/PhilsImpl.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 125
diff changeset
406 make[3]: *** [CMakeFiles/DPP2.dir/build.make:101: c/examples/DPP2/PhilsImpl.c] Error 25
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 125
diff changeset
407 make[2]: *** [CMakeFiles/Makefile2:442: CMakeFiles/DPP2.dir/all] Error 2
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 125
diff changeset
408 make[1]: *** [CMakeFiles/Makefile2:450: CMakeFiles/DPP2.dir/rule] Error 2
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 125
diff changeset
409 make: *** [Makefile:293: DPP2] Error 2
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 125
diff changeset
410 ```
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
411
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
412 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
413 # Context定義ファイルの自動生成
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
414 - ContextはすべてのDataGearの型情報をunion Dataとして持つ必要がある
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
415 - すべてのDataGearの定義をunion Dataの定義内に書く
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
416 - これは今まで手書きで作製していた
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
417 - Interfaceの型定義ファイルを導入したので、自動生成が可能になった
124
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
418 - ビルド時に使用しているDataGearを回収し、 context.hを作製する
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
419 ```c
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
420 union Data {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
421 struct Stack {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
422 ...
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
423 } Stack;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
424 struct SingleLinkedStack {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
425 ...
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
426 } SingleLinkedStack;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
427 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
428 ```
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
429 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
430 # StubCodeGear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
431 - 実行したいCodeGearの直前に実行されるMetaCodeGear
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
432 - contextからDataGearを取り出す操作をする
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
433 - すべてのノーマルレベルのCodeGearに付随する
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
434 - Perlトランスパイラでビルド時に自動生成
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
435 ![w:632 h:10cm](./stubCodeGear.svg)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
436
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
437 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
438 ## 別のInterfaceの出力を受けるCodeGearのメタ計算部分の自動生成
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
439 - Stackから`data`と`data1`を受け取ろうとする例
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
440 - 意図した通りに動かない
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
441
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
442 ```c
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
443 __code pop2Test(struct StackTestImpl3* stackTest, struct Stack* stack, __code next(...)) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
444 goto stack->pop2(pop2Test1);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
445 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
446
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
447
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
448 __code pop2Test1(struct StackTestImpl3* stackTest, union Data* data, union Data* data1, struct Stack* stack, __code next(...)) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
449 String* str = (String*)data;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
450 String* str2 = (String*)data1;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
451
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
452 printf("%d\n", str->size);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
453 printf("%d\n", str2->size);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
454 goto next(...);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
455 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
456 ```
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
457
124
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
458 ---
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
459 ## 別のInterfaceの出力を受けるCodeGearのメタ計算部分の自動生成
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
460 - Interfaceの継続に別のInterfaceを渡すと値の受け渡しが上手くいかない
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
461 - StubCodeGearがおかしい
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
462
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
463 ```c
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
464 __code pop2Test1StackTestImpl3_stub(struct Context* context) {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
465 StackTestImpl3* stackTest = (StackTestImpl3*)GearImpl(context, StackTest, stackTest);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
466 Data* data = Gearef(context, StackTest)->data;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
467 Data* data1 = Gearef(context, StackTest)->data1;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
468 Stack* stack = Gearef(context, StackTest)->stack;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
469 enum Code next = Gearef(context, StackTest)->next;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
470 goto pop2Test1StackTestImpl3(context, stackTest, data, data1, stack, next);
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
471 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
472 ```
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
473
124
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
474
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
475 ---
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
476 - メタ計算部分で取得するcontextの場所が異なっているのが問題
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
477 - 取得する場所を手書きする必要があった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
478
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
479 ![w:732 h:13cm](./stackTest1.svg)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
480
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
481 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
482 ## 別のInterfaceの出力を受けるCodeGearのメタ計算部分の自動生成
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
483 - `goto interface->method()`している箇所を読み取る
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
484 - `interface`がどのInterfaceなのかをPerlトランスパイラで特定させた
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
485 - 特定したInterfaceをパーサーを呼び出して情報を取得
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
486 - APIごとに出力があるかを調査
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
487 - 出力があったら、継続で渡しているCodeGearの入力を、呼び出しているInterfaceからとるように修正
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
488 - データの取り出しはStubでしているので、新たなStubを作製した
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
489
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
490 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
491 # メタ計算の切り替えAPI
124
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
492 - CodeGearが継続するMetaCodeGearを自由に選択できるPerlモジュールを導入した
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
493 - 従来はデフォルトで設定されるMetaCodeGearにしか継続しなかった
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
494 - Perlモジュールを書くことで特定のCodeGearの継続先を変更可能にした
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
495 - 様々な処理をMetaCodeGearですることが可能になった
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
496 - すでにモデル検査用のメタ計算を入れることが出来た
124
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
497
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
498 ![w:932 h:10cm](./metapm.svg)
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
499
117
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
500
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
501 ---
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
502 # まとめ
123
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 122
diff changeset
503 - Perlトランスパイラのフレームワークの機能を充実させた
125
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
504 - Interfaceシステムを改良した
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
505 - 型定義ファイルの導入を行った
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
506 - 定義方法に一貫性が出た
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 124
diff changeset
507 - Perlトランスパイラで警告を発生させるようになった
117
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
508 - 従来手書きしていたメタな定義をビルド時に自動的に生成するようにした
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
509 - 煩雑な処理や手で実装することによるバグの混入を回避
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
510 - MetaCodeGearの制御をユーザー側で行えるようにした
7467ceebd3c5 add svg
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 116
diff changeset
511 - モデル検査をメタ計算として自在に組み込むことが可能となった
124
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
512
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
513 ---
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
514
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
515 ```perl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
516 sub replaceMeta {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
517 return (
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
518 [qr/PhilsImpl/ => \&generateMcMeta],
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
519 );
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
520 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
521
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
522 sub generateMcMeta {
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
523 my ($context, $next) = @_;
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
524 return "goto mcMeta($context, $next);";
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
525 }
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 123
diff changeset
526 ```