summaryrefslogtreecommitdiff
path: root/lib/assembler.c
diff options
context:
space:
mode:
authorPixel <>2001-04-15 02:21:56 +0000
committerPixel <>2001-04-15 02:21:56 +0000
commitba6d5b2571acd4010c929901b490bcd836c4ca3c (patch)
tree20c8fa3dedd2aecb6c8448c5f325a8af04875a73 /lib/assembler.c
parentdff18f36172e0209c5dffefe54ec61185f7a8aba (diff)
Inclusion du simulateur.
Diffstat (limited to 'lib/assembler.c')
-rw-r--r--lib/assembler.c71
1 files changed, 43 insertions, 28 deletions
diff --git a/lib/assembler.c b/lib/assembler.c
index e727ce2..513a6be 100644
--- a/lib/assembler.c
+++ b/lib/assembler.c
@@ -1289,10 +1289,13 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e)
{
metaexpr_t *m, *n;
expression_t *t;
+ int tv;
if (!e->pattern) {
exception(1, _("Pattern not matching..."));
}
+
+ fprintf(stderr, "Evaluation de la pattern %s, index %i\n", e->pattern->name, e->index);
m = e->pattern->expr[e->index];
@@ -1309,7 +1312,7 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e)
}
} else {
if (m->string) {
- if (m->string != 'P') {
+ if (m->string[0] != 'P') {
exception(1,
_
("Error in the metalanguage (pattern should be here if not a constant type)"));
@@ -1319,8 +1322,8 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e)
t->e_type = t->e_subtype = E_VALUE;
t->avalue = e->index;
t->symbol = NULL;
- InsererVarDansTab(it, CreerElement(m->name, t))
- free(t);
+ InsererVarDansTab(it, CreerElement(m->name, t));
+ free(t);
}
}
}
@@ -1330,17 +1333,28 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e)
m = m->left;
if (m->string) {
if (m->type) {
- if (!strcmp(m->name, "I")) {
+ if (strcmp(m->name, "I") || strcmp(m->string, "O")) {
exception(1, _("Unknow constant type in the meta language"));
}
- if (e->child->e_subtype == E_VALUE) {
- pushdword(e->avalue, NULL);
- } else {
- pushdword(0, e);
+ tv = 0;
+ if (e->child->next->e_subtype == E_VALUE) {
+ tv = e->child->next->avalue;
+ }
+ if ((e->child->next->e_subtype == E_OPERATION)
+ && (e->child->next->child->e_subtype == E_VALUE)) {
+ tv = e->child->next->child->avalue;
}
+ pushdword(tv, e->child);
+ } else {
+ }
+ }
+ m = n;
+ m = m->right;
+ if (m->string) {
+ if (m->type) {
} else {
if (m->string) {
- if (m->string != 'P') {
+ if (m->string[0] != 'P') {
exception(1,
_
("Error in the metalanguage (pattern should be here if not a constant type)"));
@@ -1348,28 +1362,27 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e)
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->avalue = e->index;
+ if (e->child->next->e_subtype == E_PATTERN) {
+ t->avalue = e->child->next->index;
+ } else {
+ t->avalue = e->child->next->child->next->index;
+ }
t->symbol = NULL;
- InsererVarDansTab(it, CreerElement(m->name, t))
- free(t);
+ InsererVarDansTab(it, CreerElement(m->name, t));
+ free(t);
+ } else {
+ exception(1, _("Logical error in meta language"));
}
}
}
- } else {
+ } else { /* Unaire */
m = m->right;
if (m->string) {
if (m->type) {
- if (!strcmp(m->name, "I")) {
- exception(1, _("Unknow constant type in the meta language"));
- }
- if (e->e_subtype == E_VALUE) {
- pushdword(e->avalue, NULL);
- } else {
- pushdword(0, e);
- }
+ exception(1, _("Logical error in meta language"));
} else {
if (m->string) {
- if (m->string != 'P') {
+ if (m->string[0] != 'P') {
exception(1,
_
("Error in the metalanguage (pattern should be here if not a constant type)"));
@@ -1377,10 +1390,10 @@ static void evaluate_pattern(_TableauVariable * it, expression_t * e)
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->avalue = e->index;
+ t->avalue = e->child->index;
t->symbol = NULL;
- InsererVarDansTab(it, CreerElement(m->name, t))
- free(t);
+ InsererVarDansTab(it, CreerElement(m->name, t));
+ free(t);
}
}
}
@@ -1523,9 +1536,6 @@ void asm_eol(void)
InsererVarDansTab(&it, CreerElement(instr->names[i], t));
free(t);
evaluate_pattern(&it, e_current);
-
-
-
break;
default:
exception(1, _("Unknow constant type in the meta language"));
@@ -1537,6 +1547,11 @@ void asm_eol(void)
free_expr(e_current);
e_current = e_line;
}
+
+ fprintf(stderr, "Variables explicites:\n");
+ AfficheTableau(it);
+
+ DetruitTab(&it);