changeset 151:06449f2ae0c7

remove file_read constructor
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Mon, 16 Dec 2019 21:38:50 +0900
parents fd166dda4361
children d3f97de63622
files src/file_read.cbc
diffstat 1 files changed, 16 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/src/file_read.cbc	Sun Dec 15 14:15:27 2019 +0900
+++ b/src/file_read.cbc	Mon Dec 16 21:38:50 2019 +0900
@@ -10,56 +10,24 @@
 // } FileRead;
 // ----
 
-SysRead* createFileRead(struct Context* cbc_context) {
-    struct SysRead* sys_read  = new SysRead();
-    struct FileRead* file_read = new FileRead();
-    sys_read->sys_read = (union Data*)file_read;
-    file_read->f = NULL;
-    file_read->r  = 0;
-    sys_read->impl = NULL;
-    sys_read->addr = NULL;
-    sys_read->n  = 0;
-    sys_read->read = C_readFileRead;
-    sys_read->next = C_nextFileRead;
-    return sys_read;
-}
+SysRead* createFileReadInstFromFile(struct Context* cbc_context, struct file* f,char* addr, int n) {
+   if (f->type == FD_PIPE) {
+       return create_piperead(cbc_context, f->pipe, addr, n, next);
+   }
 
-SysRead* createFileReadInstFromFile(struct Context* cbc_context, struct file* f,char* addr, int n) {
-    if (f->type == FD_PIPE) {
-        return create_piperead(cbc_context, f->pipe, addr, n, next);
-    }
-
-    if (f->type == FD_INODE) {
-        ilock(f->ip);
-        return create_readi(cbc_context, f->ip, addr, f->off, n, cbc_fileread1);
-    }
-    return NULL; //Error?
+   if (f->type == FD_INODE) {
+       ilock(f->ip);
+       return create_readi(cbc_context, f->ip, addr, f->off, n, cbc_fileread1);
+   }
+   return NULL; //Error?
 }
 
-
-__code cbc_fileread1FileRead(struct FileRead* file_read, struct file* f,int r,__code next(r,...)) {
-
-  goto next(r,...);
-}
-
-__code nextFileRead(...) {
-
+__code selectReadInstance(struct Context cbc_context, struct file* f, __code ret(int i)) {
+   if (f->readable == 0) {
+     i = -1;
+     goto ret(i);
+   }
+   SysRead* read = createFileReadInstFromFile(proc->cbc_context, f);
+   goto read->read(f,addr,n);
 }
 
-__code readFileRead(struct FileRead* sys_read, union Data* impl, char* addr, int n, __code next(int ret,...)) {
-
-  goto next(int ret,...);
-}
-
-__code selectReadInstance(struct file* f) {
-  if (f->readable == 0) {
-    goto next(-1);
-  } 
-  SysRead* read = createFileReadInstFromFile(proc->cbc_context, f);
-  goto read->read(f,addr,n);
-}
-
-__code nextFileRead(...) {
-
-}
-