Mercurial > hg-old > index.cgi
diff src/lwasm.c @ 13:05d4115b4860
Started work on new expression evaluator system and major code re-work for next release
author | lost |
---|---|
date | Wed, 22 Oct 2008 04:51:16 +0000 |
parents | 34568fab6058 |
children | d2e86babd958 |
line wrap: on
line diff
--- a/src/lwasm.c Sat Oct 04 03:20:36 2008 +0000 +++ b/src/lwasm.c Wed Oct 22 04:51:16 2008 +0000 @@ -423,75 +423,6 @@ } } -void lwasm_read_file(asmstate_t *as, char *fname) -{ - FILE *f; - int cline = 0; - sourceline_t *cl; - size_t bufflen; - char *buff = NULL; - int retval; - - as -> passnum = 1; - - f = fopen(fname, "r"); - if (!f) - { - fprintf(stderr, "Cannot open input file %s: %s\n", fname, strerror(errno)); - return; - } - - while (!feof(f)) - { - retval = getline(&buff, &bufflen, f); - debug(" read line (%s:%d): %s\n", fname, cline, buff); - if (retval < 0) - { - if (feof(f)) - break; - fprintf(stderr, "Error reading '%s': %s\n", fname, strerror(errno)); - exit(1); - } - if (strchr(buff, '\n')) - *strchr(buff, '\n') = '\0'; - if (strchr(buff, '\r')) - *strchr(buff, '\r') = '\0'; - cl = calloc(sizeof(sourceline_t), 1); - if (!cl) - { - perror("Malloc"); - exit(1); - } - - cl -> lineno = cline++; - cl -> sourcefile = fname; - cl -> opcode = -1; - cl -> addrmode = -1; - cl -> addr = as -> addr; - cl -> dpval = as -> dpval; - cl -> prev = as -> source_tail; - if (as -> source_tail) - as -> source_tail -> next = cl; - as -> source_tail = cl; - if (as -> source_head == NULL) - as -> source_head = cl; - cl -> line = strdup(buff); - - resolve_insn(as, cl); - - if (cl -> opcode >= 0 && instab[cl -> opcode].instype == INSTYPE_PSEUDO && instab[cl -> opcode].specialnum == SPECIAL_END) - break; - - *buff = '\0'; - - } - if (buff) - free(buff); - - fclose(f); - - return; -} /* below this point is the expression evaluation package