pffffffffff
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
#include "parcours.h"
|
#include "parcours.h"
|
||||||
#include "syntabs.h"
|
#include "syntabs.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
int argumentMicka = 0;
|
||||||
int contexte = C_VARIABLE_GLOBALE;
|
int contexte = C_VARIABLE_GLOBALE;
|
||||||
int adresseGlobalCourante = 0;
|
int adresseGlobalCourante = 0;
|
||||||
int adresseLocaleCourante = 0;
|
int adresseLocaleCourante = 0;
|
||||||
@@ -122,7 +122,7 @@ void parcours_instr_si(n_instr *n)
|
|||||||
sprintf(registre,"$t%d",iRegistre);
|
sprintf(registre,"$t%d",iRegistre);
|
||||||
depile(registre);
|
depile(registre);
|
||||||
|
|
||||||
sprintf(tmp,"beq %s $0 %s", registre,faux);
|
sprintf(tmp,"beq %s $zero %s", registre,faux);
|
||||||
printMips(tmp);
|
printMips(tmp);
|
||||||
|
|
||||||
parcours_instr(n->u.si_.alors);
|
parcours_instr(n->u.si_.alors);
|
||||||
@@ -250,7 +250,7 @@ void parcours_appel(n_appel *n)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
printMips("subu $sp, $sp, 4 #Val Retour");
|
printMips("sub $sp, $sp, 4 #Val Retour");
|
||||||
|
|
||||||
int nbArg = parcours_l_exp(n->args);
|
int nbArg = parcours_l_exp(n->args);
|
||||||
|
|
||||||
@@ -261,14 +261,11 @@ void parcours_appel(n_appel *n)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*int i = nbArg;
|
|
||||||
while(i > 0){
|
|
||||||
printMips("subu $sp, $sp, 4 #Val Argument");
|
|
||||||
--i;
|
|
||||||
} */
|
|
||||||
|
|
||||||
sprintf(tmp,"jal %s",n->fonction);
|
sprintf(tmp,"jal %s",n->fonction);
|
||||||
printMips(tmp);
|
printMips(tmp);
|
||||||
|
int i = nbArg * 4;
|
||||||
|
sprintf(tmp,"addi $sp, $sp, %d",i);
|
||||||
|
printMips(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
@@ -276,18 +273,19 @@ void parcours_appel(n_appel *n)
|
|||||||
void parcours_instr_retour(n_instr *n)
|
void parcours_instr_retour(n_instr *n)
|
||||||
{
|
{
|
||||||
char tmp[250];
|
char tmp[250];
|
||||||
int nbArg = 2; ///TO DOOOOOOOOOOO
|
|
||||||
char exec[250];
|
char exec[250];
|
||||||
int returnAdress = 4 * (nbArg + 1);
|
int returnAdress = 4 * (argumentMicka + 1);
|
||||||
|
|
||||||
parcours_exp(n->u.retour_.expression);
|
parcours_exp(n->u.retour_.expression);
|
||||||
|
|
||||||
int iRegistre = 0;
|
int iRegistre = 0;
|
||||||
sprintf(tmp,"$t%d",iRegistre);
|
sprintf(tmp,"$t%d",iRegistre);
|
||||||
depile(tmp);
|
depile(tmp);
|
||||||
sprintf(exec,"sw %s %d($fp) ",tmp , returnAdress);
|
sprintf(exec,"sw %s %d($fp) #Adresse de retour",tmp , returnAdress);
|
||||||
printMips(exec);
|
printMips(exec);
|
||||||
|
|
||||||
finFunc();
|
finFunc();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
@@ -532,12 +530,22 @@ void parcours_foncDec(n_dec *n)
|
|||||||
break;
|
break;
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
argumentMicka = j;
|
||||||
dico.tab[id].complement = j;
|
dico.tab[id].complement = j;
|
||||||
|
|
||||||
contexte = C_VARIABLE_LOCALE;
|
contexte = C_VARIABLE_LOCALE;
|
||||||
parcours_l_dec(n->u.foncDec_.variables);
|
parcours_l_dec(n->u.foncDec_.variables);
|
||||||
parcours_instr(n->u.foncDec_.corps);
|
parcours_instr(n->u.foncDec_.corps);
|
||||||
|
i = rechercheExecutable(n->nom);
|
||||||
|
int nbvariableLocale = 0;
|
||||||
|
while (dico.tab[i+1].classe == C_VARIABLE_LOCALE){
|
||||||
|
++nbvariableLocale;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
sprintf(tmp,"addi $sp, $sp %d # desallocation variables locales",nbvariableLocale * 4);
|
||||||
|
//SAm est morte ici
|
||||||
|
printMips(tmp);
|
||||||
|
|
||||||
finFunc();
|
finFunc();
|
||||||
affiche_dico();
|
affiche_dico();
|
||||||
sortieFonction();
|
sortieFonction();
|
||||||
@@ -628,16 +636,15 @@ void parcours_var_simple(n_var *n, char * var)
|
|||||||
if(dico.tab[i].classe == C_VARIABLE_GLOBALE) {
|
if(dico.tab[i].classe == C_VARIABLE_GLOBALE) {
|
||||||
sprintf(var, "$%s", n->nom);
|
sprintf(var, "$%s", n->nom);
|
||||||
}
|
}
|
||||||
else if (dico.tab[i].classe == C_ARGUMENT) {
|
else if (dico.tab[i].classe == C_ARGUMENT) {
|
||||||
int adress = dico.tab[i].adresse;
|
int adress = dico.tab[i].adresse;
|
||||||
int nbArg = dico.tab[i - (adress/4) -1].complement;
|
int nbArg = dico.tab[i - (adress/4) -1].complement;
|
||||||
int result = (4 * nbArg - adress);
|
int result = 4 * nbArg - adress;
|
||||||
|
sprintf(var, "%d($fp) #variable argument %s",result,n->nom);
|
||||||
sprintf(var, "%d($fp)", result);
|
|
||||||
}
|
}
|
||||||
else if (dico.tab[i].classe == C_VARIABLE_LOCALE){
|
else if (dico.tab[i].classe == C_VARIABLE_LOCALE){
|
||||||
int adresse = -1 *(8 + dico.tab[i].adresse);
|
int adresse = -1 *(8 + dico.tab[i].adresse);
|
||||||
sprintf(var, "%d($fp)", adresse);
|
sprintf(var, "%d($fp) #variable locale", adresse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,5 +663,6 @@ void parcours_var_indicee(n_var *n, char * var)
|
|||||||
}
|
}
|
||||||
|
|
||||||
parcours_exp( n->u.indicee_.indice );
|
parcours_exp( n->u.indicee_.indice );
|
||||||
|
|
||||||
}
|
}
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user