-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.c
More file actions
executable file
·48 lines (38 loc) · 1.86 KB
/
code.c
File metadata and controls
executable file
·48 lines (38 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <string.h>
#include <stdio.h>
#include "tp.h"
#include "tp_y.h"
extern char* strdup(const char *);
int etifin;
//Création des etiquettes pour la génération de code pour la condition If then Else
char* newLabel(){
etifin=0;
char* eti=NULL;
printf("Etiquette : %d",etifin);
etifin=etifin+1;
return eti;
}
//Generation code Expression, remplissage champs code
/*void codeExpression(TreeP bloc,VarDeclP exp){
if(bloc->op==NE){
asprintf(&exp->code, "\n %s\n%s \t NEQ", getChild(exp->expr, 0)->u.lvar->code, getChild(exp->expr, 1)->u.lvar->code);
}else if(bloc->op==LT){
asprintf(&exp->code, "\n %s\n%s \t INF", getChild(exp->expr, 0)->u.lvar->code, getChild(exp->expr, 1)->u.lvar->code);
}else if(bloc->op==LE){
asprintf(&exp->code, "\n %s\n%s \t INFEQ", getChild(exp->expr, 0)->u.lvar->code, getChild(exp->expr, 1)->u.lvar->code);
}else if(bloc->op==GT){
asprintf(&exp->code, "\n %s\n%s \t SUP", getChild(exp->expr, 0)->u.lvar->code, getChild(exp->expr, 1)->u.lvar->code);
}else if(bloc->op==GE){
asprintf(&exp->code, "\n %s\n%s \t SUPEQ", getChild(exp->expr, 0)->u.lvar->code, getChild(exp->expr, 1)->u.lvar->code);
}else if(bloc->op==EQ){
asprintf(&exp->code, "\n %s\n%s \t EQ", getChild(exp->expr, 0)->u.lvar->code, getChild(exp->expr, 1)->u.lvar->code);
}else if(bloc->op==EADD){
asprintf(&exp->code, "\n %s\n%s \t ADD", getChild(exp->expr, 0)->u.lvar->code, getChild(exp->expr, 1)->u.lvar->code);
}else if(bloc->op==EMINUS){
asprintf(&exp->code, "\n %s\n%s \t MINUS", getChild(exp->expr, 0)->u.lvar->code, getChild(exp->expr, 1)->u.lvar->code);
}else if(bloc->op==EMULT){
asprintf(&exp->code, "\n %s\n%s \t MULT", getChild(exp->expr, 0)->u.lvar->code, getChild(exp->expr, 1)->u.lvar->code);
}else if(bloc->op==EDIV){
asprintf(&exp->code, "\n %s\n%s \t DIV", getChild(exp->expr, 0)->u.lvar->code, getChild(exp->expr, 1)->u.lvar->code);
}
}*/