diff options
-rw-r--r-- | lib/assembler.c | 129 | ||||
-rw-r--r-- | po/ProjetArchi.pot | 112 |
2 files changed, 124 insertions, 117 deletions
diff --git a/lib/assembler.c b/lib/assembler.c index 25b975b..c3bc4a0 100644 --- a/lib/assembler.c +++ b/lib/assembler.c @@ -70,7 +70,8 @@ int s_text = 0, s_data = 0, s_bss = 0; static void debug_print_expression(expression_t * e) { - if (!e) return; + if (!e) + return; switch (e->e_subtype) { case E_OPERATION: switch (e->op) { @@ -454,7 +455,7 @@ void push_pile(char *a) } else { trouve = 0; if ((*a != '"') && (*a != '\'')) { - e_t = (expression_t *) NomVarToVar(a, defines, &trouve); + e_t = (expression_t *) NomVarToVar(a, defines, &trouve); } if (trouve) { e = copy_expression(e_t); @@ -466,14 +467,18 @@ void push_pile(char *a) } } e->op = -1; - e->prev = e_current; + if (wc) { + e->prev = e_current; + } else { + e->prev = NULL; + } e->next = NULL; - if (e_current) { + if (wc) { e_current->next = e; } e->father = NULL; e->child = NULL; - + /* On prédevine le subtype sur quelques cas */ /* Cas des labels (en nom:) */ @@ -1127,7 +1132,7 @@ static void super_pattern(pattern_t * patterns, expression_t * e) return; if (!((e->op == OP_DECAL) || (e->op == OP_DIRECT))) return; - + for (patterns = patterns->next; patterns; patterns = patterns->next) { for (i = 0; i < patterns->nbr; i++) { if (!patterns->expr[i]->name) { @@ -1239,13 +1244,23 @@ static instruct_t *e_match_i(phon_t * phons, instruct_t * instructs, expression_ } break; case 'C': - if ((t->e_subtype != E_VALUE) && (t->e_subtype != E_LABEL)) { + if ((t->e_subtype != E_VALUE) && (t->e_subtype != E_LABEL) + && (t->e_subtype != E_OPERATION)) { go_out = 1; if (t->e_subtype == E_OPERATION) { if (t->op == OP_FUNC_CALL) go_out = 0; } } + + if ((t->e_subtype == E_OPERATION) && (!(((t->child->e_subtype == E_LABEL) + && (t->child->next->e_subtype == E_VALUE)) + || ((t->child->e_subtype == E_VALUE) + && (t->child->next->e_subtype == + E_LABEL))))) { + go_out = 1; + } + break; case 'o': /* Pour que quelque chose soit absolu, il nous suffit d'avoir un label dans l'expression */ @@ -1266,19 +1281,19 @@ static instruct_t *e_match_i(phon_t * phons, instruct_t * instructs, expression_ } } - if (!go_out) { + if (!go_out && !t) { break; } } if (instructs) { fprintf(stderr, "Nous avons reconnu une instruction:\n"); - fprintf(stderr, " o Instruction contenant %i champs explicites et %i champs implicites.\n", + fprintf(stderr, + " o Instruction contenant %i champs explicites et %i champs implicites.\n", instructs->nbexplicit, instructs->nbimplicit); fprintf(stderr, " => Champs explicites.\n"); for (i = 0; i < instructs->nbexplicit; i++) { - fprintf(stderr, " + %s <= %s (type %s)\n", - instructs->names[i], + fprintf(stderr, " + %s <= %s (type %s)\n", instructs->names[i], instructs->strings[i] ? instructs->strings[i] : "Pas de chaîne associée", instructs->etypes[i] ? "prédéfinit" : "direct"); } @@ -1290,8 +1305,8 @@ static instruct_t *e_match_i(phon_t * phons, instruct_t * instructs, expression_ instructs->istrings[i]); break; case 1: - fprintf(stderr, " + %s <= %s (type prédéfinit)\n", instructs->implicits[i], - instructs->istrings[i]); + fprintf(stderr, " + %s <= %s (type prédéfinit)\n", + instructs->implicits[i], instructs->istrings[i]); break; case 2: fprintf(stderr, " + %s <= %i (type valeur)\n", instructs->implicits[i], @@ -1315,11 +1330,9 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e) if (!e->pattern) { exception(1, _("Pattern not matching...")); } - - fprintf(stderr, "Evaluation de la pattern %s, index %i\n", e->pattern->name, e->index); + fprintf(stderr, "Evaluation de la pattern %s, index %i\n", e->pattern->name, e->index); m = e->pattern->expr[e->index]; - if (m->name) { fprintf(stderr, "La pattern a un nom\n"); if (m->string) { @@ -1339,8 +1352,7 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e) if (m->string[0] != 'P') { exception(1, _ - ("Error in the metalanguage (pattern should be here if not a constant type)")); - } + ("Error in the metalanguage (pattern should be here if not a constant type)"));} t = (expression_t *) Emalloc(sizeof(expression_t)); t->next = t->child = t->prev = t->father = NULL; t->e_type = t->e_subtype = E_VALUE; @@ -1358,7 +1370,8 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e) m = m->left; if (m->string) { if (m->type) { - if (strcmp(m->name, "I") || strcmp(m->string, "O") || strcmp(m->string, "o")) { + if (strcmp(m->name, "I") || strcmp(m->string, "O") + || strcmp(m->string, "o")) { exception(1, _("Unknow constant type in the meta language")); } tv = 0; @@ -1383,13 +1396,11 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e) if (m->string[0] != 'P') { exception(1, _ - ("Error in the metalanguage (pattern should be here if not a constant type)")); - } + ("Error in the metalanguage (pattern should be here if not a constant type)"));} t = (expression_t *) Emalloc(sizeof(expression_t)); t->next = t->child = t->prev = t->father = NULL; t->e_type = t->e_subtype = E_VALUE; t->pattern = NULL; - if (e->child->next->e_subtype == E_PATTERN) { t->avalue = e->child->next->index; } else { @@ -1413,8 +1424,7 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e) if (m->string[0] != 'P') { exception(1, _ - ("Error in the metalanguage (pattern should be here if not a constant type)")); - } + ("Error in the metalanguage (pattern should be here if not a constant type)"));} t = (expression_t *) Emalloc(sizeof(expression_t)); t->next = t->child = t->prev = t->father = NULL; t->e_type = t->e_subtype = E_VALUE; @@ -1430,26 +1440,25 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e) } } -static int evaluate_field(_TableauVariable it, char * field, field_t * fields) { +static int evaluate_field(_TableauVariable it, char *field, field_t * fields) +{ int i, r, e, n; char trouve; - expression_t * t; + expression_t *t; for (fields = fields->next; fields; fields = fields->next) { if (!strcmp(field + 1, fields->name)) { break; } } - + if (!(fields)) { exception(1, _("Unknow field in metalanguage")); } - + r = 0; n = 0; - fprintf(stderr, "Evaluation du champ %s\n", field); - for (i = 0; i < fields->nbr; i++) { t = (expression_t *) NomVarToVar(fields->names[i], it, &trouve); e = 0; @@ -1467,7 +1476,7 @@ static int evaluate_field(_TableauVariable it, char * field, field_t * fields) { } r = (r << n) | e; } - + return r; } @@ -1496,10 +1505,9 @@ void asm_eol(void) fprintf(stderr, "Fin de ligne sur:\n"); debug_print_expression(e_line); fprintf(stderr, "-----\n"); - e_current = e_line; - if (!(e_current)) break; - + if (!(e_current)) + break; /* Est-ce que le premier mot est un label terminant par ':' ? */ if (e_current->e_subtype == E_LABEL) { if (e_current->symbol[strlen(e_current->symbol) - 1] == ':') { @@ -1522,7 +1530,7 @@ void asm_eol(void) } } - + switch (e_current->e_subtype) { case E_INTERNAL: switch (e_current->op) { @@ -1592,7 +1600,8 @@ void asm_eol(void) } break; case E_INSTRUCT: - if (!e_current) break; + if (!e_current) + break; if (segment != SEG_TEXT) { exception(1, _("You can only have an instruction into a .text segment")); } @@ -1605,7 +1614,6 @@ void asm_eol(void) Initialise(&it); pi = pushdword(0, NULL); - for (i = 0; i < instr->nbexplicit; i++) { if (instr->strings[i]) { switch (instr->strings[i][0]) { @@ -1620,12 +1628,10 @@ void asm_eol(void) } else { exception(1, _ - ("Unknow constant type in the meta language")); - } + ("Unknow constant type in the meta language"));} } else { InsererVarDansTab(&it, - CreerElement(instr->names[i], e_current)); - } + CreerElement(instr->names[i], e_current));} break; case 'O': if (instr->etypes) { @@ -1638,24 +1644,24 @@ void asm_eol(void) } else { exception(1, _ - ("Unknow constant type in the meta language")); - } + ("Unknow constant type in the meta language"));} } break; case 'o': if (instr->etypes) { if (!strcmp(instr->names[i], "I")) { if (e_current->e_subtype == E_VALUE) { - exception(1, _("Can't have a direct value for a relative offset")); - } else { + exception(1, + _ + ("Can't have a direct value for a relative offset"));} + else { pi = pushdword(0, e_current); } pi->Encoded -= pi->offset; } else { exception(1, _ - ("Unknow constant type in the meta language")); - } + ("Unknow constant type in the meta language"));} } break; case 'P': @@ -1664,7 +1670,8 @@ void asm_eol(void) t->avalue = e_current->index; t->child = t->next = NULL; t->pattern = NULL; - fprintf(stderr, "Insertion de la variable %s, de valeur %i.\n", instr->names[i], t->avalue); + fprintf(stderr, "Insertion de la variable %s, de valeur %i.\n", + instr->names[i], t->avalue); InsererVarDansTab(&it, CreerElement(instr->names[i], t)); evaluate_pattern(&it, e_current); break; @@ -1678,10 +1685,10 @@ void asm_eol(void) free_expr(e_current); e_current = e_line; } - + for (i = 0; i < instr->nbimplicit; i++) { - switch(instr->itypes[i]) { - case 0: /* type direct */ + switch (instr->itypes[i]) { + case 0: /* type direct */ fprintf(stderr, "On cherche la variable %s\n", instr->istrings[i]); t = (expression_t *) NomVarToVar(instr->istrings[i], it, &trouve); if (!trouve) { @@ -1690,11 +1697,12 @@ void asm_eol(void) t->avalue = 0; t->child = t->next = NULL; t->pattern = NULL; - fprintf(stderr, "Insertion de la variable %s, de valeur %i.\n", instr->istrings[i], t->avalue); + fprintf(stderr, "Insertion de la variable %s, de valeur %i.\n", + instr->istrings[i], t->avalue); } InsererVarDansTab(&it, CreerElement(instr->implicits[i], t)); break; - case 1: /* type prédéfinit */ + case 1: /* type prédéfinit */ t = (expression_t *) Emalloc(sizeof(expression_t)); t->e_type = t->e_subtype = E_VALUE; if (instr->istrings[i][0] != 'F') { @@ -1705,7 +1713,7 @@ void asm_eol(void) t->pattern = NULL; InsererVarDansTab(&it, CreerElement(instr->implicits[i], t)); break; - case 2: /* type valeur */ + case 2: /* type valeur */ t = (expression_t *) Emalloc(sizeof(expression_t)); t->e_type = t->e_subtype = E_VALUE; t->avalue = instr->ivalues[i]; @@ -1715,13 +1723,11 @@ void asm_eol(void) break; } } - + fprintf(stderr, "Variables\n"); AfficheTableau(it); - pushdword(evaluate_field(it, "FI", fields), NULL); DetruitTab(&it); - break; default: exception(1, _("Unknow instruction")); @@ -1738,7 +1744,7 @@ void asm_eol(void) void asm_eof(FILE * f) { - + } static void delete_bytestream(bytestream_t * s) @@ -1796,9 +1802,10 @@ static int process_file(char *name) return 0; } -void assemble_file(char * iname, char * oname) { - FILE * f; - +void assemble_file(char *iname, char *oname) +{ + FILE *f; + pushcontext(_("Opening output file")); if (!(f = fopen(oname, "wb"))) { pushcontext(strerror(errno)); diff --git a/po/ProjetArchi.pot b/po/ProjetArchi.pot index 04eac5d..27017e0 100644 --- a/po/ProjetArchi.pot +++ b/po/ProjetArchi.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2001-04-15 20:17+0200\n" +"POT-Creation-Date: 2001-04-16 01:21+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -14,218 +14,218 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: ENCODING\n" -#: lib/assembler.c:168 +#: lib/assembler.c:169 msgid "You have to be into the .text or the .data segment to define a value." msgstr "" -#: lib/assembler.c:191 +#: lib/assembler.c:192 msgid "Label already defined" msgstr "" -#: lib/assembler.c:254 +#: lib/assembler.c:255 msgid "You can't have the startpoint elsewhere than the .text segment" msgstr "" -#: lib/assembler.c:398 +#: lib/assembler.c:399 msgid "Not a valid . directive" msgstr "" -#: lib/assembler.c:427 +#: lib/assembler.c:428 msgid "Not a valid # directive" msgstr "" #. Cas des directives . -#: lib/assembler.c:435 +#: lib/assembler.c:436 msgid "Error: extra parameters to a . directive." msgstr "" -#: lib/assembler.c:547 +#: lib/assembler.c:552 msgid "Too much arguments to #undef" msgstr "" -#: lib/assembler.c:551 +#: lib/assembler.c:556 msgid "Defined symbol not found." msgstr "" -#: lib/assembler.c:557 +#: lib/assembler.c:562 msgid "Too much arguments to #include" msgstr "" -#: lib/assembler.c:559 +#: lib/assembler.c:564 #, c-format msgid "Including file at line %i" msgstr "" -#: lib/assembler.c:562 +#: lib/assembler.c:567 msgid "Error reading include file" msgstr "" -#: lib/assembler.c:614 lib/assembler.c:620 +#: lib/assembler.c:619 lib/assembler.c:625 msgid "Zero divide." msgstr "" -#: lib/assembler.c:633 lib/assembler.c:640 +#: lib/assembler.c:638 lib/assembler.c:645 msgid "Error: unable to compute the immediate value" msgstr "" -#: lib/assembler.c:649 +#: lib/assembler.c:654 msgid "Function unknow" msgstr "" -#: lib/assembler.c:656 +#: lib/assembler.c:661 msgid "Addresses addition not allowed" msgstr "" -#: lib/assembler.c:660 +#: lib/assembler.c:665 msgid "You can only use the decal operator on labels" msgstr "" -#: lib/assembler.c:665 lib/assembler.c:668 lib/assembler.c:699 +#: lib/assembler.c:670 lib/assembler.c:673 lib/assembler.c:704 msgid "Address operation invalid" msgstr "" -#: lib/assembler.c:671 lib/assembler.c:703 +#: lib/assembler.c:676 lib/assembler.c:708 msgid "Addresses operations not allowed" msgstr "" -#: lib/assembler.c:674 lib/assembler.c:796 lib/assembler.c:833 -#: lib/assembler.c:907 +#: lib/assembler.c:679 lib/assembler.c:801 lib/assembler.c:838 +#: lib/assembler.c:912 msgid "Expression too complex or invalid" msgstr "" -#: lib/assembler.c:707 lib/assembler.c:720 lib/assembler.c:773 -#: lib/assembler.c:785 lib/assembler.c:822 +#: lib/assembler.c:712 lib/assembler.c:725 lib/assembler.c:778 +#: lib/assembler.c:790 lib/assembler.c:827 msgid "Address type not supported" msgstr "" -#: lib/assembler.c:789 +#: lib/assembler.c:794 msgid "Address addition not supported" msgstr "" -#: lib/assembler.c:826 lib/assembler.c:878 +#: lib/assembler.c:831 lib/assembler.c:883 msgid "Expression invalid" msgstr "" #. Bon si l'on est ici, c'est pas bon signe non plus... -#: lib/assembler.c:951 +#: lib/assembler.c:956 msgid "Expression too complex" msgstr "" -#: lib/assembler.c:1014 +#: lib/assembler.c:1019 msgid "Something wrong, nested operator called..." msgstr "" -#: lib/assembler.c:1085 +#: lib/assembler.c:1090 msgid "Something wrong, lparenthesis operator called..." msgstr "" -#: lib/assembler.c:1088 +#: lib/assembler.c:1093 msgid "Something wrong, should never got here..." msgstr "" -#: lib/assembler.c:1259 +#: lib/assembler.c:1274 msgid "Unknow predefined string into the meta language" msgstr "" -#: lib/assembler.c:1316 +#: lib/assembler.c:1331 msgid "Pattern not matching..." msgstr "" -#: lib/assembler.c:1329 lib/assembler.c:1362 lib/assembler.c:1623 -#: lib/assembler.c:1641 lib/assembler.c:1657 lib/assembler.c:1672 +#: lib/assembler.c:1342 lib/assembler.c:1375 lib/assembler.c:1631 +#: lib/assembler.c:1647 lib/assembler.c:1664 lib/assembler.c:1679 msgid "Unknow constant type in the meta language" msgstr "" -#: lib/assembler.c:1342 lib/assembler.c:1386 lib/assembler.c:1416 +#: lib/assembler.c:1355 lib/assembler.c:1399 lib/assembler.c:1427 msgid "" "Error in the metalanguage (pattern should be here if not a constant type)" msgstr "" -#: lib/assembler.c:1374 lib/assembler.c:1402 lib/assembler.c:1410 -#: lib/assembler.c:1701 +#: lib/assembler.c:1387 lib/assembler.c:1413 lib/assembler.c:1421 +#: lib/assembler.c:1709 msgid "Logical error in meta language" msgstr "" -#: lib/assembler.c:1445 +#: lib/assembler.c:1456 msgid "Unknow field in metalanguage" msgstr "" -#: lib/assembler.c:1459 +#: lib/assembler.c:1468 msgid "Can't evaluate directly expression" msgstr "" -#: lib/assembler.c:1466 +#: lib/assembler.c:1475 msgid "Value too large for field" msgstr "" -#: lib/assembler.c:1520 lib/assembler.c:1727 +#: lib/assembler.c:1528 lib/assembler.c:1733 msgid "Unknow instruction" msgstr "" -#: lib/assembler.c:1545 +#: lib/assembler.c:1553 msgid "Unknow constant" msgstr "" -#: lib/assembler.c:1554 +#: lib/assembler.c:1562 msgid "Bad constant for an immediate value" msgstr "" -#: lib/assembler.c:1571 +#: lib/assembler.c:1579 msgid "Bad constant for a string" msgstr "" -#: lib/assembler.c:1588 +#: lib/assembler.c:1596 msgid "Bad array size" msgstr "" -#: lib/assembler.c:1597 +#: lib/assembler.c:1606 msgid "You can only have an instruction into a .text segment" msgstr "" -#: lib/assembler.c:1600 +#: lib/assembler.c:1609 msgid "Unmatched instruction" msgstr "" -#: lib/assembler.c:1649 +#: lib/assembler.c:1656 msgid "Can't have a direct value for a relative offset" msgstr "" -#: lib/assembler.c:1766 +#: lib/assembler.c:1772 msgid "Loading file" msgstr "" -#: lib/assembler.c:1767 lib/meta.c:516 +#: lib/assembler.c:1773 lib/meta.c:516 #, c-format msgid "Opening file '%s'" msgstr "" -#: lib/assembler.c:1775 lib/meta.c:524 +#: lib/assembler.c:1781 lib/meta.c:524 msgid "Reading file" msgstr "" -#: lib/assembler.c:1777 lib/meta.c:526 +#: lib/assembler.c:1783 lib/meta.c:526 #, c-format msgid "Reading line %i" msgstr "" -#: lib/assembler.c:1786 +#: lib/assembler.c:1792 #, c-format msgid "Summering line %s" msgstr "" -#: lib/assembler.c:1802 +#: lib/assembler.c:1809 msgid "Opening output file" msgstr "" -#: lib/assembler.c:1805 +#: lib/assembler.c:1812 msgid "Error writing output file" msgstr "" -#: lib/assembler.c:1809 +#: lib/assembler.c:1816 msgid "Error reading file" msgstr "" -#: lib/assembler.c:1811 +#: lib/assembler.c:1818 msgid "Writing output file" msgstr "" |