# HG changeset patch # User anatofuz # Date 1576499930 -32400 # Node ID 06449f2ae0c78af2cda5925b61e9777d90b0c0b4 # Parent fd166dda4361d677f464db7f17fddc05a8690381 remove file_read constructor diff -r fd166dda4361 -r 06449f2ae0c7 src/file_read.cbc --- 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(...) { - -} -