variable local
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
int nbArg = 0;
|
int nbArg = 0;
|
||||||
|
int nbvariableLocalFonc = 0;
|
||||||
int contexte = C_VARIABLE_GLOBALE;
|
int contexte = C_VARIABLE_GLOBALE;
|
||||||
int adresseGlobalCourante = 0;
|
int adresseGlobalCourante = 0;
|
||||||
int adresseLocaleCourante = 0;
|
int adresseLocaleCourante = 0;
|
||||||
@@ -295,6 +296,9 @@ void parcours_instr_retour(n_instr *n)
|
|||||||
sprintf(exec,"sw %s %d($fp) #Adresse de retour",tmp , returnAdress);
|
sprintf(exec,"sw %s %d($fp) #Adresse de retour",tmp , returnAdress);
|
||||||
printMips(exec);
|
printMips(exec);
|
||||||
|
|
||||||
|
sprintf(tmp,"addi $sp, $sp %d # desallocation variables locales",nbvariableLocalFonc * 4);
|
||||||
|
printMips(tmp);
|
||||||
|
|
||||||
finFuncreturn(1);
|
finFuncreturn(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -660,21 +664,23 @@ void parcours_foncDec(n_dec *n)
|
|||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
nbArg = j;
|
nbArg = j;
|
||||||
|
i = id;
|
||||||
|
int nbvariableLocale = 0;
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
i = id;
|
|
||||||
int nbvariableLocale = 0;
|
|
||||||
|
|
||||||
while (i+1 < dico.sommet && (dico.tab[i+1].classe == C_VARIABLE_LOCALE
|
while (i+1 < dico.sommet && (dico.tab[i+1].classe == C_VARIABLE_LOCALE
|
||||||
|| dico.tab[i+1].classe == C_ARGUMENT)){
|
|| dico.tab[i+1].classe == C_ARGUMENT)){
|
||||||
if(dico.tab[i+1].classe == C_VARIABLE_LOCALE)
|
if(dico.tab[i+1].classe == C_VARIABLE_LOCALE)
|
||||||
++nbvariableLocale;
|
++nbvariableLocale;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
nbvariableLocalFonc = nbvariableLocale;
|
||||||
|
|
||||||
|
parcours_instr(n->u.foncDec_.corps);
|
||||||
sprintf(tmp,"addi $sp, $sp %d # desallocation variables locales",nbvariableLocale * 4);
|
sprintf(tmp,"addi $sp, $sp %d # desallocation variables locales",nbvariableLocale * 4);
|
||||||
|
|
||||||
printMips(tmp);
|
printMips(tmp);
|
||||||
|
|||||||
Reference in New Issue
Block a user