changeset 373:097a58a16a04

remove IO*
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Mon, 06 Jul 2020 20:52:25 +0900
parents 6fc38a3f38f9
children bbca1e5fb946
files src/impl/ConsoleIO.cbc src/impl/ConsoleIO.h src/interface/IO.h
diffstat 3 files changed, 0 insertions(+), 116 deletions(-) [+]
line wrap: on
line diff
--- a/src/impl/ConsoleIO.cbc	Mon Jul 06 11:25:47 2020 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-#include "../context.h"
-#interface "IO.h"
-
-// ----
-// typedef struct ConsoleIO <Type, Isa> impl IO {
-//   __code consoleread(Type* IO, struct inode* ip, char* dst, int n, __code next(...));
-//   __code consoleread1(Type* IO, int n, int target, char* dst, struct inode* ip, __code next(...));
-//   __code consoleread2(Type* IO, struct inode*  ip, __code next(...));
-//   __code next(....);
-// } ConsoleIO;
-// ----
-
-IO* createConsoleIO(struct Context* cbc_context) {
-    struct IO* io  = new IO();
-    struct ConsoleIO* console_io = new ConsoleIO();
-    io->io = (union Data*)console_io;
-    console_io->IO = NULL;
-    console_io->ip = NULL;
-    console_io->dst = NULL;
-    console_io->n  = 0;
-    console_io->target  = 0;
-    console_io->consoleread = C_consoleread;
-    console_io->consoleread1 = C_consoleread1;
-    console_io->consoleread2 = C_consoleread2;
-    io->read = C_readConsoleIO;
-    io->write = C_writeConsoleIO;
-    io->close = C_closeConsoleIO;
-    return io;
-}
-
-__code readConsoleIO(struct ConsoleIO* io, struct file* file, char* addr, int n, __code next(...)) {
-    struct inode* ip = file->ip; 
-    // args should be assigned to the impl structure
-    goto io->consoleread(__code next(...));
-}
-
-__code consoleread(struct ConsoleIO* io, struct inode* ip, char* dst, int n, __code next(...)) {
-    uint target;
-
-    iunlock(ip);
-
-    target = n;
-    acquire(&input.lock);
-
-    if (n > 0) {
-      goto io->consoleread2(io, n, ip, target, dst, ip, next);
-    }
-    goto io->consoleread1(io, n, target, dst, ip, next);
-}
-
-__code consoleread1(struct ConsoleIO* io, int n, int target, char* dst, struct inode* ip, __code next(...)) {
-    int c = input.buf[input.r++ % INPUT_BUF];
-
-    if (c == C('D')) {  // EOF
-        if (n < target) {
-            // Save ^D for next time, to make sure
-            // caller gets a 0-byte result.
-            input.r--;
-        }
-        cont = 0;
-    }
-
-    *dst++ = c;
-    --n;
-
-    if (c == '\n') {
-        cont = 0;
-    }
-
-    if (cont == 1) {
-        if (n > 0) {
-            goto cbc_sleep(&input.r, &input.lock, cbc_consoleread2);
-        }
-    }
-
-    release(&input.lock);
-    ilock(ip);
-
-    goto next(target - n);
-}
-
-__code consoleread2(struct ConsoleIO* io, struct inode*  ip, __code next(...)) {
-    if (input.r == input.w) { // input is global variable
-        if (proc->killed) {
-            release(&input.lock);
-            ilock(ip);
-            goto next(-1);
-        }
-       goto cbc_sleep(&input.r, &input.lock, cbc_consoleread2);
-    }
-    goto io->consoleread1();
-}
-
-
-__code writeConsoleIO(struct ConsoleIO* io, struct file* file, char* addr, int n, __code next(...)) {
-
-    goto next(...);
-}
-
-__code closeConsoleIO(struct ConsoleIO* io, struct file* file, int fd, __code next(...)) {
-
-    goto next(...);
-}
-
--- a/src/impl/ConsoleIO.h	Mon Jul 06 11:25:47 2020 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-typedef struct ConsoleIO <Type, Isa> impl IO {
-  __code consoleread(Type* io, struct inode* ip, char* dst, int n, __code next(...));
-  __code consoleread1(Type* io, int n, int target, char* dst, struct inode* ip, __code next(...));
-  __code consoleread2(Type* io, struct inode*  ip, __code next(...));
-  __code next(....);
-} ConsoleIO;
--- a/src/interface/IO.h	Mon Jul 06 11:25:47 2020 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-typedef struct IO <Type, Impl> {
-    __code read(Impl* io, struct file* file, char* addr, int n, __code next(...));
-    __code write(Impl* io, struct file* file, char* addr, int n, __code next(...));
-    __code close(Impl* io, struct file* file, int fd, __code next(...));
-    __code next(...);
-} IO;