summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPixel <>2001-04-15 16:49:39 +0000
committerPixel <>2001-04-15 16:49:39 +0000
commita1377062cc56484ff439eb3b73e7f4efac1c3077 (patch)
tree4080af556c821f4be065b80f5058c1fa8ed77e1a /lib
parentd90a3e9f5e9bb8e93d8e5282f0ee5cae1b7b2119 (diff)
Bug fixes
Diffstat (limited to 'lib')
-rw-r--r--lib/assembler.c23
-rw-r--r--lib/hash.c10
2 files changed, 23 insertions, 10 deletions
diff --git a/lib/assembler.c b/lib/assembler.c
index 5fc5928..8bceaec 100644
--- a/lib/assembler.c
+++ b/lib/assembler.c
@@ -319,8 +319,11 @@ static expression_t *copy_expression(expression_t * e)
*t = *e;
if (t->symbol) {
- e_t = (expression_t *) NomVarToVar(e->symbol, defines, &trouve);
- if ((trouve) && (t->e_subtype = E_STRING)) {
+ trouve = 0;
+ if (e->e_subtype == E_LABEL) {
+ e_t = (expression_t *) NomVarToVar(e->symbol, defines, &trouve);
+ }
+ if ((trouve) && (t->e_type = E_STRING)) {
free(t);
t = copy_expression(e_t);
return t;
@@ -449,7 +452,10 @@ void push_pile(char *a)
e->avalue = number;
e->symbol = NULL;
} else {
+ trouve = 0;
+ if ((*a != '"') && (*a != '\'')) {
e_t = (expression_t *) NomVarToVar(a, defines, &trouve);
+ }
if (trouve) {
e = copy_expression(e_t);
} else {
@@ -1229,7 +1235,7 @@ static instruct_t *e_match_i(phon_t * phons, instruct_t * instructs, expression_
}
break;
case 'C':
- if (t->e_subtype != E_VALUE) {
+ if ((t->e_subtype != E_VALUE) && (t->e_subtype != E_LABEL)) {
go_out = 1;
if (t->e_subtype == E_OPERATION) {
if (t->op == OP_FUNC_CALL)
@@ -1311,7 +1317,9 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e)
m = e->pattern->expr[e->index];
if (m->name) {
+ fprintf(stderr, "La pattern a un nom\n");
if (m->string) {
+ fprintf(stderr, "et une string associée\n");
if (m->type) {
if (!strcmp(m->name, "I")) {
exception(1, _("Unknow constant type in the meta language"));
@@ -1322,6 +1330,7 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e)
pushdword(0, e);
}
} else {
+ fprintf(stderr, "et n'est pas d'un type prédéfinit\n");
if (m->string) {
if (m->string[0] != 'P') {
exception(1,
@@ -1435,17 +1444,21 @@ static int evaluate_field(_TableauVariable it, char * field, field_t * fields) {
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;
+ fprintf(stderr, "On veut la variable %s pour le champ %i\n", fields->names[i], i);
if (trouve) {
if (t->e_subtype != E_VALUE) {
exception(1, _("Can't evaluate directly expression"));
}
e = t->avalue;
}
+ fprintf(stderr, "Elle vaut %i\n", e);
n = fields->sizes[i];
- if ((e & (n - 1)) != e) {
+ if ((e & ((1 << n) - 1)) != e) {
exception(1, _("Value too large for field"));
}
r = (r << n) | e;
@@ -1616,8 +1629,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);
InsererVarDansTab(&it, CreerElement(instr->names[i], t));
- free(t);
evaluate_pattern(&it, e_current);
break;
default:
diff --git a/lib/hash.c b/lib/hash.c
index 2850444..80e44af 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -19,7 +19,7 @@ static int FonctionHachage(char *clef)
return (i);
}
}
- return (strlen(CHAINEHACHAGE));
+ return -1;
}
_Element CreerElement(char *Nom, _TypeVariable Var)
@@ -95,7 +95,7 @@ char SupprimerDansTab(_TableauVariable * t, char *Nom)
{
int index = FonctionHachage(Nom);
- if (0 <= index && index <= strlen(CHAINEHACHAGE)) {
+ if (0 <= index && index < strlen(CHAINEHACHAGE)) {
Supprimer(&((*t)[index]), Nom);
} else {
return (0);
@@ -107,7 +107,7 @@ char InsererVarDansTab(_TableauVariable * t, _Element e)
{
int index = FonctionHachage(e.NomVar);
- if (0 <= index && index <= strlen(CHAINEHACHAGE)) {
+ if (0 <= index && index < strlen(CHAINEHACHAGE)) {
(*t)[index] = InserTete((*t)[index], e);
} else {
return (0);
@@ -159,7 +159,7 @@ int Initialise(_TableauVariable * t)
unsigned int i;
(*t) = (_TableauVariable) Emalloc(sizeof(_ListeChaine) * (strlen(CHAINEHACHAGE) + 1));
- for (i = 0; i <= strlen(CHAINEHACHAGE); i++) {
+ for (i = 0; i < strlen(CHAINEHACHAGE); i++) {
(*t)[i] = NULL;
}
return (i);
@@ -169,7 +169,7 @@ void DetruitTab(_TableauVariable * t)
{
int i;
- for (i = 0; i <= strlen(CHAINEHACHAGE); i++) {
+ for (i = 0; i < strlen(CHAINEHACHAGE); i++) {
Detruit(&((*t)[i]));
}