summaryrefslogtreecommitdiff
path: root/lib/assembler.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/assembler.c')
-rw-r--r--lib/assembler.c23
1 files changed, 18 insertions, 5 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: