Torna indietro   Hardware Upgrade Forum > Software > Programmazione

iPhone 17 Pro: più di uno smartphone. È uno studio di produzione in formato tascabile
iPhone 17 Pro: più di uno smartphone. È uno studio di produzione in formato tascabile
C'è tanta sostanza nel nuovo smartphone della Mela dedicato ai creator digitali. Nuovo telaio in alluminio, sistema di raffreddamento vapor chamber e tre fotocamere da 48 megapixel: non è un semplice smartphone, ma uno studio di produzione digitale on-the-go
Intel Panther Lake: i processori per i notebook del 2026
Intel Panther Lake: i processori per i notebook del 2026
Panther Lake è il nome in codice della prossima generazione di processori Intel Core Ultra, che vedremo al debutto da inizio 2026 nei notebook e nei sistemi desktop più compatti. Nuovi core, nuove GPU e soprattutto una struttura a tile che vede per la prima volta l'utilizzo della tecnologia produttiva Intel 18A: tanta potenza in più, ma senza perdere in efficienza
Intel Xeon 6+: è tempo di Clearwater Forest
Intel Xeon 6+: è tempo di Clearwater Forest
Intel ha annunciato la prossima generazione di processori Xeon dotati di E-Core, quelli per la massima efficienza energetica e densità di elaborazione. Grazie al processo produttivo Intel 18A, i core passano a un massimo di 288 per ogni socket, con aumento della potenza di calcolo e dell'efficienza complessiva.
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 22-02-2013, 19:06   #21
cdimauro
Senior Member
 
L'Avatar di cdimauro
 
Iscritto dal: Jan 2002
Città: Germania
Messaggi: 26110
Quote:
Originariamente inviato da Vincenzo1968 Guarda i messaggi
Ah ok.

Mi disiscrivo dai, che mi si rompono i cabasisi a leggere di cdimauro che parla male del C.
Sei ossessionato dal C. Ogni critica per te è fumo negli occhi.

Non posso farci nulla se il Pascal, che peraltro è nato prima del C, offre un meccanismo più elegante per lo stesso concetto. Prenditela con Ritchie e Kernighan.
Quote:
Comunque non è che ci vuole l'arte di Pinna per leggere l'endianess del sistema e agire di conseguenza:

Codice:
char isBigEndian()
{
	short i = 0xABCD;
	unsigned char *buff;

	buff = (unsigned char*)&i;

	if( buff[0] == 0xAB )
		return 1;

	return 0;
}
Sarà un po' macchinoso ma è estremamente efficiente.
A parte il fatto che stai giocando coi puntatori in maniera sporca, in questo modo puoi soltanto capire qual è l'endianess, ma non risolvi il problema.

Dovresti definire due struct per i bitfield, e usare l'una o l'altra a seconda se il tuo sistema è big o little endian. Una cosa un po' pallosa e non di immediato utilizzo, visto che devi farlo a runtime (col tuo esempio).
Quote:
Tutto il contrario rispetto a python che è estremamente inefficiente: lento, lento, lento! Insopportabilmente lento. Lento ma così lento che più lento non si può.
Chi si accontenta gode.
__________________
Per iniziare a programmare c'è solo Python con questo o quest'altro (più avanzato) libro
@LinkedIn Non parlo in alcun modo a nome dell'azienda per la quale lavoro
Ho poco tempo per frequentare il forum; eventualmente, contattatemi in PVT o nel mio sito. Fanboys
cdimauro è offline   Rispondi citando il messaggio o parte di esso
Old 22-02-2013, 19:16   #22
The_ouroboros
Senior Member
 
L'Avatar di The_ouroboros
 
Iscritto dal: May 2007
Città: Milano
Messaggi: 7103
Quote:
Originariamente inviato da cdimauro Guarda i messaggi
Non c'è nessun supporto ufficiale ai bitfield/mask perché, essendo disponibile il tipo Set (e FronzenSet), si possono gestisce in scioltezza ed estrema semplicità gli insiemi come matematica insegna (con tutte le operazioni "classiche" definite):
Codice:
a = {0, 1, 5, 7}
b = {2, 5, 6, 7}
c = a | b
print c # Stampa: set([0, 1, 2, 5, 6, 7])
In alternativa, per chi vuole o lo ritiene opportuno, si definiscono le classiche costanti e si usano gli interi.
Ho visto anche che prefissando 0b ad un numero posso usarlo come binario e "giocare" con &,^,<<,>>,~ e |…
__________________
Apple Watch Ultra + iPhone 15 Pro Max + Rog Ally + Legion Go

Ultima modifica di The_ouroboros : 22-02-2013 alle 19:19.
The_ouroboros è offline   Rispondi citando il messaggio o parte di esso
Old 22-02-2013, 19:19   #23
cdimauro
Senior Member
 
L'Avatar di cdimauro
 
Iscritto dal: Jan 2002
Città: Germania
Messaggi: 26110
Sì, esatto, in questo modo puoi introdurre numeri interi in notazione binaria (poi c'è anche l'ottale e l'esadecimale), con la quale viene comodo definire sequenze di bit.
__________________
Per iniziare a programmare c'è solo Python con questo o quest'altro (più avanzato) libro
@LinkedIn Non parlo in alcun modo a nome dell'azienda per la quale lavoro
Ho poco tempo per frequentare il forum; eventualmente, contattatemi in PVT o nel mio sito. Fanboys
cdimauro è offline   Rispondi citando il messaggio o parte di esso
Old 22-02-2013, 19:23   #24
The_ouroboros
Senior Member
 
L'Avatar di The_ouroboros
 
Iscritto dal: May 2007
Città: Milano
Messaggi: 7103
Sempre più interessante sto serpentello...
Cmq è una valigia utile quella del "lavoro di bit"
__________________
Apple Watch Ultra + iPhone 15 Pro Max + Rog Ally + Legion Go
The_ouroboros è offline   Rispondi citando il messaggio o parte di esso
Old 22-02-2013, 20:17   #25
The_ouroboros
Senior Member
 
L'Avatar di The_ouroboros
 
Iscritto dal: May 2007
Città: Milano
Messaggi: 7103
Quote:
Bitwise operators are operators that work on multi-bit values, but conceptually one bit at a time.
Codice:
    AND is 1 only if both of its inputs are 1, otherwise it's 0.
    OR is 1 if one or both of its inputs are 1, otherwise it's 0.
    XOR is 1 only if exactly one of its inputs are 1, otherwise it's 0.
    NOT is 1 only if its input is 0, otherwise it's 0.
These can often be best shown as truth tables. Input possibilities are on the top and left, the resultant bit is one of the four (two in the case of NOT since it only has one input) values shown at the intersection of the inputs.
Codice:
AND | 0 1     OR | 0 1     XOR | 0 1   
----+-----    ---+----     ----+----        
 0  | 0 0      0 | 0 1       0 | 0 1             
 1  | 0 1      1 | 1 1       1 | 1 0
One example is if you only want the lower 4 bits of an integer, you AND it with 15 (binary 1111) so:
Codice:
      201: 1100 1001
AND  15: 0000 1111
------------------
 IS   9    0000 1001
The zero bits in 15(0b1111) in that case effectively act as a filter, forcing the bits in the result to be zero as well.

Another example is if you have two 4-bit values that you want to pack into an 8-bit one, you can use all three of your operators (left-shift, and and or):

Codice:
packed_val = ((val1 & 15) << 4) | (val2 & 15)
1. The & 15 operation will make sure that both values only have the lower 4 bits.
2. The << 4 is a 4-bit shift left to move val1 into the top 4 bits of an 8-bit value.
3. The | simply combines these two together.

If val1 is 7 and val2 is 4:
Codice:
                val1            val2
                ====            ====
 & 15 (and)   xxxx-0111       xxxx-0100  & 15
 << 4 (left)  0111-0000           |
                  |               |
                  +-------+-------+
                          |
| (or)                0111-0100
fonte: http://stackoverflow.com/questions/1...tion-and-usage
__________________
Apple Watch Ultra + iPhone 15 Pro Max + Rog Ally + Legion Go

Ultima modifica di The_ouroboros : 22-02-2013 alle 20:19.
The_ouroboros è offline   Rispondi citando il messaggio o parte di esso
Old 23-02-2013, 07:40   #26
sottovento
Senior Member
 
L'Avatar di sottovento
 
Iscritto dal: Nov 2005
Città: Texas
Messaggi: 1722
Quote:
Originariamente inviato da The_ouroboros Guarda i messaggi
Sono a casa in malattia e la mente divaga...
Il pensiero mi è ricaduto a qualche giorno fa quando debuggavo un programma e mi è sorta una domanda..
Chi usa ancora, con le moderne pipeline dei processori, le Bitwise operations?

Nel senso, a parte gli ambiente embedded, ovvio
Chiunque scrivi un driver o, in maniera piu' generale, abbia bisogno di accedere da un dispositivo hardware. Chi gioca con l'hardware preferisce ragionare in termini di segnali (i.e. bit) e non te li mette in byte diversi perche' costerebbe molto di piu'. Questo vale per chiunque, non solo per gli ambienti embedded.
__________________
In God we trust; all others bring data
sottovento è offline   Rispondi citando il messaggio o parte di esso
Old 23-02-2013, 07:46   #27
sottovento
Senior Member
 
L'Avatar di sottovento
 
Iscritto dal: Nov 2005
Città: Texas
Messaggi: 1722
Quote:
Originariamente inviato da cdimauro Guarda i messaggi
Togli pure il mi sembra: è una caratteristica non portabile del C, proprio per l'endianess.
Dipende da cosa intendi. Ci sono degli standard (lo so, mettere nella stessa frase "C" e "Standard" fa ridere. Potrei addirittura candidarmi alle elezioni), per cui i bit field vendono definiti a partire da LSB. Pertanto

Codice:
struct MyStruct
{
	unsigned int b0 : 1;
	unsigned int b1 : 1;
	unsigned int b2 : 1;
	unsigned int b3 : 1;
	unsigned int b4 : 1;
	unsigned int b5 : 1;
	unsigned int b6 : 1;
	unsigned int b7 : 1;
	unsigned int b8 : 1;
	unsigned int b9 : 1;
	unsigned int b10 : 1;
	unsigned int b11 : 1;
	unsigned int b12 : 1;
	unsigned int b13 : 1;
	unsigned int b14 : 1;
	unsigned int b16 : 1;
	unsigned int b17 : 1;
	unsigned int b18 : 1;
	unsigned int b19 : 1;
	unsigned int b20 : 1;
	unsigned int b21 : 1;
	unsigned int b22 : 1;
	unsigned int b23 : 1;
	unsigned int b24 : 1;
	unsigned int b25 : 1;
	unsigned int b26 : 1;
	unsigned int b27 : 1;
	unsigned int b28 : 1;
	unsigned int b29 : 1;
	unsigned int b30 : 1;
	unsigned int b31 : 1;
};

int main(int argc, char *argv[])
{
	int val = 0x01;
	MyStruct *p = (MyStruct *)&val;

	printf ("b0: %d   b31:%d\n", p->b0, p->b31);
}
generera' lo stesso output indipendentemente dall'endianness della macchina su cui gira.

Quote:
Originariamente inviato da cdimauro Guarda i messaggi
Sì. Il Pascal ha il concetto di Set, mentre in Modula-2 c'è proprio il BitMask (non ricordo se il tipo si chiama così).
Sia Pascal sia Modula-2 introducono i concetti di Set. Ma sono concetti ad alto livello, la loro rappresentazione non e' specificata. Il C, invece, e' fatto per rompere le scatole e lo deve fare fino in fondo

Altra cosa: se parli di Modula-2 significa che hai anche tu passato la quarantina. Mamma mia, stiamo invecchiando
__________________
In God we trust; all others bring data
sottovento è offline   Rispondi citando il messaggio o parte di esso
Old 23-02-2013, 07:54   #28
sottovento
Senior Member
 
L'Avatar di sottovento
 
Iscritto dal: Nov 2005
Città: Texas
Messaggi: 1722
Quote:
Originariamente inviato da Vincenzo1968 Guarda i messaggi
Ah ok.
Mi disiscrivo dai, che mi si rompono i cabasisi a leggere di cdimauro che parla male del C.
Sai che ci teniamo ai tuoi cabasisi! Su, dai, mettili nel cassetto, al sicuro

Quote:
Originariamente inviato da Vincenzo1968 Guarda i messaggi
Comunque non è che ci vuole l'arte di Pinna per leggere l'endianess del sistema e agire di conseguenza:

Codice:
char isBigEndian()
{
	short i = 0xABCD;
	unsigned char *buff;

	buff = (unsigned char*)&i;

	if( buff[0] == 0xAB )
		return 1;

	return 0;
}
Sarà un po' macchinoso ma è estremamente efficiente.
No, non e' macchinoso, e' la maniera corretta di procedere. Cmq, come scrivevo, non hai bisogno di conoscere l'endianness per definire la bitfield (e non potresti nemmeno). Al massimo sapere se sei su macchina big endian/little endian ti puo' servire se hai bisogno di accedere mediante mask a dei bit da words/double words.
Sempre che queste word arrivino da un sistema diverso (per esempio, stai leggendo lo stato di un dispositivo o decodificando dati via rete), altrimenti anche questo non ha senso
__________________
In God we trust; all others bring data
sottovento è offline   Rispondi citando il messaggio o parte di esso
Old 23-02-2013, 07:59   #29
The_ouroboros
Senior Member
 
L'Avatar di The_ouroboros
 
Iscritto dal: May 2007
Città: Milano
Messaggi: 7103
Quote:
Originariamente inviato da sottovento Guarda i messaggi
Chiunque scrivi un driver o, in maniera piu' generale, abbia bisogno di accedere da un dispositivo hardware. Chi gioca con l'hardware preferisce ragionare in termini di segnali (i.e. bit) e non te li mette in byte diversi perche' costerebbe molto di piu'. Questo vale per chiunque, non solo per gli ambienti embedded.
Interessante prospettiva.
Qualche info in più?
__________________
Apple Watch Ultra + iPhone 15 Pro Max + Rog Ally + Legion Go
The_ouroboros è offline   Rispondi citando il messaggio o parte di esso
Old 23-02-2013, 08:33   #30
sottovento
Senior Member
 
L'Avatar di sottovento
 
Iscritto dal: Nov 2005
Città: Texas
Messaggi: 1722
Quote:
Originariamente inviato da The_ouroboros Guarda i messaggi
Interessante prospettiva.
Qualche info in più?
Cioe'? Sui bitfield? O l'accesso all'hardware?
__________________
In God we trust; all others bring data
sottovento è offline   Rispondi citando il messaggio o parte di esso
Old 23-02-2013, 08:43   #31
cdimauro
Senior Member
 
L'Avatar di cdimauro
 
Iscritto dal: Jan 2002
Città: Germania
Messaggi: 26110
Quote:
Originariamente inviato da sottovento Guarda i messaggi
Dipende da cosa intendi. Ci sono degli standard (lo so, mettere nella stessa frase "C" e "Standard" fa ridere. Potrei addirittura candidarmi alle elezioni), per cui i bit field vendono definiti a partire da LSB.
In realtà lo standard ANSI e ISO lasciano indefinita l'implementazione dei campi di bit. Ecco perché parlavo di funzionalità non portabile del linguaggio.
Quote:
Pertanto

Codice:
struct MyStruct
{
	unsigned int b0 : 1;
[...]
	unsigned int b31 : 1;
};

int main(int argc, char *argv[])
{
	int val = 0x01;
	MyStruct *p = (MyStruct *)&val;

	printf ("b0: %d   b31:%d\n", p->b0, p->b31);
}
generera' lo stesso output indipendentemente dall'endianness della macchina su cui gira.
Se il compilatore alloca i bit sempre dall'LSB, come avevi supposto, dovrebbe dare un risultato diverso a seconda che la macchina sia little o big endian.

Se, invece, su macchina little endian parte dall'LSB, mentre per quelle big endian parte dall'MSB, allora il risultato sarà uguale.

Comunque rimane sempre da vedere come si comporta il compilatore (ci sarebbe da considerare anche il padding dei bit, che è anch'esso indefinito).

Altra cosa, se si definiscono meno bit rispetto alla dimensione della parola di macchina, come usualmente avviene (difficile che si allochino tutti i bit ogni volta), sorgono problemi.
Quote:
Sia Pascal sia Modula-2 introducono i concetti di Set. Ma sono concetti ad alto livello, la loro rappresentazione non e' specificata. Il C, invece, e' fatto per rompere le scatole e lo deve fare fino in fondo
Alla fine dipende dall'implementazione, come per il C. Una volta che sai come il compilatore alloca i bit, puoi fare quello che vuoi, e... si faceva (almeno io col Turbo Pascal di Borland).
Quote:
Altra cosa: se parli di Modula-2 significa che hai anche tu passato la quarantina. Mamma mia, stiamo invecchiando
Già. La cifra delle unità è pari a 2 nel mio caso.
__________________
Per iniziare a programmare c'è solo Python con questo o quest'altro (più avanzato) libro
@LinkedIn Non parlo in alcun modo a nome dell'azienda per la quale lavoro
Ho poco tempo per frequentare il forum; eventualmente, contattatemi in PVT o nel mio sito. Fanboys
cdimauro è offline   Rispondi citando il messaggio o parte di esso
Old 23-02-2013, 08:44   #32
The_ouroboros
Senior Member
 
L'Avatar di The_ouroboros
 
Iscritto dal: May 2007
Città: Milano
Messaggi: 7103
Quote:
Originariamente inviato da sottovento Guarda i messaggi
Cioe'? Sui bitfield? O l'accesso all'hardware?
Sul "giocare" con i segnali
__________________
Apple Watch Ultra + iPhone 15 Pro Max + Rog Ally + Legion Go
The_ouroboros è offline   Rispondi citando il messaggio o parte di esso
Old 23-02-2013, 09:09   #33
sottovento
Senior Member
 
L'Avatar di sottovento
 
Iscritto dal: Nov 2005
Città: Texas
Messaggi: 1722
Quote:
Originariamente inviato da The_ouroboros Guarda i messaggi
Sul "giocare" con i segnali
Bella domanda, ma forse troppo generica oltre che OT.
Per limitare un pochino, potrei dire che l'accesso all'hardware ("giocare" con i segnali) puo' essere fatto in maniera diversa a seconda
- del processore;
- dello standard di bus a cui il tuo hardware e' collegato (o all'assenza di standard);
- della quantita' di dati che si vuole scambiare;
- del tipo dei dati che si vuole scambiare.

La prima divisione che si puo' pensare e' fra I/O "classico" e "memory mapped". Alcuni processori tuttavia non possono fare questa distinzione. Il primo esempio che mi viene in mente sono i processori Motorola 68x che non avevano l'I/O classico ma tutto mappato in memoria.
Questo significa che accedere al dispositivo "semplicemente" significa scrivere/leggere a determinati indirizzi.

Ma forse la tua domanda era piu' semplice. Se vuoi cominciare a "giocare" ed ottenere qualcosa di utile (per esempio, poter controllare le luci di casa con il computer, magari anche attraverso internet/mail/sms) potresti guardare i kit di Nuova Elettronica (si, esiste ancora!!!), che funzionano SEMPRE!
Te li devi montare, quindi c'e' anche quel divertimento. Ti serve un minimo di conoscenze di elettronica. Niente di trascendentale, ma quanto meno devi saper maneggiare un saldatore
__________________
In God we trust; all others bring data
sottovento è offline   Rispondi citando il messaggio o parte di esso
Old 23-02-2013, 09:35   #34
The_ouroboros
Senior Member
 
L'Avatar di The_ouroboros
 
Iscritto dal: May 2007
Città: Milano
Messaggi: 7103
Quote:
Originariamente inviato da sottovento Guarda i messaggi

La prima divisione che si puo' pensare e' fra I/O "classico" e "memory mapped". Alcuni processori tuttavia non possono fare questa distinzione. Il primo esempio che mi viene in mente sono i processori Motorola 68x che non avevano l'I/O classico ma tutto mappato in memoria.
Questo significa che accedere al dispositivo "semplicemente" significa scrivere/leggere a determinati indirizzi.
Interessante, moolto interessante
__________________
Apple Watch Ultra + iPhone 15 Pro Max + Rog Ally + Legion Go
The_ouroboros è offline   Rispondi citando il messaggio o parte di esso
Old 23-02-2013, 09:41   #35
Vincenzo1968
Bannato
 
Iscritto dal: Mar 2008
Città: Villabate(PA)
Messaggi: 2515
Quote:
Originariamente inviato da sottovento Guarda i messaggi
No, non e' macchinoso, e' la maniera corretta di procedere. Cmq, come scrivevo, non hai bisogno di conoscere l'endianness per definire la bitfield (e non potresti nemmeno). Al massimo sapere se sei su macchina big endian/little endian ti puo' servire se hai bisogno di accedere mediante mask a dei bit da words/double words.
Sempre che queste word arrivino da un sistema diverso (per esempio, stai leggendo lo stato di un dispositivo o decodificando dati via rete), altrimenti anche questo non ha senso
No no, quale maniera corretta di procedere? Vuoi babbiare? Sto giocando in maniera sporca coi puntatori!

Non mi riferivo comunque alla bitfield. Dicevo in generale, sugli operatori bitwise. Se un software ha bisogno di memorizzare i dati su file in formato big endian, e tu sei su un sistema little endian, quella funzione ti serve per sapere se prima di salvare i dati sul file devi convertire da little endian a big endian.
É quello che ho fatto per il punto 3 del contest 17. Il bytecode della jvm dev'essere, secondo quanto riportato dalle specifiche, in formato big endian.

Ma gioco in maniera sporca coi puntatori... Uh! i puntatori!

Disiscritto dai.

Ultima modifica di Vincenzo1968 : 23-02-2013 alle 09:48.
Vincenzo1968 è offline   Rispondi citando il messaggio o parte di esso
Old 23-02-2013, 09:47   #36
sottovento
Senior Member
 
L'Avatar di sottovento
 
Iscritto dal: Nov 2005
Città: Texas
Messaggi: 1722
Quote:
Originariamente inviato da cdimauro Guarda i messaggi
In realtà lo standard ANSI e ISO lasciano indefinita l'implementazione dei campi di bit. Ecco perché parlavo di funzionalità non portabile del linguaggio.
Se la memoria non mi inganna, partire da lsb e' standard. Per questo che il codice sopra deve (dovrebbe?) dare gli stessi risultati indipendentemente dall'endianness.


Quote:
Originariamente inviato da cdimauro Guarda i messaggi
Se il compilatore alloca i bit sempre dall'LSB, come avevi supposto, dovrebbe dare un risultato diverso a seconda che la macchina sia little o big endian.
Eh no! Cmq l'endianness del bit field e' lo stesso dell'intero da cui ho prelevato l'indirizzo.

Ad ogni modo, siamo perfettamente d'accordo che affidare il funzionamento di un programma a questi dettagli e' da pazzi. Cosi' come siamo d'accordo che il C/C++ sia un linguaggio il cui utilizzo debba essere limitato ai casi strettamente necessari, if any.


Quote:
Originariamente inviato da cdimauro Guarda i messaggi
Già. La cifra delle unità è pari a 2 nel mio caso.
Nel mio, 3. Dai, non siamo vecchi: siamo interessanti
__________________
In God we trust; all others bring data
sottovento è offline   Rispondi citando il messaggio o parte di esso
Old 23-02-2013, 09:57   #37
Vincenzo1968
Bannato
 
Iscritto dal: Mar 2008
Città: Villabate(PA)
Messaggi: 2515
Dalla mia soluzione al contest 17:

endianess.h
Codice:
#ifndef ENDIANESS_H
#define ENDIANESS_H

#define BYTE unsigned char

#define S1 signed char
#define S2 signed short
#define S4 signed long
#define S8 signed __int64
#define U1 unsigned char
#define U2 unsigned short
#define U4 unsigned long
#define U8 unsigned __int64

#define F4 float
#define F8 double


#define FORMAT_WORD(arr,start){ fb[0]=arr[start+1];\
		fb[1]=arr[start];\
		arr[start]=fb[0];\
		arr[start+1]=fb[1]; }

#define FORMAT_DWORD(arr,start){ fb[0]=arr[start+3];\
		fb[1]=arr[start+2];\
		fb[2]=arr[start+1];\
		fb[3]=arr[start];\
		arr[start]=fb[0];\
		arr[start+1]=fb[1];\
		arr[start+2]=fb[2];\
		arr[start+3]=fb[3]; }

#define FORMAT_QWORD(arr,start){ fb[0]=arr[start+7];\
		fb[1]=arr[start+6];\
		fb[2]=arr[start+5];\
		fb[3]=arr[start+4];\
		fb[4]=arr[start+3];\
		fb[5]=arr[start+2];\
		fb[6]=arr[start+1];\
		fb[7]=arr[start];\
		arr[start]=fb[0];\
		arr[start+1]=fb[1];\
		arr[start+2]=fb[2];\
		arr[start+3]=fb[3];\
		arr[start+4]=fb[4];\
		arr[start+5]=fb[5];\
		arr[start+6]=fb[6];\
		arr[start+7]=fb[7]; }


char isBigEndian();

#endif /* ENDIANESS_H */
endianess.c
Codice:
#include "endianess.h"

/*
ritorna 1 se la macchina è big-endian, 0 se little-endian
*/
char isBigEndian()
{
	short i = 0xABCD;
	unsigned char *buff;

	buff = (unsigned char*)&i;

	if( buff[0] == 0xAB )
		return 1;

	return 0;
}
jvm.h
Codice:
#ifndef JVM_H
#define JVM_H

#define CONSTANT_Class  7
#define CONSTANT_Fieldref  9
#define CONSTANT_Methodref  10
#define CONSTANT_InterfaceMethodref  11
#define CONSTANT_String  8
#define CONSTANT_Integer  3
#define CONSTANT_Float  4
#define CONSTANT_Long  5
#define CONSTANT_Double  6
#define CONSTANT_NameAndType  12
#define CONSTANT_Utf8  1

#define ACC_PUBLIC  0x0001
#define ACC_PRIVATE  0x0002
#define ACC_PROTECTED  0x0004
#define ACC_STATIC  0x0008
#define ACC_FINAL  0x0010
#define ACC_SYNCHRONIZED  0x0020
#define ACC_SUPER  0x0020
#define ACC_VOLATILE  0x0040
#define ACC_TRANSIENT  0x0080
#define ACC_NATIVE  0x0100
#define ACC_INTERFACE  0x0200
#define ACC_ABSTRACT 0x0400
#define ACC_STRICT  0x0800


#define jvm_nop	0
#define jvm_aconst_null	1
#define jvm_iconst_m1	2
#define jvm_iconst_0	3
#define jvm_iconst_1	4
#define jvm_iconst_2	5
#define jvm_iconst_3	6
#define jvm_iconst_4	7
#define jvm_iconst_5	8
#define jvm_lconst_0	9
#define jvm_lconst_1	10
#define jvm_fconst_0	11
#define jvm_fconst_1	12
#define jvm_fconst_2	13
#define jvm_dconst_0	14
#define jvm_dconst_1	15
#define jvm_bipush	16
#define jvm_sipush	17
#define jvm_ldc	18
#define jvm_ldc_w	19
#define jvm_ldc2_w	20
#define jvm_iload	21
#define jvm_lload	22
#define jvm_fload	23
#define jvm_dload	24
#define jvm_aload	25
#define jvm_iload_0	26
#define jvm_iload_1	27
#define jvm_iload_2	28
#define jvm_iload_3	29
#define jvm_lload_0	30
#define jvm_lload_1	31
#define jvm_lload_2	32
#define jvm_lload_3	33
#define jvm_fload_0	34
#define jvm_fload_1	35
#define jvm_fload_2	36
#define jvm_fload_3	37
#define jvm_dload_0	38
#define jvm_dload_1	39
#define jvm_dload_2	40
#define jvm_dload_3	41
#define jvm_aload_0	42
#define jvm_aload_1	43
#define jvm_aload_2	44
#define jvm_aload_3	45
#define jvm_iaload	46
#define jvm_laload	47
#define jvm_faload	48
#define jvm_daload	49
#define jvm_aaload	50
#define jvm_baload	51
#define jvm_caload	52
#define jvm_saload	53
#define jvm_istore	54
#define jvm_lstore	55
#define jvm_fstore	56
#define jvm_dstore	57
#define jvm_astore	58
#define jvm_istore_0	59
#define jvm_istore_1	60
#define jvm_istore_2	61
#define jvm_istore_3	62
#define jvm_lstore_0	63
#define jvm_lstore_1	64
#define jvm_lstore_2	65
#define jvm_lstore_3	66
#define jvm_fstore_0	67
#define jvm_fstore_1	68
#define jvm_fstore_2	69
#define jvm_fstore_3	70
#define jvm_dstore_0	71
#define jvm_dstore_1	72
#define jvm_dstore_2	73
#define jvm_dstore_3	74
#define jvm_astore_0	75
#define jvm_astore_1	76
#define jvm_astore_2	77
#define jvm_astore_3	78
#define jvm_iastore	79
#define jvm_lastore	80
#define jvm_fastore	81
#define jvm_dastore	82
#define jvm_aastore	83
#define jvm_bastore	84
#define jvm_castore	85
#define jvm_sastore	86
#define jvm_pop	87
#define jvm_pop2	88
#define jvm_dup	89
#define jvm_dup_x1	90
#define jvm_dup_x2	91
#define jvm_dup2	92
#define jvm_dup2_x1	93
#define jvm_dup2_x2	94
#define jvm_swap	95
#define jvm_iadd	96
#define jvm_ladd	97
#define jvm_fadd	98
#define jvm_dadd	99
#define jvm_isub	100
#define jvm_lsub	101
#define jvm_fsub	102
#define jvm_dsub	103
#define jvm_imul	104
#define jvm_lmul	105
#define jvm_fmul	106
#define jvm_dmul	107
#define jvm_idiv	108
#define jvm_ldiv	109
#define jvm_fdiv	110
#define jvm_ddiv	111
#define jvm_irem	112
#define jvm_lrem	113
#define jvm_frem	114
#define jvm_drem	115
#define jvm_ineg	116
#define jvm_lneg	117
#define jvm_fneg	118
#define jvm_dneg	119
#define jvm_ishl	120
#define jvm_lshl	121
#define jvm_ishr	122
#define jvm_lshr	123
#define jvm_iushr	124
#define jvm_lushr	125
#define jvm_iand	126
#define jvm_land	127
#define jvm_ior	128
#define jvm_lor	129
#define jvm_ixor	130
#define jvm_lxor	131
#define jvm_iinc	132
#define jvm_i2l	133
#define jvm_i2f	134
#define jvm_i2d	135
#define jvm_l2i	136
#define jvm_l2f	137
#define jvm_l2d	138
#define jvm_f2i	139
#define jvm_f2l	140
#define jvm_f2d	141
#define jvm_d2i	142
#define jvm_d2l	143
#define jvm_d2f	144
#define jvm_i2b	145
#define jvm_i2c	146
#define jvm_i2s	147
#define jvm_lcmp	148
#define jvm_fcmpl	149
#define jvm_fcmpg	150
#define jvm_dcmpl	151
#define jvm_dcmpg	152
#define jvm_ifeq	153
#define jvm_ifne	154
#define jvm_iflt	155
#define jvm_ifge	156
#define jvm_ifgt	157
#define jvm_ifle	158
#define jvm_if_icmpeq	159
#define jvm_if_icmpne	160
#define jvm_if_icmplt	161
#define jvm_if_icmpge	162
#define jvm_if_icmpgt	163
#define jvm_if_icmple	164
#define jvm_if_acmpeq	165
#define jvm_if_acmpne	166
#define jvm_goto	167
#define jvm_jsr	168
#define jvm_ret	169
#define jvm_tableswitch	170
#define jvm_lookupswitch	171
#define jvm_ireturn	172
#define jvm_lreturn	173
#define jvm_freturn	174
#define jvm_dreturn	175
#define jvm_areturn	176
#define jvm_return	177
#define jvm_getstatic	178
#define jvm_putstatic	179
#define jvm_getfield	180
#define jvm_putfield	181
#define jvm_invokevirtual	182
#define jvm_invokespecial	183
#define jvm_invokestatic	184
#define jvm_invokeinterface	185
#define jvm_xxxunusedxxx	186
#define jvm_new	187
#define jvm_newarray	188
#define jvm_anewarray	189
#define jvm_arraylength	190
#define jvm_athrow	191
#define jvm_checkcast	192
#define jvm_instanceof	193
#define jvm_monitorenter	194
#define jvm_monitorexit	195
#define jvm_wide	196
#define jvm_multianewarray	197
#define jvm_ifnull	198
#define jvm_ifnonnull	199
#define jvm_goto_w	200
#define jvm_jsr_w	201
#define jvm_breakpoint	202
#define jvm_impdep1	254
#define jvm_impdep2	255


/*
char *I_Set[256] =
{
"nop",
"aconst_null",
"iconst_m1",
"iconst_0",
"iconst_1",
"iconst_2",
"iconst_3",
"iconst_4",
"iconst_5",
"lconst_0",
"lconst_1",
"fconst_0",
"fconst_1",
"fconst_2",
"dconst_0",
"dconst_1",
"bipush",
"sipush",
"ldc",
"ldc_w",
"ldc2_w",
"iload",
"lload",
"fload",
"dload",
"aload",
"iload_0",
"iload_1",
"iload_2",
"iload_3",
"lload_0",
"lload_1",
"lload_2",
"lload_3",
"fload_0",
"fload_1",
"fload_2",
"fload_3",
"dload_0",
"dload_1",
"dload_2",
"dload_3",
"aload_0",
"aload_1",
"aload_2",
"aload_3",
"iaload",
"laload",
"faload",
"daload",
"aaload",
"baload",
"caload",
"saload",
"istore",
"lstore",
"fstore",
"dstore",
"astore",
"istore_0",
"istore_1",
"istore_2",
"istore_3",
"lstore_0",
"lstore_1",
"lstore_2",
"lstore_3",
"fstore_0",
"fstore_1",
"fstore_2",
"fstore_3",
"dstore_0",
"dstore_1",
"dstore_2",
"dstore_3",
"astore_0",
"astore_1",
"astore_2",
"astore_3",
"iastore",
"lastore",
"fastore",
"dastore",
"aastore",
"bastore",
"castore",
"sastore",
"pop",
"pop2",
"dup",
"dup_x1",
"dup_x2",
"dup2",
"dup2_x1",
"dup2_x2",
"swap",
"iadd",
"ladd",
"fadd",
"dadd",
"isub",
"lsub",
"fsub",
"dsub",
"imul",
"lmul",
"fmul",
"dmul",
"idiv",
"ldiv",
"fdiv",
"ddiv",
"irem",
"lrem",
"frem",
"drem",
"ineg",
"lneg",
"fneg",
"dneg",
"ishl",
"lshl",
"ishr",
"lshr",
"iushr",
"lushr",
"iand",
"land",
"ior",
"lor",
"ixor",
"lxor",
"iinc",
"i2l",
"i2f",
"i2d",
"l2i",
"l2f",
"l2d",
"f2i",
"f2l",
"f2d",
"d2i",
"d2l",
"d2f",
"i2b",
"i2c",
"i2s",
"lcmp",
"fcmpl",
"fcmpg",
"dcmpl",
"dcmpg",
"ifeq",
"ifne",
"iflt",
"ifge",
"ifgt",
"ifle",
"if_icmpeq",
"if_icmpne",
"if_icmplt",
"if_icmpge",
"if_icmpgt",
"if_icmple",
"if_acmpeq",
"if_acmpne",
"goto",
"jsr",
"ret",
"tableswitch",
"lookupswitch",
"ireturn",
"lreturn",
"freturn",
"dreturn",
"areturn",
"return",
"getstatic",
"putstatic",
"getfield",
"putfield",
"invokevirtual",
"invokespecial",
"invokestatic",
"invokeinterface",
"xxxunusedxxx",
"new",
"newarray",
"anewarray",
"arraylength",
"athrow",
"checkcast",
"instanceof",
"monitorenter",
"monitorexit",
"wide",
"multianewarray",
"ifnull",
"ifnonnull",
"goto_w",
"jsr_w",
"breakpoint",
"", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "",
"", "", "",
"impdep1",
"impdep2"
};
*/

#include "symtab.h"
#include "ast.h"

#define JVM_HT_SIZE 4096

typedef struct tag_jvmHashTable
{
	char *Key;
	unsigned short c; /*indice constant pool table*/
	struct tag_jvmHashTable *next;
} jvmHashTable;

jvmHashTable* jvmhtNewNode(char *Key, unsigned short c);
int jvmhtFind(jvmHashTable **pHashTable, char *Key, unsigned short *c);
void jvmhtInsert(jvmHashTable **pHashTable, char *Key, unsigned short c);
void jvmhtFree(jvmHashTable* first);

void jvmSetNumberLocals(int n);

void jvmWriteHeader(FILE *fp);
int jvmMakeConstantPool(char *szSourceFile, char *szClassName);
int jvmAddArrayClass(int type, int sizes, int index);
int jvmAddStringConstant(char *sz, int index);
int jvmAddIntegerConstant(int c, int index);
int jvmAddRealConstant(double c, int index);
void jvmWriteInfo(FILE *fp);
void jvmWriteInitMethod(FILE *fp);
void jvmWriteMainMethod(FILE *fp, nodeType *pTree, jvmHashTable **pHT);
void MakeOutputFileName(char *szInputFileName, char *szOutputFileName, char *szFileNameWithoutExt, char *szExt);
void jvmTypeCheck(int t1, int t2);
void MakeBytecodeMain(nodeType *p, jvmHashTable **pHT, Scope *pScope);
void jvmStart(char *szInputFileName, nodeType *pTree, Scope *pScope);

#endif /* JVM_H */
jvm.c
Codice:
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h> 
#include <ctype.h>
#include <math.h>
#include "scanner.h"
#include "endianess.h"
#include "jvm.h"

/*#pragma warning(disable : 4996)*/

#define ARRAY_TO_S2(arr,v){ buff = (BYTE*)&v;\
		FORMAT_WORD(arr,0);\
		v = *( (S2*)arr ); }

#define ARRAY_TO_S4(arr,v){ buff = (BYTE*)&v;\
		FORMAT_DWORD(arr,0);\
		v = *( (S4*)arr ); }

#define ARRAY_TO_S8(arr,v){ buff = (BYTE*)&v;\
		FORMAT_QWORD(arr,0);\
		v = *( (S8*)arr ); }

#define ARRAY_TO_U2(arr,v){ buff = (BYTE*)&v;\
		FORMAT_WORD(arr,0);\
		v = *( (U2*)arr ); }

#define ARRAY_TO_U4(arr,v){ buff = (BYTE*)&v;\
		FORMAT_DWORD(arr,0);\
		v = *( (U4*)arr ); }

#define ARRAY_TO_U8(arr,v){ buff = (BYTE*)&v;\
		FORMAT_QWORD(arr,0);\
		v = *( (U8*)arr ); }

#define ARRAY_TO_F4(arr,v){ buff = (BYTE*)&v;\
		FORMAT_DWORD(arr,0);\
		v = *( (F4*)arr ); }

#define ARRAY_TO_F8(arr,v){ buff = (BYTE*)&v;\
		FORMAT_QWORD(arr,0);\
		v = *( (F8*)arr ); }

U2 g_ConstantPoolCount = 68;
/*U2 g_ConstantPoolCount = 13;*/
U1 g_ArrayConstantPool[4096];
U1 g_ArrayCode[4096];

int g_IndexConstantPool;
int g_IndexBytecodeArray = 0;

U2 g_max_stack = 0;
U2 g_max_locals = 1;
U4 g_code_length = 0;


/*-------------------------- HashTable -----------------------------------------*/


/*HashTable* htNewNode(char *Key, enumTipo0 t0, enumTipo1 t1, enumTipo2 t2, Valore v, char bInizializzato)*/
jvmHashTable* jvmhtNewNode(char *Key, unsigned short c)
{
	jvmHashTable *n;

	n = (jvmHashTable*)malloc(sizeof(jvmHashTable));

	if( n == NULL )
		return NULL;

	n->Key = (char*)malloc(strlen(Key)+1);
	if ( n->Key == NULL )
	{
		free(n);
		return NULL;
	}
	strcpy(n->Key, Key);
	n->c = c;
	n->next = NULL;

	return n;
}

/*int htFind(HashTable **pHashTable, char *Key, HashTable *pDati)*/
int jvmhtFind(jvmHashTable **pHashTable, char *Key, unsigned short *c)
{
	int index = 0;
	jvmHashTable *t;
	int a = 31415;
	/* int b = 27183; */
	char szTemp[1024];
	/*char *s = Key;*/
	char *s = szTemp;

	strcpy(szTemp, Key);

	*c = 0;

	for(; *s != '\0'; s++)
	{
		if ( *s == '\n' )
			*s = ' ';
		index = (a*index + *s) % JVM_HT_SIZE;
	}
	if ( index < 0 )
		index *= -1;

	t = pHashTable[index];
	while ( t != NULL )
	{
		if ( strcmp(t->Key, Key) == 0 )
		{
			*c = t->c;
			return 1;
		}
		t = t->next;
	}

	return 0;
}

/*void htInsert(HashTable **pHashTable, char *Key, enumTipo0 t0, enumTipo1 t1, enumTipo2 t2, Valore v, char bInizializzato)*/
void jvmhtInsert(jvmHashTable **pHashTable, char *Key, unsigned short c)
{
	int index = 0;
	jvmHashTable *t = NULL;
	int a = 31415;
	/* int b = 27183; */
	char szTemp[1024];
	/*char *s = Key;*/
	char *s = szTemp;

	strcpy(szTemp, Key);

	for(; *s != '\0'; s++)
	{
		if ( *s == '\n' )
			*s = ' ';
		index = (a*index + *s) % JVM_HT_SIZE;
	}
	if ( index < 0 )
		index *= -1;

	t = pHashTable[index];
	if ( t == NULL )
	{
		pHashTable[index] = jvmhtNewNode(Key, c);
		return;
	}

	while ( t != NULL )
	{
		if ( strcmp(t->Key, Key) == 0 )
		{
			/*pHashTable[index]->pLista = ListAppend(pHashTable[index]->pLista, pos);*/
			printf("\nErrore: La chiave %s e' gia' presente nella hashtable\n", Key);
			return;
		}
		if ( t->next == NULL )
		{
			t->next = jvmhtNewNode(Key, c);
			/*t = t->next;*/
			/*t->next = NULL;*/
			return;
		}
		t = t->next;
	}
}

void jvmhtFree(jvmHashTable* first)
{
	jvmHashTable *n1 = first, *n2;
	while ( n1 != NULL )
	{
		n2 = n1->next;
		if ( n1->Key )
		{
			free(n1->Key);
		}
		free(n1);
		n1 = n2;
	}
}

/*------------------------------ JVM ----------------------------------------------*/

void jvmSetNumberLocals(int n)
{
	g_max_locals = n;
}

void jvmWriteHeader(FILE *fp)
{
	U4 magic = 0xCAFEBABE;
	U2 minor_version = 0;
	U2 major_version = 50;

	BYTE *buff;
	U1 fb[8]; /*Necessario per usare le macro;*/

	if ( !isBigEndian() )
	{
		ARRAY_TO_U4(buff, magic);
		ARRAY_TO_U2(buff, minor_version);
		ARRAY_TO_U2(buff, major_version);
	}

	fwrite(&magic, sizeof(U4), 1, fp);
	fwrite(&minor_version, sizeof(U2), 1, fp);
	fwrite(&major_version, sizeof(U2), 1, fp);
}

int jvmMakeConstantPool(char *szSourceFile, char *szClassName)
{
	int k;
	int index = 0;
	U1 tag;
	U2 name_index;
	U2 class_index;
	U2 name_and_type_index;
	U2 descriptor_index;
	U2 length;
	U2 lengthBigEndian;

	char szStringa[1024];

	U1 fb[8]; /*Necessario per usare le macro;*/
	BYTE *buff;

	tag = CONSTANT_Class;
	for ( k = 25; k < 33; k++)
	{
		g_ArrayConstantPool[index++] = tag;
		name_index = k;
		if ( !isBigEndian() )
		{
			ARRAY_TO_U2(buff, name_index);
		}
		memcpy(g_ArrayConstantPool + index, &name_index, 2);
		index += 2;
	}

	tag = CONSTANT_Fieldref;
	class_index = 3;
	name_and_type_index = 33;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, class_index);
		ARRAY_TO_U2(buff, name_and_type_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &class_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &name_and_type_index, 2);
	index += 2;



	tag = CONSTANT_Methodref;

	class_index = 2;
	name_and_type_index = 36;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, class_index);
		ARRAY_TO_U2(buff, name_and_type_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &class_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &name_and_type_index, 2);
	index += 2;

	class_index = 6;
	name_and_type_index = 36;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, class_index);
		ARRAY_TO_U2(buff, name_and_type_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &class_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &name_and_type_index, 2);
	index += 2;

	class_index = 6;
	name_and_type_index = 39;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, class_index);
		ARRAY_TO_U2(buff, name_and_type_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &class_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &name_and_type_index, 2);
	index += 2;

	class_index = 6;
	name_and_type_index = 42;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, class_index);
		ARRAY_TO_U2(buff, name_and_type_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &class_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &name_and_type_index, 2);
	index += 2;

	class_index = 4;
	name_and_type_index = 45;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, class_index);
		ARRAY_TO_U2(buff, name_and_type_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &class_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &name_and_type_index, 2);
	index += 2;

	class_index = 3;
	name_and_type_index = 48;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, class_index);
		ARRAY_TO_U2(buff, name_and_type_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &class_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &name_and_type_index, 2);
	index += 2;

	class_index = 5;
	name_and_type_index = 51;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, class_index);
		ARRAY_TO_U2(buff, name_and_type_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &class_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &name_and_type_index, 2);
	index += 2;

	class_index = 7;
	name_and_type_index = 54;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, class_index);
		ARRAY_TO_U2(buff, name_and_type_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &class_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &name_and_type_index, 2);
	index += 2;

	class_index = 8;
	name_and_type_index = 57;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, class_index);
		ARRAY_TO_U2(buff, name_and_type_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &class_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &name_and_type_index, 2);
	index += 2;




	tag = CONSTANT_Utf8;

	strcpy(szStringa, "Code");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "LineNumberTable");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "main");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "([Ljava/lang/String;)V");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "SourceFile");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, szSourceFile);
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	/*strcpy(szStringa, "PrintDemo");*/
	strcpy(szStringa, szClassName);
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "java/lang/Object");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "java/lang/System");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "java/io/PrintStream");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "java/io/Console");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "java/lang/StringBuilder");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "java/lang/Integer");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "java/lang/Double");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;


	tag = CONSTANT_NameAndType;
	name_index = 34;
	descriptor_index = 35;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, name_index);
		ARRAY_TO_U2(buff, descriptor_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &name_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &descriptor_index, 2);
	index += 2;

	tag = CONSTANT_Utf8;
	strcpy(szStringa, "out");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "Ljava/io/PrintStream;");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;


	tag = CONSTANT_NameAndType;
	name_index = 37;
	descriptor_index = 38;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, name_index);
		ARRAY_TO_U2(buff, descriptor_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &name_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &descriptor_index, 2);
	index += 2;

	tag = CONSTANT_Utf8;
	strcpy(szStringa, "<init>");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "()V");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;


	tag = CONSTANT_NameAndType;
	name_index = 40;
	descriptor_index = 41;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, name_index);
		ARRAY_TO_U2(buff, descriptor_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &name_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &descriptor_index, 2);
	index += 2;

	tag = CONSTANT_Utf8;
	strcpy(szStringa, "append");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "(Ljava/lang/String;)Ljava/lang/StringBuilder;");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;


	tag = CONSTANT_NameAndType;
	name_index = 43;
	descriptor_index = 44;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, name_index);
		ARRAY_TO_U2(buff, descriptor_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &name_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &descriptor_index, 2);
	index += 2;

	tag = CONSTANT_Utf8;
	strcpy(szStringa, "toString");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "()Ljava/lang/String;");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;


	tag = CONSTANT_NameAndType;
	name_index = 46;
	descriptor_index = 47;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, name_index);
		ARRAY_TO_U2(buff, descriptor_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &name_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &descriptor_index, 2);
	index += 2;

	tag = CONSTANT_Utf8;
	strcpy(szStringa, "print");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "(Ljava/lang/String;)V");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;


	tag = CONSTANT_NameAndType;
	name_index = 49;
	descriptor_index = 50;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, name_index);
		ARRAY_TO_U2(buff, descriptor_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &name_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &descriptor_index, 2);
	index += 2;

	tag = CONSTANT_Utf8;
	strcpy(szStringa, "console");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "()Ljava/io/Console;");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;


	tag = CONSTANT_NameAndType;
	name_index = 52;
	descriptor_index = 53;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, name_index);
		ARRAY_TO_U2(buff, descriptor_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &name_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &descriptor_index, 2);
	index += 2;

	tag = CONSTANT_Utf8;
	strcpy(szStringa, "readLine");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "()Ljava/lang/String;");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;


	tag = CONSTANT_NameAndType;
	name_index = 55;
	descriptor_index = 56;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, name_index);
		ARRAY_TO_U2(buff, descriptor_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &name_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &descriptor_index, 2);
	index += 2;

	tag = CONSTANT_Utf8;
	strcpy(szStringa, "parseInt");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "(Ljava/lang/String;)I");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;


	tag = CONSTANT_NameAndType;
	name_index = 58;
	descriptor_index = 59;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, name_index);
		ARRAY_TO_U2(buff, descriptor_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &name_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &descriptor_index, 2);
	index += 2;

	tag = CONSTANT_Utf8;
	strcpy(szStringa, "parseDouble");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	strcpy(szStringa, "(Ljava/lang/String;)D");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;



	/*---------------------- Aggiunti in seguito --------------------*/

	tag = CONSTANT_Methodref;
	class_index = 4;
	name_and_type_index = 61;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, class_index);
		ARRAY_TO_U2(buff, name_and_type_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &class_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &name_and_type_index, 2);
	index += 2;

	tag = CONSTANT_NameAndType;
	name_index = 46;
	descriptor_index = 62;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, name_index);
		ARRAY_TO_U2(buff, descriptor_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &name_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &descriptor_index, 2);
	index += 2;

	tag = CONSTANT_Utf8;
	strcpy(szStringa, "(I)V");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;


	tag = CONSTANT_Methodref;
	class_index = 4;
	name_and_type_index = 64;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, class_index);
		ARRAY_TO_U2(buff, name_and_type_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &class_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &name_and_type_index, 2);
	index += 2;

	tag = CONSTANT_NameAndType;
	name_index = 46;
	descriptor_index = 65;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, name_index);
		ARRAY_TO_U2(buff, descriptor_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &name_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &descriptor_index, 2);
	index += 2;

	tag = CONSTANT_Utf8;
	strcpy(szStringa, "(D)V");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;


	tag = CONSTANT_Methodref;
	class_index = 4;
	name_and_type_index = 67;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, class_index);
		ARRAY_TO_U2(buff, name_and_type_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &class_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &name_and_type_index, 2);
	index += 2;

	tag = CONSTANT_NameAndType;
	name_index = 46;
	descriptor_index = 68;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, name_index);
		ARRAY_TO_U2(buff, descriptor_index);
	}
	g_ArrayConstantPool[index++] = tag;
	memcpy(g_ArrayConstantPool + index, &name_index, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, &descriptor_index, 2);
	index += 2;

	tag = CONSTANT_Utf8;
	strcpy(szStringa, "(Z)V");
	length = strlen(szStringa);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szStringa, length);
	index += length;

	return index;
}

int jvmAddArrayClass(int type, int sizes, int index)
{
	char szClassName[512];
	U1 tag;
	U2 string_index;
	U2 length;
	U2 lengthBigEndian;

	U1 fb[8]; /*Necessario per usare le macro;*/
	BYTE *buff;

	int k;

	tag = CONSTANT_Class;
	g_ArrayConstantPool[index++] = tag;
	string_index = g_ConstantPoolCount + 2;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, string_index);
	}
	memcpy(g_ArrayConstantPool + index, &string_index, 2);
	index += 2;

	tag = CONSTANT_Utf8;
	strcpy(szClassName, "[");
	for ( k = 1; k < sizes; k++ )
	{
		strcat(szClassName, "[");
	}
	if ( type == T_INTEGER )
		strcat(szClassName, "I");
	if ( type == T_REAL )
		strcat(szClassName, "D");
	if ( type == T_BOOLEAN )
		strcat(szClassName, "Z");
	if ( type == T_STRING )
		strcat(szClassName, "Ljava/lang/String;");
	length = strlen(szClassName);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, szClassName, length);
	index += length;

	g_ConstantPoolCount += 2;

	return index;
}


int jvmAddStringConstant(char *sz, int index)
{
	U1 tag;
	U2 string_index;
	U2 length;
	U2 lengthBigEndian;

	U1 fb[8]; /*Necessario per usare le macro;*/
	BYTE *buff;

	tag = CONSTANT_String;
	g_ArrayConstantPool[index++] = tag;
	string_index = g_ConstantPoolCount + 2;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, string_index);
	}
	memcpy(g_ArrayConstantPool + index, &string_index, 2);
	index += 2;

	tag = CONSTANT_Utf8;
	length = strlen(sz);
	lengthBigEndian = length;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, lengthBigEndian);
	}
	memcpy(g_ArrayConstantPool + index, &lengthBigEndian, 2);
	index += 2;
	memcpy(g_ArrayConstantPool + index, sz, length);
	index += length;

	g_ConstantPoolCount += 2;

	return index;
}

int jvmAddIntegerConstant(int c, int index)
{
	U1 tag;
	U4 bytes = (U4)c;

	U1 fb[8]; /*Necessario per usare le macro;*/
	BYTE *buff;

	tag = CONSTANT_Integer;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U4(buff, bytes);
	}
	memcpy(g_ArrayConstantPool + index, &bytes, 4);
	index += 4;

	g_ConstantPoolCount++;

	return index;
}

int jvmAddRealConstant(double c, int index)
{
	U1 tag;
	F8 bytes = (F8)c;

	U1 fb[8]; /*Necessario per usare le macro;*/
	BYTE *buff;

	tag = CONSTANT_Double;
	g_ArrayConstantPool[index++] = tag;
	if ( !isBigEndian() )
	{
		ARRAY_TO_F8(buff, bytes);
	}
	memcpy(g_ArrayConstantPool + index, &bytes, 8);
	index += 8;

	g_ConstantPoolCount += 2;

	return index;
}

void jvmWriteInfo(FILE *fp)
{
	U2 access_flags = ACC_SUPER;
    U2 this_class = 1;
    U2 super_class = 2;
    U2 interfaces_count = 0;
    U2 fields_count = 0;
    U2 methods_count = 2;

	BYTE *buff;
	U1 fb[8]; /*Necessario per usare le macro;*/

	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, access_flags);
		ARRAY_TO_U2(buff, this_class);
		ARRAY_TO_U2(buff, super_class);
		ARRAY_TO_U2(buff, interfaces_count);
		ARRAY_TO_U2(buff, fields_count);
		ARRAY_TO_U2(buff, methods_count);
	}

	fwrite(&access_flags, sizeof(U2), 1, fp);
	fwrite(&this_class, sizeof(U2), 1, fp);
	fwrite(&super_class, sizeof(U2), 1, fp);
	fwrite(&interfaces_count, sizeof(U2), 1, fp);
	fwrite(&fields_count, sizeof(U2), 1, fp);
	fwrite(&methods_count, sizeof(U2), 1, fp);
}

void jvmWriteInitMethod(FILE *fp)
{
	U1 bytecode;
	U2 param;
	U2 access_flags = 0;
    U2 name_index = 37;
    U2 descriptor_index = 38;
    U2 attributes_count = 1;
	U2 attribute_name_index = 19;
    U4 attribute_length = 17;
    U2 max_stack = 1;
    U2 max_locals = 1;
    U4 code_length = 5;
    U2 exception_table_length = 0;
	/*
    {    	u2 start_pc;
          	u2 end_pc;
         	u2  handler_pc;
          	u2  catch_type;
    }	exception_table[exception_table_length];
	*/
	BYTE *buff;
	U1 fb[8]; /*Necessario per usare le macro;*/

	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, access_flags);
		ARRAY_TO_U2(buff, name_index);
		ARRAY_TO_U2(buff, descriptor_index);
		ARRAY_TO_U2(buff, attributes_count);
		ARRAY_TO_U2(buff, attribute_name_index);
		ARRAY_TO_U4(buff, attribute_length);
		ARRAY_TO_U2(buff, max_stack);
		ARRAY_TO_U2(buff, max_locals);
		ARRAY_TO_U4(buff, code_length);
	}

	fwrite(&access_flags, sizeof(U2), 1, fp);
	fwrite(&name_index, sizeof(U2), 1, fp);
	fwrite(&descriptor_index, sizeof(U2), 1, fp);
	fwrite(&attributes_count, sizeof(U2), 1, fp);
	fwrite(&attribute_name_index, sizeof(U2), 1, fp);
	fwrite(&attribute_length, sizeof(U4), 1, fp);
	fwrite(&max_stack, sizeof(U2), 1, fp);
	fwrite(&max_locals, sizeof(U2), 1, fp);
	fwrite(&code_length, sizeof(U4), 1, fp);

	bytecode = jvm_aload_0;
	fwrite(&bytecode, sizeof(U1), 1, fp);

	bytecode = jvm_invokespecial;
	fwrite(&bytecode, sizeof(U1), 1, fp);

	param = 10; /*Method java/lang/Object."<init>":()V*/
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, param);
	}
	fwrite(&param, sizeof(U2), 1, fp);

	bytecode = jvm_return;
	fwrite(&bytecode, sizeof(U1), 1, fp);


	exception_table_length = 0;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, exception_table_length);
	}
	fwrite(&exception_table_length, sizeof(U2), 1, fp);

	attributes_count = 0;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, attributes_count);
	}
	fwrite(&attributes_count, sizeof(U2), 1, fp);
}

void jvmWriteMainMethod(FILE *fp, nodeType *pTree, jvmHashTable **pHT)
{
	U2 access_flags = ACC_PUBLIC | ACC_STATIC;

    U2 name_index = 21;
    U2 descriptor_index = 22;

    U2 attributes_count = 1;
	U2 attribute_name_index = 19;

    U4 attribute_length;
    U4 code_lengthBigEndian;
    U2 exception_table_length = 0;

	BYTE *buff;
	U1 fb[8]; /*Necessario per usare le macro;*/

	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, access_flags);
		ARRAY_TO_U2(buff, name_index);
		ARRAY_TO_U2(buff, descriptor_index);
		ARRAY_TO_U2(buff, attributes_count);
		ARRAY_TO_U2(buff, attribute_name_index);
	}

	fwrite(&access_flags, sizeof(U2), 1, fp);
	fwrite(&name_index, sizeof(U2), 1, fp);
	fwrite(&descriptor_index, sizeof(U2), 1, fp);
	fwrite(&attributes_count, sizeof(U2), 1, fp);
	fwrite(&attribute_name_index, sizeof(U2), 1, fp);

	code_lengthBigEndian = g_code_length;

	attribute_length = 12;
	attribute_length += g_code_length;

	if ( !isBigEndian() )
	{
		ARRAY_TO_U4(buff, attribute_length);
		ARRAY_TO_U2(buff, g_max_stack);
		ARRAY_TO_U2(buff, g_max_locals);
		ARRAY_TO_U4(buff, code_lengthBigEndian);
	}

	fwrite(&attribute_length, sizeof(U4), 1, fp);
	fwrite(&g_max_stack, sizeof(U2), 1, fp);
	fwrite(&g_max_locals, sizeof(U2), 1, fp);
	fwrite(&code_lengthBigEndian, sizeof(U4), 1, fp);

	fwrite(g_ArrayCode, g_code_length, 1, fp);

	exception_table_length = 0;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, exception_table_length);
	}
	fwrite(&exception_table_length, sizeof(U2), 1, fp);

	attributes_count = 0;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, attributes_count);
	}
	fwrite(&attributes_count, sizeof(U2), 1, fp);
}

void MakeOutputFileName(char *szInputFileName, char *szOutputFileName, char *szFileNameWithoutExt, char *szExt)
{
	int k;
	int dotIndex;
	int len = strlen(szInputFileName);

	strcpy(szOutputFileName, "");
	strcpy(szFileNameWithoutExt, "");
	strcpy(szExt, "");

	k = len - 1;

	while ( k >= 0 )
	{
		if ( szInputFileName[k] == '.' )
			break;
		--k;
	}
	k++;

	if ( k > 0 )
	{
		memcpy(szExt, szInputFileName + k, len - k);
		szExt[len - k] = '\0';

		k -= 2;
		dotIndex = k + 1;
	}
	else
	{
		dotIndex = len;
	}

	while ( k >= 0 )
	{
		if ( !isalnum(szInputFileName[k]) && szInputFileName[k] != '_' )
			break;
		--k;
	}
	k++;

	memcpy(szFileNameWithoutExt, szInputFileName + k, dotIndex - k);
	szFileNameWithoutExt[dotIndex - k] = '\0';

	strcpy(szOutputFileName, szFileNameWithoutExt);
	strcat(szOutputFileName, ".class");
}

void MakeBytecodeDeclArrayMain(jvmHashTable **pHT, HashTable *pDati)
{
	char szInt[128];
	char szClassName[128];
	int k;

	U2 constClassIndex;
	U1 constIntegerIndex;

	U1 bytecode;
	U1 paramU1;
	U2 paramU2;

	BYTE *buff;
	U1 fb[8]; /*Necessario per usare le macro;*/

	HashTable *t = pDati;


	for ( k = 0; k < t->Value.pArrayDef->countIndexes; k++ )
	{
		/* ************* INIZIO LOAD ****************** */

		if ( t->Value.pArrayDef->sizes[k] >= -128 && t->Value.pArrayDef->sizes[k] <= 127 )
		{
			if ( t->Value.pArrayDef->sizes[k] >= -1 && t->Value.pArrayDef->sizes[k] <= 5 )
			{
				if ( t->Value.pArrayDef->sizes[k] == 0 )
					bytecode = jvm_iconst_0;
				else if ( t->Value.pArrayDef->sizes[k] == 1 )
					bytecode = jvm_iconst_1;
				else if ( t->Value.pArrayDef->sizes[k] == 2 )
					bytecode = jvm_iconst_2;
				else if ( t->Value.pArrayDef->sizes[k] == 3 )
					bytecode = jvm_iconst_3;
				else if ( t->Value.pArrayDef->sizes[k] == 4 )
					bytecode = jvm_iconst_4;
				else if ( t->Value.pArrayDef->sizes[k] == 5 )
					bytecode = jvm_iconst_5;

				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_max_stack++;
				g_code_length++;
				g_IndexBytecodeArray++;
			}
			else
			{
				bytecode = jvm_bipush;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_max_stack++;
				g_code_length++;
				g_IndexBytecodeArray++;

				paramU1 = (U1)t->Value.pArrayDef->sizes[k];
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU1, 1);
				g_code_length++;
				g_IndexBytecodeArray++;
			}
		}
		else if ( t->Value.pArrayDef->sizes[k] >= -32768 && t->Value.pArrayDef->sizes[k] <= 32767 )
		{
			bytecode = jvm_sipush;
			memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
			g_max_stack++;
			g_code_length++;
			g_IndexBytecodeArray++;

			paramU2 = (U2)t->Value.pArrayDef->sizes[k];
			if ( !isBigEndian() )
			{
				ARRAY_TO_S2(buff, paramU2);
			}
			memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
			g_code_length += 2;
			g_IndexBytecodeArray += 2;
		}
		else
		{
			sprintf(szInt, "%d", t->Value.pArrayDef->sizes[k]);
			if ( !jvmhtFind(pHT, szInt, (unsigned short*)&constIntegerIndex) )
			{
				constIntegerIndex = (unsigned char)(g_ConstantPoolCount + 1);
				jvmhtInsert(pHT, szInt, constIntegerIndex);
				g_IndexConstantPool = jvmAddIntegerConstant(t->Value.pArrayDef->sizes[k], g_IndexConstantPool);
			}

			bytecode = jvm_ldc;
			memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
			g_max_stack++;
			g_code_length++;
			g_IndexBytecodeArray++;

			paramU1 = constIntegerIndex;
			memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU1, 1);
			g_code_length++;
			g_IndexBytecodeArray++;
		}
	}

	if ( t->Value.pArrayDef->countIndexes == 1 )
	{
		bytecode = jvm_newarray;

		switch ( t->Tipo1 )
		{
		case T_INTEGER:
			paramU1 = 10;
			break;
		case T_REAL:
			paramU1 = 7;
			break;
		case T_BOOLEAN:
			paramU1 = 4;
			break;
		case T_STRING:
			paramU1 = 8; /*byte*/
			break;
		}

		memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
		g_max_stack++;
		g_code_length++;
		g_IndexBytecodeArray++;

		memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU1, 1);
		g_code_length++;
		g_IndexBytecodeArray++;

		/* ************* FINE LOAD ******************* */
	}
	else /*Array Multidimensionale*/
	{
		bytecode = jvm_multianewarray;

		memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
		g_max_stack++;
		g_code_length++;
		g_IndexBytecodeArray++;

		strcpy(szClassName, "[");
		for ( k = 1; k < t->Value.pArrayDef->countIndexes; k++ )
		{
			strcat(szClassName, "[");
		}
		if ( t->Tipo1 == T_INTEGER )
			strcat(szClassName, "I");
		if ( t->Tipo1 == T_REAL )
			strcat(szClassName, "D");
		if ( t->Tipo1 == T_BOOLEAN )
			strcat(szClassName, "Z");
		if ( t->Tipo1 == T_STRING )
			strcat(szClassName, "Ljava/lang/String;");

		if ( !jvmhtFind(pHT, szClassName, (unsigned short*)&constClassIndex) )
		{
			constClassIndex = (unsigned short)(g_ConstantPoolCount + 1);
			jvmhtInsert(pHT, szClassName, constClassIndex);
			g_IndexConstantPool = jvmAddArrayClass(t->Tipo1, t->Value.pArrayDef->countIndexes, g_IndexConstantPool);
		}

		paramU2 = constClassIndex;
		if ( !isBigEndian() )
		{
			ARRAY_TO_U2(buff, paramU2);
		}
		memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
		g_code_length += 2;
		g_IndexBytecodeArray += 2;

		paramU1 = (U1)t->Value.pArrayDef->countIndexes;
		memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU1, 1);
		g_code_length++;
		g_IndexBytecodeArray++;

		/* ************* FINE LOAD ****************** */
	}


	/* ************* INIZIO STORE **************** */
	if (pDati->frameIndex >= 0 && pDati->frameIndex <= 3)
	{
		if ( (U1)pDati->frameIndex == 0 )
			bytecode = jvm_astore_0;
		else if ( (U1)pDati->frameIndex == 1 )
			bytecode = jvm_astore_1;
		else if ( (U1)pDati->frameIndex == 2 )
			bytecode = jvm_astore_2;
		else if ( (U1)pDati->frameIndex == 3 )
			bytecode = jvm_astore_3;
		memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
		g_max_stack--;
		g_code_length++;
		g_IndexBytecodeArray++;
	}
	else
	{
		bytecode = jvm_astore;
		memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
		g_max_stack--;
		g_code_length++;
		g_IndexBytecodeArray++;
		paramU1 = (U1)pDati->frameIndex;
		memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU1, 1);
		g_code_length++;
		g_IndexBytecodeArray++;
	}
	/* ************* FINE STORE *************** */
}

void MakeBytecodeDeclInitMain(jvmHashTable **pHT, Scope *pScope)
{
	int index;
	HashTable *t;
	HashTable **pHashTable;

	HashTable Dati;

	char szInt[128];
	char szReal[128];

	U1 constStringIndex;
	U1 constIntegerIndex;
	U2 constRealIndex;

	U1 bytecode;
	U1 paramU1;
	U2 paramU2;

	S1 paramS1;
	S2 paramS2;

	BYTE *buff;
	U1 fb[8]; /*Necessario per usare le macro;*/


	pHashTable = pScope->stack[0];

	for ( index = 0; index < HT_SIZE - 1; index++ )
	{
		t = pHashTable[index];
		while ( t != NULL )
		{
			scopeFind(pScope, t->Key, &Dati);

			if ( t->Tipo0 == T_SIMPLE && t->bInizializzato && t->bDecl )
			{
				/* ************* INIZIO LOAD ******************* */

				switch ( t->Tipo1 )
				{
				case T_INTEGER:
					if ( t->Value.iVal >= -128 && t->Value.iVal <= 127 )
					{
						if ( t->Value.iVal >= -1 && t->Value.iVal <= 5 )
						{
							if ( t->Value.iVal == -1 )
								bytecode = jvm_iconst_m1;
							else if ( t->Value.iVal == 0 )
								bytecode = jvm_iconst_0;
							else if ( t->Value.iVal == 1 )
								bytecode = jvm_iconst_1;
							else if ( t->Value.iVal == 2 )
								bytecode = jvm_iconst_2;
							else if ( t->Value.iVal == 3 )
								bytecode = jvm_iconst_3;
							else if ( t->Value.iVal == 4 )
								bytecode = jvm_iconst_4;
							else if ( t->Value.iVal == 5 )
								bytecode = jvm_iconst_5;

							memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
							g_max_stack++;
							g_code_length++;
							g_IndexBytecodeArray++;
						}
						else
						{
							bytecode = jvm_bipush;
							memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
							g_max_stack++;
							g_code_length++;
							g_IndexBytecodeArray++;

							paramS1 = (S1)t->Value.iVal;
							memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramS1, 1);
							g_code_length++;
							g_IndexBytecodeArray++;
						}
					}
					else if ( t->Value.iVal >= -32768 && t->Value.iVal <= 32767 )
					{
						bytecode = jvm_sipush;
						memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
						g_max_stack++;
						g_code_length++;
						g_IndexBytecodeArray++;

						paramS2 = (S2)t->Value.iVal;
						if ( !isBigEndian() )
						{
							ARRAY_TO_S2(buff, paramS2);
						}
						memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramS2, 2);
						g_code_length += 2;
						g_IndexBytecodeArray += 2;
					}
					else
					{
						sprintf(szInt, "%d", t->Value.iVal);
						if ( !jvmhtFind(pHT, szInt, (unsigned short*)&constIntegerIndex) )
						{
							constIntegerIndex = (unsigned char)(g_ConstantPoolCount + 1);
							jvmhtInsert(pHT, szInt, constIntegerIndex);
							g_IndexConstantPool = jvmAddIntegerConstant(t->Value.iVal, g_IndexConstantPool);
						}

						bytecode = jvm_ldc;
						memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
						g_max_stack++;
						g_code_length++;
						g_IndexBytecodeArray++;

						paramU1 = constIntegerIndex;
						memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU1, 1);
						g_code_length++;
						g_IndexBytecodeArray++;
					}

					break;
				case T_REAL:
					if ( t->Value.dblVal == 0.0 || t->Value.dblVal == 1.0 )
					{
						if ( t->Value.dblVal == 0.0 )
							bytecode = jvm_dconst_0;
						else if ( t->Value.dblVal == 1.0 )
							bytecode = jvm_dconst_1;

						memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
						g_max_stack += 2;
						g_code_length++;
						g_IndexBytecodeArray++;
					}
					else
					{
						sprintf(szReal, "%lf", t->Value.dblVal);
						if ( !jvmhtFind(pHT, szReal, &constRealIndex) )
						{
							constRealIndex = (unsigned short)(g_ConstantPoolCount + 1);
							jvmhtInsert(pHT, szReal, constRealIndex);
							g_IndexConstantPool = jvmAddRealConstant(t->Value.dblVal, g_IndexConstantPool);
						}

						bytecode = jvm_ldc2_w;
						memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
						g_max_stack += 2;
						g_code_length++;
						g_IndexBytecodeArray++;

						paramU2 = constRealIndex;
						if ( !isBigEndian() )
						{
							ARRAY_TO_U2(buff, paramU2);
						}
						memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
						g_code_length += 2;
						g_IndexBytecodeArray += 2;
					}

					break;
				case T_BOOLEAN:
					if ( t->Value.bVal == 0 )
					{
						bytecode = jvm_iconst_0;
					}
					else if ( t->Value.bVal == 1 )
					{
						bytecode = jvm_iconst_1;
					}

					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_max_stack++;
					g_code_length++;
					g_IndexBytecodeArray++;

					break;
				case T_STRING:
					if ( !jvmhtFind(pHT, t->Value.strVal, (unsigned short*)&constStringIndex) )
					{
						constStringIndex = (unsigned char)(g_ConstantPoolCount + 1);
						jvmhtInsert(pHT, t->Value.strVal, constStringIndex);
						g_IndexConstantPool = jvmAddStringConstant(t->Value.strVal, g_IndexConstantPool);
					}

					bytecode = jvm_ldc;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_max_stack++;
					g_code_length++;
					g_IndexBytecodeArray++;

					paramU1 = constStringIndex;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU1, 1);
					g_code_length++;
					g_IndexBytecodeArray++;

					break;
				}
				/* ************* FINE LOAD ******************* */


				/* ************* INIZIO STORE **************** */
				if (Dati.frameIndex >= 0 && Dati.frameIndex <= 3)
				{
					if ( (U1)Dati.frameIndex == 0 )
					{
						if ( Dati.Tipo1 == T_INTEGER || Dati.Tipo1 == T_BOOLEAN)
							bytecode = jvm_istore_0;
						else if ( Dati.Tipo1 == T_REAL )
							bytecode = jvm_dstore_0;
						else if ( Dati.Tipo1 == T_STRING )
							bytecode = jvm_astore_0;
					}
					else if ( (U1)Dati.frameIndex == 1 )
					{
						if ( Dati.Tipo1 == T_INTEGER || Dati.Tipo1 == T_BOOLEAN)
							bytecode = jvm_istore_1;
						else if ( Dati.Tipo1 == T_REAL )
							bytecode = jvm_dstore_1;
						else if ( Dati.Tipo1 == T_STRING )
							bytecode = jvm_astore_1;
					}
					else if ( (U1)Dati.frameIndex == 2 )
					{
						if ( Dati.Tipo1 == T_INTEGER || Dati.Tipo1 == T_BOOLEAN)
							bytecode = jvm_istore_2;
						else if ( Dati.Tipo1 == T_REAL )
							bytecode = jvm_dstore_2;
						else if ( Dati.Tipo1 == T_STRING )
							bytecode = jvm_astore_2;
					}
					else if ( (U1)Dati.frameIndex == 3 )
					{
						if ( Dati.Tipo1 == T_INTEGER || Dati.Tipo1 == T_BOOLEAN)
							bytecode = jvm_istore_3;
						else if ( Dati.Tipo1 == T_REAL )
							bytecode = jvm_dstore_3;
						else if ( Dati.Tipo1 == T_STRING )
							bytecode = jvm_astore_3;
					}

					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					if ( Dati.Tipo1 != T_REAL )
						g_max_stack--;
					else
						g_max_stack -= 2;
					g_code_length++;
					g_IndexBytecodeArray++;
				}
				else
				{
					if ( Dati.Tipo1 == T_INTEGER || Dati.Tipo1 == T_BOOLEAN)
						bytecode = jvm_istore;
					else if ( Dati.Tipo1 == T_REAL )
						bytecode = jvm_dstore;
					else if ( Dati.Tipo1 == T_STRING )
						bytecode = jvm_astore;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					if ( Dati.Tipo1 != T_REAL )
						g_max_stack--;
					else
						g_max_stack -= 2;
					g_code_length++;
					g_IndexBytecodeArray++;

					paramU1 = (U1)Dati.frameIndex;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU1, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
				}

				/* ************* FINE STORE ************** */
			}
			else if ( t->Tipo0 == T_ARRAY )
			{
				MakeBytecodeDeclArrayMain(pHT, &Dati);
			}

			t = t->next;
		}
	}
}

void LoadArray(nodeType *p, jvmHashTable **pHT, Scope *pScope)
{
	U1 bytecode;
	U1 paramU1;

	int k;

	if ( p->type0 == T_ARRAY )
	{
		HashTable Dati;
		scopeFind(pScope, p->id.name, &Dati);

		if ( Dati.frameIndex >= 0 && Dati.frameIndex <= 3 )
		{
			if ( (U1)Dati.frameIndex == 0 )
				bytecode = jvm_aload_0;
			else if ( (U1)Dati.frameIndex == 1 )
				bytecode = jvm_aload_1;
			else if ( (U1)Dati.frameIndex == 2 )
				bytecode = jvm_aload_2;
			else if ( (U1)Dati.frameIndex == 3 )
				bytecode = jvm_aload_3;
			memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
			g_max_stack++;
			g_code_length++;
			g_IndexBytecodeArray++;
		}
		else
		{
			bytecode = jvm_aload;
			memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
			g_max_stack++;
			g_code_length++;
			g_IndexBytecodeArray++;
			paramU1 = (U1)Dati.frameIndex;
			memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU1, 1);
			g_code_length++;
			g_IndexBytecodeArray++;
		}

		MakeBytecodeMain(p->id.value.pArrayDef->indexes[0], pHT, pScope);

		if ( p->id.value.pArrayDef->countIndexes > 1 )
		{
			for ( k = 1; k < p->id.value.pArrayDef->countIndexes; k++ )
			{
				bytecode = jvm_aaload;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_max_stack++;
				g_code_length++;
				g_IndexBytecodeArray++;

				if ( p->id.value.pArrayDef )
					MakeBytecodeMain(p->id.value.pArrayDef->indexes[k], pHT, pScope);
			}
		}
	}
}

void jvmTypeCheck(int t1, int t2)
{
	U1 bytecode;

	if ( t1 == t2 )
		return;

	switch ( t1 )
	{
	case T_INTEGER:
		if ( t2 == T_REAL )
			bytecode = jvm_d2i;
		break;
	case T_REAL:
		if ( t2 == T_INTEGER || t2 == T_BOOLEAN )
			bytecode = jvm_i2d;
		break;
	case T_BOOLEAN:
		if ( t2 == T_REAL )
			bytecode = jvm_d2i;
		break;
	}

	memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
	g_code_length++;
	g_IndexBytecodeArray++;
}

void MakeBytecodeMain(nodeType *p, jvmHashTable **pHT, Scope *pScope)
{
	U1 constStringIndex;
	U1 constIntegerIndex;
	U2 constRealIndex;

	U1 bytecode;
	U1 paramU1;
	U2 paramU2;

	S1 paramS1;
	S2 paramS2;

	U2 segnaposto1, segnaposto2;

	static int bLeftSide = 0;

	BYTE *buff;
	U1 fb[8]; /*Necessario per usare le macro;*/

    if (!p)
	{
		return;
	}

    switch(p->type)
	{
    case typeConst:
		{
			switch( p->type1 )
			{
			case T_INTEGER:
				if ( p->con.value.iVal >= -128 && p->con.value.iVal <= 127 )
				{
					if ( p->con.value.iVal >= -1 && p->con.value.iVal <= 5 )
					{
						if ( p->con.value.iVal == -1 )
							bytecode = jvm_iconst_m1;
						else if ( p->con.value.iVal == 0 )
							bytecode = jvm_iconst_0;
						else if ( p->con.value.iVal == 1 )
							bytecode = jvm_iconst_1;
						else if ( p->con.value.iVal == 2 )
							bytecode = jvm_iconst_2;
						else if ( p->con.value.iVal == 3 )
							bytecode = jvm_iconst_3;
						else if ( p->con.value.iVal == 4 )
							bytecode = jvm_iconst_4;
						else if ( p->con.value.iVal == 5 )
							bytecode = jvm_iconst_5;

						memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
						g_max_stack++;
						g_code_length++;
						g_IndexBytecodeArray++;
					}
					else
					{
						bytecode = jvm_bipush;
						memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
						g_max_stack++;
						g_code_length++;
						g_IndexBytecodeArray++;

						paramS1 = (S1)p->con.value.iVal;
						memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramS1, 1);
						g_code_length++;
						g_IndexBytecodeArray++;
					}
				}
				else if ( p->con.value.iVal >= -32768 && p->con.value.iVal <= 32767 )
				{
					bytecode = jvm_sipush;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_max_stack++;
					g_code_length++;
					g_IndexBytecodeArray++;

					paramS2 = (S2)p->con.value.iVal;
					if ( !isBigEndian() )
					{
						ARRAY_TO_S2(buff, paramS2);
					}
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramS2, 2);
					g_code_length += 2;
					g_IndexBytecodeArray += 2;
				}
				else
				{
					if ( !jvmhtFind(pHT, p->con.lexeme, (unsigned short*)&constIntegerIndex) )
					{
						constIntegerIndex = (unsigned char)(g_ConstantPoolCount + 1);
						jvmhtInsert(pHT, p->con.lexeme, constIntegerIndex);
						g_IndexConstantPool = jvmAddIntegerConstant(p->con.value.iVal, g_IndexConstantPool);
					}

					bytecode = jvm_ldc;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_max_stack++;
					g_code_length++;
					g_IndexBytecodeArray++;

					paramU1 = constIntegerIndex;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU1, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
				}

				break;
			case T_REAL:
				if ( p->con.value.dblVal == 0.0 || p->con.value.dblVal == 1.0 )
				{
					if ( p->con.value.dblVal == 0.0 )
						bytecode = jvm_dconst_0;
					else if ( p->con.value.dblVal == 1.0 )
						bytecode = jvm_dconst_1;

					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_max_stack += 2;
					g_code_length++;
					g_IndexBytecodeArray++;
				}
				else
				{
					if ( !jvmhtFind(pHT, p->con.lexeme, &constRealIndex) )
					{
						constRealIndex = (unsigned short)(g_ConstantPoolCount + 1);
						jvmhtInsert(pHT, p->con.lexeme, constRealIndex);
						g_IndexConstantPool = jvmAddRealConstant(p->con.value.dblVal, g_IndexConstantPool);
					}

					bytecode = jvm_ldc2_w;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_max_stack += 2;
					g_code_length++;
					g_IndexBytecodeArray++;

					paramU2 = constRealIndex;
					if ( !isBigEndian() )
					{
						ARRAY_TO_U2(buff, paramU2);
					}
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
					g_code_length += 2;
					g_IndexBytecodeArray += 2;
				}

				break;
			case T_BOOLEAN:
				if ( p->con.value.bVal == 0 )
					bytecode = jvm_iconst_0;
				else if ( p->con.value.bVal == 1 )
					bytecode = jvm_iconst_1;

				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_max_stack++;
				g_code_length++;
				g_IndexBytecodeArray++;

				break;
			case T_STRING:
				if ( !jvmhtFind(pHT, p->con.value.strVal, (unsigned short*)&constStringIndex) )
				{
					constStringIndex = (unsigned char)(g_ConstantPoolCount + 1);
					jvmhtInsert(pHT, p->con.value.strVal, constStringIndex);
					g_IndexConstantPool = jvmAddStringConstant(p->con.value.strVal, g_IndexConstantPool);
				}

				bytecode = jvm_ldc;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_max_stack++;
				g_code_length++;
				g_IndexBytecodeArray++;

				paramU1 = constStringIndex;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU1, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				break;
			}

			return;
		}
		break;
    case typeId:
		{
			HashTable Dati;
			if ( scopeFind(pScope, p->id.name, &Dati) )
			{
				if ( Dati.Tipo0 == T_ARRAY )
				{
					if ( bLeftSide )
					{
						if ( Dati.Tipo1 == T_INTEGER )
							bytecode = jvm_iastore;
						else if ( Dati.Tipo1 == T_REAL )
							bytecode = jvm_dastore;
						else if ( Dati.Tipo1 == T_BOOLEAN )
							bytecode = jvm_bastore;
						else if ( Dati.Tipo1 == T_STRING )
							bytecode = jvm_aastore;
					}
					else
					{
						if ( Dati.Tipo1 == T_INTEGER )
							bytecode = jvm_iaload;
						else if ( Dati.Tipo1 == T_REAL )
							bytecode = jvm_daload;
						else if ( Dati.Tipo1 == T_BOOLEAN )
							bytecode = jvm_baload;
						else if ( Dati.Tipo1 == T_STRING )
							bytecode = jvm_aaload;
					}
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					if ( bLeftSide )
					{
						if ( Dati.Tipo1 != T_REAL )
							g_max_stack--;
						else
							g_max_stack -= 2;
					}
					else
					{
						if ( Dati.Tipo1 != T_REAL )
							g_max_stack++;
						else
							g_max_stack += 2;
					}
					g_code_length++;
					g_IndexBytecodeArray++;
				}
				else /*Dati.Tipo0 == T_SIMPLE*/
				{
					if (Dati.frameIndex >= 0 && Dati.frameIndex <= 3)
					{
						if ( (U1)Dati.frameIndex == 0 )
						{
							if ( Dati.Tipo1 == T_INTEGER || Dati.Tipo1 == T_BOOLEAN)
							{
								if ( bLeftSide )
									bytecode = jvm_istore_0;
								else
									bytecode = jvm_iload_0;
							}
							else if ( Dati.Tipo1 == T_REAL )
							{
								if ( bLeftSide )
									bytecode = jvm_dstore_0;
								else
									bytecode = jvm_dload_0;
							}
							else if ( Dati.Tipo1 == T_STRING )
							{
								if ( bLeftSide )
									bytecode = jvm_astore_0;
								else
									bytecode = jvm_aload_0;
							}
						}
						else if ( (U1)Dati.frameIndex == 1 )
						{
							if ( Dati.Tipo1 == T_INTEGER || Dati.Tipo1 == T_BOOLEAN)
							{
								if ( bLeftSide )
									bytecode = jvm_istore_1;
								else
									bytecode = jvm_iload_1;
							}
							else if ( Dati.Tipo1 == T_REAL )
							{
								if ( bLeftSide )
									bytecode = jvm_dstore_1;
								else
									bytecode = jvm_dload_1;
							}
							else if ( Dati.Tipo1 == T_STRING )
							{
								if ( bLeftSide )
									bytecode = jvm_astore_1;
								else
									bytecode = jvm_aload_1;
							}
						}
						else if ( (U1)Dati.frameIndex == 2 )
						{
							if ( Dati.Tipo1 == T_INTEGER || Dati.Tipo1 == T_BOOLEAN)
							{
								if ( bLeftSide )
									bytecode = jvm_istore_2;
								else
									bytecode = jvm_iload_2;
							}
							else if ( Dati.Tipo1 == T_REAL )
							{
								if ( bLeftSide )
									bytecode = jvm_dstore_2;
								else
									bytecode = jvm_dload_2;
							}
							else if ( Dati.Tipo1 == T_STRING )
							{
								if ( bLeftSide )
									bytecode = jvm_astore_2;
								else
									bytecode = jvm_aload_2;
							}
						}
						else if ( (U1)Dati.frameIndex == 3 )
						{
							if ( Dati.Tipo1 == T_INTEGER || Dati.Tipo1 == T_BOOLEAN)
							{
								if ( bLeftSide )
									bytecode = jvm_istore_3;
								else
									bytecode = jvm_iload_3;
							}
							else if ( Dati.Tipo1 == T_REAL )
							{
								if ( bLeftSide )
									bytecode = jvm_dstore_3;
								else
									bytecode = jvm_dload_3;
							}
							else if ( Dati.Tipo1 == T_STRING )
							{
								if ( bLeftSide )
									bytecode = jvm_astore_3;
								else
									bytecode = jvm_aload_3;
							}
						}

						memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
						if ( bLeftSide )
						{
							if ( Dati.Tipo1 != T_REAL )
								g_max_stack--;
							else
								g_max_stack -= 2;
						}
						else
						{
							if ( Dati.Tipo1 != T_REAL )
								g_max_stack++;
							else
								g_max_stack += 2;
						}
						g_code_length++;
						g_IndexBytecodeArray++;
					}
					else
					{
						if ( Dati.Tipo1 == T_INTEGER || Dati.Tipo1 == T_BOOLEAN)
						{
							if ( bLeftSide )
								bytecode = jvm_istore;
							else
								bytecode = jvm_iload;
						}
						else if ( Dati.Tipo1 == T_REAL )
						{
							if ( bLeftSide )
								bytecode = jvm_dstore;
							else
								bytecode = jvm_dload;
						}
						else if ( Dati.Tipo1 == T_STRING )
						{
							if ( bLeftSide )
								bytecode = jvm_astore;
							else
								bytecode = jvm_aload;
						}
						memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
						if ( bLeftSide )
						{
							if ( Dati.Tipo1 != T_REAL )
								g_max_stack--;
							else
								g_max_stack -= 2;
						}
						else
						{
							if ( Dati.Tipo1 != T_REAL )
								g_max_stack++;
							else
								g_max_stack += 2;
						}
						g_code_length++;
						g_IndexBytecodeArray++;

						paramU1 = (U1)Dati.frameIndex;
						memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU1, 1);
						g_code_length++;
						g_IndexBytecodeArray++;
					}
				}
			}
			else
			{
				printf("Errore: X identificatore '%s' non dichiarato\n", p->id.name);
			}

			return;
		}
		break;
    case typeOperator:
		{
			switch(p->opr.oper)
			{
			case T_KW_WHILE:
				segnaposto1 = g_IndexBytecodeArray;
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);

				bytecode = jvm_iconst_0;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				bytecode = jvm_if_icmpeq;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;
				segnaposto2 = g_IndexBytecodeArray;

				paramU2 = 0;
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				MakeBytecodeMain(p->opr.op[1], pHT, pScope);

				bytecode = jvm_goto;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				paramU2 = segnaposto1 - g_IndexBytecodeArray + 1;
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				paramU2 = g_IndexBytecodeArray - segnaposto2 + 1;
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + segnaposto2, &paramU2, 2);

				return;
			case T_KW_DO: /*do-while*/
				segnaposto1 = g_IndexBytecodeArray;
				MakeBytecodeMain(p->opr.op[1], pHT, pScope);

				bytecode = jvm_iconst_0;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				bytecode = jvm_if_icmpeq;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;
				segnaposto2 = g_IndexBytecodeArray;

				paramU2 = 0;
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				MakeBytecodeMain(p->opr.op[0], pHT, pScope);

				bytecode = jvm_goto;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				paramU2 = segnaposto1 - g_IndexBytecodeArray + 1;
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				paramU2 = g_IndexBytecodeArray - segnaposto2 + 1;
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + segnaposto2, &paramU2, 2);

				return;
			case T_KW_IF:
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);

				if (p->opr.nops > 2)
				{
					/*if else*/
					bytecode = jvm_iconst_0;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;

					bytecode = jvm_if_icmpeq;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
					segnaposto2 = g_IndexBytecodeArray;

					paramU2 = 0;
					if ( !isBigEndian() )
					{
						ARRAY_TO_U2(buff, paramU2);
					}
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
					g_code_length += 2;
					g_IndexBytecodeArray += 2;

					MakeBytecodeMain(p->opr.op[1], pHT, pScope);

					bytecode = jvm_goto;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
					segnaposto1 = g_IndexBytecodeArray;

					paramU2 = 0;
					if ( !isBigEndian() )
					{
						ARRAY_TO_U2(buff, paramU2);
					}
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
					g_code_length += 2;
					g_IndexBytecodeArray += 2;

					paramU2 = g_IndexBytecodeArray - segnaposto2 + 1;
					if ( !isBigEndian() )
					{
						ARRAY_TO_U2(buff, paramU2);
					}
					memcpy(g_ArrayCode + segnaposto2, &paramU2, 2);

					MakeBytecodeMain(p->opr.op[2], pHT, pScope);

					paramU2 = g_IndexBytecodeArray - segnaposto1 + 1;
					if ( !isBigEndian() )
					{
						ARRAY_TO_U2(buff, paramU2);
					}
					memcpy(g_ArrayCode + segnaposto1, &paramU2, 2);
				}
				else
				{
					/*if*/
					bytecode = jvm_iconst_0;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;

					bytecode = jvm_if_icmpeq;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
					segnaposto2 = g_IndexBytecodeArray;

					paramU2 = 0;
					if ( !isBigEndian() )
					{
						ARRAY_TO_U2(buff, paramU2);
					}
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
					g_code_length += 2;
					g_IndexBytecodeArray += 2;

					MakeBytecodeMain(p->opr.op[1], pHT, pScope);

					paramU2 = g_IndexBytecodeArray - segnaposto2 + 1;
					if ( !isBigEndian() )
					{
						ARRAY_TO_U2(buff, paramU2);
					}
					memcpy(g_ArrayCode + segnaposto2, &paramU2, 2);
				}

				return;
			case T_KW_PRINT:
				bytecode = jvm_getstatic;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_max_stack++;
				g_code_length++;
				g_IndexBytecodeArray++;

				paramU2 = 9; /*Field java/lang/System.out:Ljava/io/PrintStream;*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				LoadArray(p->opr.op[0], pHT, pScope);

				MakeBytecodeMain(p->opr.op[0], pHT, pScope);

				bytecode = jvm_invokevirtual;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				if ( p->opr.op[0]->type1 == T_STRING )
					paramU2 = 14; /*java/io/PrintStream.print:(Ljava/lang/String;)V*/
				else if ( p->opr.op[0]->type1 == T_INTEGER )
					paramU2 = 60; /*java/io/PrintStream.print:(I)V*/
				else if ( p->opr.op[0]->type1 == T_REAL )
					paramU2 = 63; /*java/io/PrintStream.print:(D)V*/
				else if ( p->opr.op[0]->type1 == T_BOOLEAN )
					paramU2 = 66; /*java/io/PrintStream.print:(Z)V*/

				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				return;
			case T_KW_READ:
				bytecode = jvm_invokestatic;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_max_stack++;
				g_code_length++;
				g_IndexBytecodeArray++;

				paramU2 = 15; /*java/lang/System.console:()Ljava/io/Console;*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				bytecode = jvm_invokevirtual;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				paramU2 = 16; /*java/io/Console.readLine:()Ljava/lang/String;*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				if ( p->opr.op[0]->type1 != T_STRING )
				{
					bytecode = jvm_invokestatic;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;

					if ( p->opr.op[0]->type1 == T_INTEGER )
						paramU2 = 17; /*java/lang/Integer.parseInt:(Ljava/lang/String;)I*/
					else if ( p->opr.op[0]->type1 == T_REAL )
						paramU2 = 18; /*java/lang/Double.parseDouble:(Ljava/lang/String;)D*/
					if ( !isBigEndian() )
					{
						ARRAY_TO_U2(buff, paramU2);
					}
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
					g_code_length += 2;
					g_IndexBytecodeArray += 2;
				}

				LoadArray(p->opr.op[0], pHT, pScope);
				bLeftSide = 1;
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);
				bLeftSide = 0;

				return;
			case T_STMT_LIST:
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);
				MakeBytecodeMain(p->opr.op[1], pHT, pScope);
				return;
			case T_CODE_BLOCK:
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);
				return;
			case T_OP_ASSIGN:
				LoadArray(p->opr.op[0], pHT, pScope);
				LoadArray(p->opr.op[1], pHT, pScope);
				bLeftSide = 0;
				MakeBytecodeMain(p->opr.op[1], pHT, pScope);
				jvmTypeCheck(p->opr.op[0]->type1, p->opr.op[1]->type1);
				bLeftSide = 1;
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);
				bLeftSide = 0;
				return;
			case T_OP_UMINUS:
				LoadArray(p->opr.op[0], pHT, pScope);
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);

				if ( p->opr.op[0]->type1 == T_INTEGER )
					bytecode = jvm_ineg;
				else if ( p->opr.op[0]->type1 == T_REAL )
					bytecode = jvm_dneg;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				return;
			case T_OP_PLUS:
				if ( p->type1 != T_STRING )
				{
					LoadArray(p->opr.op[0], pHT, pScope);
					MakeBytecodeMain(p->opr.op[0], pHT, pScope);
					jvmTypeCheck(p->type1, p->opr.op[0]->type1);

					LoadArray(p->opr.op[1], pHT, pScope);
					MakeBytecodeMain(p->opr.op[1], pHT, pScope);
					jvmTypeCheck(p->type1, p->opr.op[1]->type1);

					if ( p->type1 == T_INTEGER )
						bytecode = jvm_iadd;
					else if ( p->type1 == T_REAL )
						bytecode = jvm_dadd;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
				}
				else /*Concatenazione di due stringhe*/
				{
					bytecode = jvm_new;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;

					paramU2 = 6; /*class java/lang/StringBuilder*/
					if ( !isBigEndian() )
					{
						ARRAY_TO_U2(buff, paramU2);
					}
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
					g_code_length += 2;
					g_IndexBytecodeArray += 2;

					bytecode = jvm_dup;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;

					bytecode = jvm_invokespecial;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;

					paramU2 = 11; /*java/lang/StringBuilder."<init>":()V*/
					if ( !isBigEndian() )
					{
						ARRAY_TO_U2(buff, paramU2);
					}
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
					g_code_length += 2;
					g_IndexBytecodeArray += 2;

					LoadArray(p->opr.op[0], pHT, pScope);
					MakeBytecodeMain(p->opr.op[0], pHT, pScope);

					bytecode = jvm_invokevirtual;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;

					paramU2 = 12; /*java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;*/
					if ( !isBigEndian() )
					{
						ARRAY_TO_U2(buff, paramU2);
					}
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
					g_code_length += 2;
					g_IndexBytecodeArray += 2;

					LoadArray(p->opr.op[1], pHT, pScope);
					MakeBytecodeMain(p->opr.op[1], pHT, pScope);

					bytecode = jvm_invokevirtual;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;

					paramU2 = 12; /*java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;*/
					if ( !isBigEndian() )
					{
						ARRAY_TO_U2(buff, paramU2);
					}
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
					g_code_length += 2;
					g_IndexBytecodeArray += 2;

					bytecode = jvm_invokevirtual;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;

					paramU2 = 13; /*java/lang/StringBuilder.toString:()Ljava/lang/String;*/
					if ( !isBigEndian() )
					{
						ARRAY_TO_U2(buff, paramU2);
					}
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
					g_code_length += 2;
					g_IndexBytecodeArray += 2;
				}

				return;
			case T_OP_MINUS:
				LoadArray(p->opr.op[0], pHT, pScope);
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[0]->type1);

				LoadArray(p->opr.op[1], pHT, pScope);
				MakeBytecodeMain(p->opr.op[1], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[1]->type1);

				if ( p->type1 == T_INTEGER )
					bytecode = jvm_isub;
				else if ( p->type1 == T_REAL )
					bytecode = jvm_dsub;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				return;
			case T_OP_MULT:
				LoadArray(p->opr.op[0], pHT, pScope);
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[0]->type1);

				LoadArray(p->opr.op[1], pHT, pScope);
				MakeBytecodeMain(p->opr.op[1], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[1]->type1);

				if ( p->type1 == T_INTEGER )
					bytecode = jvm_imul;
				else if ( p->type1 == T_REAL )
					bytecode = jvm_dmul;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				return;
			case T_OP_DIV:
				LoadArray(p->opr.op[0], pHT, pScope);
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[0]->type1);

				LoadArray(p->opr.op[1], pHT, pScope);
				MakeBytecodeMain(p->opr.op[1], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[1]->type1);

				if ( p->type1 == T_INTEGER )
					bytecode = jvm_idiv;
				else if ( p->type1 == T_REAL )
					bytecode = jvm_ddiv;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				return;
			case T_OP_LT:
				LoadArray(p->opr.op[0], pHT, pScope);
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[0]->type1);

				LoadArray(p->opr.op[1], pHT, pScope);
				MakeBytecodeMain(p->opr.op[1], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[1]->type1);

				if ( p->type1 == T_INTEGER )
				{
					bytecode = jvm_if_icmpge;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
				}
				else if ( p->type1 == T_REAL )
				{
					bytecode = jvm_dcmpg;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;

					bytecode = jvm_ifge;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
				}

				paramU2 = 7; /*= 6 + 1 ( + 1 perchè comprende il byte dell'istruzione if_icmpge o ifge )*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				bytecode = jvm_iconst_1;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				bytecode = jvm_goto;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				paramU2 = 4; /*= 3 + 1 ( + 1 perchè comprende il byte dell'istruzione goto )*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				bytecode = jvm_iconst_0;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				return;
			case T_OP_GT:
				LoadArray(p->opr.op[0], pHT, pScope);
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[0]->type1);

				LoadArray(p->opr.op[1], pHT, pScope);
				MakeBytecodeMain(p->opr.op[1], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[1]->type1);

				if ( p->type1 == T_INTEGER )
				{
					bytecode = jvm_if_icmple;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
				}
				else if ( p->type1 == T_REAL )
				{
					bytecode = jvm_dcmpl;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;

					bytecode = jvm_ifle;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
				}

				paramU2 = 7; /*= 6 + 1 ( + 1 perchè comprende il byte dell'istruzione if_icmpge o ifge )*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				bytecode = jvm_iconst_1;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				bytecode = jvm_goto;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				paramU2 = 4; /*= 3 + 1 ( + 1 perchè comprende il byte dell'istruzione goto )*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				bytecode = jvm_iconst_0;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				return;
			case T_OP_GE:
				LoadArray(p->opr.op[0], pHT, pScope);
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[0]->type1);

				LoadArray(p->opr.op[1], pHT, pScope);
				MakeBytecodeMain(p->opr.op[1], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[1]->type1);

				if ( p->type1 == T_INTEGER )
				{
					bytecode = jvm_if_icmplt;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
				}
				else if ( p->type1 == T_REAL )
				{
					bytecode = jvm_dcmpl;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;

					bytecode = jvm_iflt;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
				}

				paramU2 = 7; /*= 6 + 1 ( + 1 perchè comprende il byte dell'istruzione if_icmpge o ifge )*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				bytecode = jvm_iconst_1;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				bytecode = jvm_goto;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				paramU2 = 4; /*= 3 + 1 ( + 1 perchè comprende il byte dell'istruzione goto )*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				bytecode = jvm_iconst_0;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				return;
			case T_OP_LE:
				LoadArray(p->opr.op[0], pHT, pScope);
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[0]->type1);

				LoadArray(p->opr.op[1], pHT, pScope);
				MakeBytecodeMain(p->opr.op[1], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[1]->type1);

				if ( p->type1 == T_INTEGER )
				{
					bytecode = jvm_if_icmpgt;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
				}
				else if ( p->type1 == T_REAL )
				{
					bytecode = jvm_dcmpl;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;

					bytecode = jvm_ifgt;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
				}

				paramU2 = 7; /*= 6 + 1 ( + 1 perchè comprende il byte dell'istruzione if_icmpge o ifge )*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				bytecode = jvm_iconst_1;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				bytecode = jvm_goto;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				paramU2 = 4; /*= 3 + 1 ( + 1 perchè comprende il byte dell'istruzione goto )*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				bytecode = jvm_iconst_0;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				return;
			case T_OP_NE:
				LoadArray(p->opr.op[0], pHT, pScope);
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[0]->type1);

				LoadArray(p->opr.op[1], pHT, pScope);
				MakeBytecodeMain(p->opr.op[1], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[1]->type1);

				if ( p->type1 == T_INTEGER )
				{
					bytecode = jvm_if_icmpeq;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
				}
				else if ( p->type1 == T_REAL )
				{
					bytecode = jvm_dcmpl;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;

					bytecode = jvm_ifeq;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
				}

				paramU2 = 7; /*= 6 + 1 ( + 1 perchè comprende il byte dell'istruzione if_icmpge o ifge )*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				bytecode = jvm_iconst_1;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				bytecode = jvm_goto;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				paramU2 = 4; /*= 3 + 1 ( + 1 perchè comprende il byte dell'istruzione goto )*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				bytecode = jvm_iconst_0;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				return;
			case T_OP_EQ:
				LoadArray(p->opr.op[0], pHT, pScope);
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[0]->type1);

				LoadArray(p->opr.op[1], pHT, pScope);
				MakeBytecodeMain(p->opr.op[1], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[1]->type1);

				if ( p->type1 == T_INTEGER )
				{
					bytecode = jvm_if_icmpne;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
				}
				else if ( p->type1 == T_REAL )
				{
					bytecode = jvm_dcmpl;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;

					bytecode = jvm_ifne;
					memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
					g_code_length++;
					g_IndexBytecodeArray++;
				}

				paramU2 = 7; /*= 6 + 1 ( + 1 perchè comprende il byte dell'istruzione if_icmpge o ifge )*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				bytecode = jvm_iconst_1;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				bytecode = jvm_goto;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				paramU2 = 4; /*= 3 + 1 ( + 1 perchè comprende il byte dell'istruzione goto )*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				bytecode = jvm_iconst_0;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				return;
			case T_OP_AND:
				LoadArray(p->opr.op[0], pHT, pScope);
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[0]->type1);

				bytecode = jvm_ifeq;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;
				segnaposto1 = g_IndexBytecodeArray;

				paramU2 = 0;
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				LoadArray(p->opr.op[1], pHT, pScope);
				MakeBytecodeMain(p->opr.op[1], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[1]->type1);

				bytecode = jvm_ifeq;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;
				segnaposto2 = g_IndexBytecodeArray;

				paramU2 = 0;
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				bytecode = jvm_iconst_1;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				bytecode = jvm_goto;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				paramU2 = 4; /*= 3 + 1 ( + 1 perchè comprende il byte dell'istruzione goto )*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				paramU2 = g_IndexBytecodeArray - segnaposto1 + 1;
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + segnaposto1, &paramU2, 2);

				paramU2 = g_IndexBytecodeArray - segnaposto2 + 1;
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + segnaposto2, &paramU2, 2);

				bytecode = jvm_iconst_0;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				return;
			case T_OP_OR:
				LoadArray(p->opr.op[0], pHT, pScope);
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[0]->type1);

				bytecode = jvm_ifne;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;
				segnaposto1 = g_IndexBytecodeArray;

				paramU2 = 0;
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				LoadArray(p->opr.op[1], pHT, pScope);
				MakeBytecodeMain(p->opr.op[1], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[1]->type1);

				bytecode = jvm_ifeq;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;
				segnaposto2 = g_IndexBytecodeArray;

				paramU2 = 0;
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				paramU2 = g_IndexBytecodeArray - segnaposto1 + 1;
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + segnaposto1, &paramU2, 2);

				bytecode = jvm_iconst_1;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				bytecode = jvm_goto;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				paramU2 = 4; /*= 3 + 1 ( + 1 perchè comprende il byte dell'istruzione goto )*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				paramU2 = g_IndexBytecodeArray - segnaposto2 + 1;
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + segnaposto2, &paramU2, 2);

				bytecode = jvm_iconst_0;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				return;
			case T_OP_NOT:
				LoadArray(p->opr.op[0], pHT, pScope);
				MakeBytecodeMain(p->opr.op[0], pHT, pScope);
				jvmTypeCheck(p->type1, p->opr.op[0]->type1);

				bytecode = jvm_ifne;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				paramU2 = 7; /*= 6 + 1 ( + 1 perchè comprende il byte dell'istruzione if_icmpge o ifge )*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				bytecode = jvm_iconst_1;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				bytecode = jvm_goto;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				paramU2 = 4; /*= 3 + 1 ( + 1 perchè comprende il byte dell'istruzione goto )*/
				if ( !isBigEndian() )
				{
					ARRAY_TO_U2(buff, paramU2);
				}
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &paramU2, 2);
				g_code_length += 2;
				g_IndexBytecodeArray += 2;

				bytecode = jvm_iconst_0;
				memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
				g_code_length++;
				g_IndexBytecodeArray++;

				return;
			}
		}
		break;
    }
}

void jvmStart(char *szInputFileName, nodeType *pTree, Scope *pScope)
{
	FILE *fp;
	U2 constant_pool_count;
	U2 attributes_count = 0;
	U1 bytecode;

	char szOutputFileName[512];
	char szFileNameWithoutExt[512];
	char szExt[512];
	char szSourceFile[512];
	char szClassName[512];

	BYTE *buff;
	U1 fb[8]; /*Necessario per usare le macro;*/

	jvmHashTable **pHT;
	int x;

	MakeOutputFileName(szInputFileName, szOutputFileName, szFileNameWithoutExt, szExt);
	strcpy(szSourceFile, szFileNameWithoutExt);
	strcat(szSourceFile, ".");
	strcat(szSourceFile, szExt);

	strcpy(szClassName, szFileNameWithoutExt);

	fp = fopen(szOutputFileName, "wb");
	if ( !fp )
	{
		printf("Errore. Impossibile creare il file %s.\n", szOutputFileName);
		return;
	}


	pHT = (jvmHashTable**)malloc(sizeof(jvmHashTable*) * JVM_HT_SIZE);
	if ( pHT != NULL )
	{
		for ( x = 0; x < JVM_HT_SIZE; x++ )
		{
			pHT[x] = (jvmHashTable*)malloc(sizeof(jvmHashTable));
			if ( pHT[x] == NULL )
			{
				printf("Memoria non sufficiente.\n");
				return;
			}
			pHT[x] = NULL;
		}
	}
	else
	{
		printf("Memoria non sufficiente.\n");
		return;
	}

	jvmWriteHeader(fp);
	g_IndexConstantPool = jvmMakeConstantPool(szSourceFile, szClassName);

	MakeBytecodeDeclInitMain(pHT, pScope);
	MakeBytecodeMain(pTree, pHT, pScope);

	bytecode = jvm_return;
	memcpy(g_ArrayCode + g_IndexBytecodeArray, &bytecode, 1);
	g_code_length++;


	constant_pool_count = g_ConstantPoolCount + 1;
	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, constant_pool_count);
	}
	fwrite(&constant_pool_count, sizeof(U2), 1, fp);
	fwrite(g_ArrayConstantPool, g_IndexConstantPool, 1, fp);

	jvmWriteInfo(fp);
	jvmWriteInitMethod(fp);
	jvmWriteMainMethod(fp, pTree, pHT);

	if ( !isBigEndian() )
	{
		ARRAY_TO_U2(buff, attributes_count);
	}
	fwrite(&attributes_count, sizeof(U2), 1, fp);

	fclose(fp);

	for ( x = 0; x < JVM_HT_SIZE; x++)
		jvmhtFree(pHT[x]);
	free(pHT);
}
Vincenzo1968 è offline   Rispondi citando il messaggio o parte di esso
Old 23-02-2013, 10:07   #38
The_ouroboros
Senior Member
 
L'Avatar di The_ouroboros
 
Iscritto dal: May 2007
Città: Milano
Messaggi: 7103
Guardate cosa ho trovato....

Gcc Explorer

Un sito che da il disasm del codice C che gli passi e permette anche un minimo di parametri
__________________
Apple Watch Ultra + iPhone 15 Pro Max + Rog Ally + Legion Go
The_ouroboros è offline   Rispondi citando il messaggio o parte di esso
Old 23-02-2013, 10:18   #39
Vincenzo1968
Bannato
 
Iscritto dal: Mar 2008
Città: Villabate(PA)
Messaggi: 2515
Naturalmente nel contest 17 non s'è vista neanche l'ombra di python. Sempre tante belle chiacchiere: python questo, python quello, python è così, python è colà, python su, python giù, python a destra, python a sinistra, python sopra, python sotto... ma quando c'è da fare i fatti...

Non dico che non si potesse fare in python. Dico che i chiacchieroni, qui, non lo sanno fare.

Disiscritto dai. Disiscrivetevi anche voi. Disiscriviamoci tutti.
Vincenzo1968 è offline   Rispondi citando il messaggio o parte di esso
Old 23-02-2013, 10:40   #40
sottovento
Senior Member
 
L'Avatar di sottovento
 
Iscritto dal: Nov 2005
Città: Texas
Messaggi: 1722
Quote:
Originariamente inviato da Vincenzo1968 Guarda i messaggi
Naturalmente nel contest 17 non s'è vista neanche l'ombra di python. Sempre tante belle chiacchiere: python questo, python quello, python è così, python è colà, python su, python giù, python a destra, python a sinistra, python sopra, python sotto... ma quando c'è da fare i fatti...

Non dico che non si potesse fare in python. Dico che i chiacchieroni, qui, non lo sanno fare.

Disiscritto dai. Disiscrivetevi anche voi. Disiscriviamoci tutti.
Scusa se ti rispondo, anche se evidentemente il messaggio era rivolto a qualcun altro.
Vincenzo, sei una brava persona ed un ottimo tecnico, anzi di piu'! E ne hai dato una gran dimostrazione su questo forum.
E' per questo che non capisco questo "sfogo", che esula dai motivi tecnici.
Non conosco python, ho solo letto qualcosa per avere un'infarinatura di base e mi sembra un ottimo linguaggio. Di chiacchieroni ce ne sono tanti, ma certamente non puoi chiamare chiacchierone quella persona a cui fai riferimento, poiche' anche lui e' un gran tecnico. Avete punti di vista diversi, entrambi condivisibili. Avreste entrambi solo da guadagnare dalla vostra amicizia, e tutto da perdere a farvi la guerra.

my two cents
__________________
In God we trust; all others bring data
sottovento è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


iPhone 17 Pro: più di uno smartphone. È uno studio di produzione in formato tascabile iPhone 17 Pro: più di uno smartphone. &Eg...
Intel Panther Lake: i processori per i notebook del 2026 Intel Panther Lake: i processori per i notebook ...
Intel Xeon 6+: è tempo di Clearwater Forest Intel Xeon 6+: è tempo di Clearwater Fore...
4K a 160Hz o Full HD a 320Hz? Titan Army P2712V, a un prezzo molto basso 4K a 160Hz o Full HD a 320Hz? Titan Army P2712V,...
Recensione Google Pixel Watch 4: basta sollevarlo e si ha Gemini sempre al polso Recensione Google Pixel Watch 4: basta sollevarl...
Un solo iPhone rubato ha portato alla sc...
Xiaomi 17 Ultra sta arrivando: ecco come...
Il Motorola Edge 70 non ha più se...
Alcuni Galaxy S26 utilizzeranno il chip ...
Amazon, ecco i super sconti del weekend:...
Scovare un bug di sicurezza sui disposit...
Offerta Amazon su NordVPN: proteggi 10 d...
ECOVACS DEEBOT X8 PRO OMNI in offerta su...
Scope elettriche Tineco in offerta su Am...
Offerta Amazon sui robot EUREKA J15 Ultr...
Chrome disattiverà automaticament...
Tornano tutti e 4 i colori disponibili p...
Super sconto su iPhone 16: Amazon abbass...
Sconto pazzesco sulle Blink: videocamere...
Ring ancora in forte sconto, 35,99€ (-64...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 14:27.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Served by www3v