changeset 46:03a8903d40d7

...
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Mon, 01 Feb 2021 15:15:41 +0900
parents af80bd950c79
children 24f6f068ddbb
files paper/chapter/04-interface.tex paper/master_paper.pdf paper/src/generatePickNext.pl paper/src/parsedOutputStub.pl
diffstat 4 files changed, 58 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/paper/chapter/04-interface.tex	Mon Feb 01 14:23:40 2021 +0900
+++ b/paper/chapter/04-interface.tex	Mon Feb 01 15:15:41 2021 +0900
@@ -169,5 +169,26 @@
 ソースコード\ref{src:insertTest1}の\texttt{pop2Test}では、 \texttt{stack->pop2}の呼び出しをしているため、 \texttt{stack}がインスタンスであり、 \texttt{pop2}がAPIである。
 現在解析しているgoto文が含まれているCodeGearの名前は、変数\texttt{\$currentCodeGear}で別途保存している。
 連想配列である\texttt{\$codeGearInfo}の中には、 各CodeGearで使われている変数と変数の型などの情報が格納されている。
-ソースコード\ref{src:parsedOutputStub.pl}の9行目では、 \texttt{\$codeGearInfo}経由でInterfaceのインスタンスから、具体的にどの型が呼ばれているかを取得している。
-\texttt{pop2Test}では、 \texttt{stack}がインスタンスに対応する型名は\texttt{Stack}となる。
\ No newline at end of file
+ソースコード\ref{src:parsedOutputStub.pl}の9行目では、 \texttt{\$codeGearInfo}経由でInterfaceのインスタンスから、具体的にどの型が呼ばれているかを取得する。
+\texttt{pop2Test}では、 インスタンス\texttt{stack}に対応する型名は\texttt{Stack}と解析される。
+
+ソースコード\ref{src:parsedOutputStub.pl}の10行目で実行されている\texttt{findExistsOutputDataGear}はgenerate\_stub.pl内の関数である。
+これはInterfaceの名前とメソッド名を与えると、 Interfaceの定義ファイルのパース結果から出力の有無を確認する動きをする。
+出力がある場合は出力している変数名の一覧を返す。
+ソースコード\ref{src:insertTest1}の例では\texttt{pop2}は\texttt{data}と\texttt{data1}を出力している為、 これらがリストとして関数から返される。
+出力がない場合は偽値を返すために13行目からのif文から先は動かない。
+出力があった場合はgenerate\_stub.plの内部変数に出力する変数名と、 Interfaceの名前の登録を行う。
+生成するStubは命名規則が、 \texttt{\_\_code CodeGearStub\_1}のように末尾に\texttt{\_}に続けて数値をいれる。
+この数値は変換した回数となるため、 この回数の計算を行う。
+
+
+27行目で\texttt{\$generateHaveOutputStub}のlist要素に現在のCodeGearの名前と、 出力に関する情報を代入している。
+現在のCodeGearの名前を保存しているのは、この後のコード生成部分でenumの番号を切り替える必要があるためである。
+ソースコード\ref{src:insertTest1}の例では\texttt{pop2Test}が使うenumを書き換える必要がある為、 ここの\texttt{\$currentCodeGear}はpop2Testとなる。
+ここで作製した\texttt{\$outputStubElem}は、返還後のCbCコードを生成しているフェーズで呼びされる。
+ソースコード\ref{src:generatePickNext.pl}の箇所は遷移先のenumをPerlスクリプトで生成し、 GearsOSが実行中にenumをcontextに書き込むコードを生成するフェーズである。
+\lstinputlisting[label=src:generatePickNext.pl, caption=Gearefのコード生成部分]{src/generatePickNext.pl}
+if文で条件判定をしているが、前者は出力があるケースかどうかのチェックである。
+続く条件式はGearsOSのビルドルールとして静的に書いたstubの場合は変更を加えない為に、 静的に書いているかどうかの確認をしている。
+
+変数\texttt{\$pick\_next}で継続先のCodeGearの名前を作製している。
Binary file paper/master_paper.pdf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/src/generatePickNext.pl	Mon Feb 01 15:15:41 2021 +0900
@@ -0,0 +1,7 @@
+if ($outputStubElem && !$stub{$outputStubElem->{createStubName}."_stub"}->{static}) {
+  my $pick_next = "$outputStubElem->{createStubName}_$outputStubElem->{counter}";
+  $return_line .= "${indent}Gearef(${context_name}, $ntype)->$pName = C_$pick_next;\n";
+  $i++;
+  next;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/paper/src/parsedOutputStub.pl	Mon Feb 01 15:15:41 2021 +0900
@@ -0,0 +1,28 @@
+  } elsif (/^(.*)goto (\w+)\-\>(\w+)\((.*)\);/) {
+    debug_print("getDataGear",__LINE__, $_) if $opt_debug;
+    # handling goto statement
+    # determine the interface you are using, and in the case of a goto CodeGear with output, create a special stub flag
+    my $prev = $1;
+    my $instance = $2;
+    my $method = $3;
+    my $tmpArgs = $4;
+    my $typeName = $codeGearInfo->{$currentCodeGear}->{arg}->{$instance};
+    my $nextOutPutArgs = findExistsOutputDataGear($typeName, $method);
+    my $outputStubElem = { modifyEnumCode => $currentCodeGear, createStubName => $tmpArgs };
+
+    if ($nextOutPutArgs) {
+      my $tmpArgHash = {};
+      for my $vname (@$nextOutPutArgs) {
+        $tmpArgHash->{$vname} = $typeName;
+      }
+
+      $outputStubElem->{args} = $tmpArgHash;
+
+      #We're assuming that $tmpArgs only contains the name of the next CodeGear.
+      #Eventually we need to parse the contents of the argument. (eg. @parsedArgs)
+      my @parsedArgs = split /,/ , $tmpArgs; #
+
+      $generateHaveOutputStub->{counter}->{$tmpArgs}++;
+      $outputStubElem->{counter} = $generateHaveOutputStub->{counter}->{$tmpArgs};
+      $generateHaveOutputStub->{list}->{$currentCodeGear} = $outputStubElem;
+    }
\ No newline at end of file