Mercurial > hg > Papers > 2022 > ikki-master
changeset 6:38dfa4d8b0be
add GearsFile & Directory
author | ichikitakahiro <e165713@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 16 Jan 2022 23:43:50 +0900 |
parents | d8f93db60366 |
children | b31312c4d2de |
files | Paper/images/GearsDirectory.graffle.graffle Paper/images/GearsDirectory.pdf Paper/images/GearsFile.graffle.graffle Paper/images/GearsFile.pdf Paper/images/QueueElement.graffle.graffle Paper/images/QueueElement.pdf Paper/images/Unix.graffle.graffle Paper/images/UnixWC.pdf Paper/src/Atomic.h Paper/src/GearsFileImpl.h Paper/src/WcImpl.cbc |
diffstat | 11 files changed, 39 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Paper/src/Atomic.h Sun Jan 16 23:43:50 2022 +0900 @@ -0,0 +1,9 @@ +typedef struct Atomic<>{ + union Data* atomic; + union Data** ptr; + union Data* oldData; + union Data* newData; + __code checkAndSet(Impl* atomic, union Data** ptr, union Data* oldData, union Data* newData, __code next(...), __code fail(...)); + __code next(...); + __code fail(...); +} Atomic;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Paper/src/GearsFileImpl.h Sun Jan 16 23:43:50 2022 +0900 @@ -0,0 +1,6 @@ +typedef struct GearsFileImpl <> impl GearsFile { + struct Queue* inputQueue; + struct Queue* outputQueue; + struct Queue* mainQueue; + __code next(...); +} GearsFileImpl;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Paper/src/WcImpl.cbc Sun Jan 16 23:43:50 2022 +0900 @@ -0,0 +1,24 @@ +__code putString(struct WcImpl* wc, int line, __code next(...)){ + if (wc->strTable[line] != NULL){ + wcString* string = NEW(wcString); + string->str = wc->strTable[line]; + goto countUp(string, next); + } else { + goto showResult(next); + } +} + +__code countUp(struct WcImpl* wc, wcString* string, __code next(...)) { + printf("countUp「%s」\n", string->str); + wc->lineNum = wc->lineNum + 1; + int num = wc->lineNum; + wc->wordNum = wc->wordNum + strlen(string->str); + Gearef(context, Wc)->line = num; + goto putString(num, next); +} + +__code showResult(struct WcImpl* wc, __code next(...)) { + printf("Number of Words is 「%d」\n", wc->wordNum); + printf("EOF and finish codes\n"); + goto next(...); +}