Fixed bug, when hash code of function was sign and it did not took a place in hash table properly
This commit is contained in:
parent
9177bdcc2c
commit
2ff331b755
2 changed files with 30 additions and 29 deletions
|
@ -11,7 +11,7 @@ struct
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
short id_start;
|
unsigned short id_start;
|
||||||
int count_code;
|
int count_code;
|
||||||
}ByteCodeH_Common;
|
}ByteCodeH_Common;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ struct
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
short id;
|
unsigned short id;
|
||||||
int count_locals;
|
int count_locals;
|
||||||
int count_args;
|
int count_args;
|
||||||
}ByteCodeH_Primary;
|
}ByteCodeH_Primary;
|
||||||
|
|
|
@ -34,7 +34,8 @@ int run_interpreter(char* filename)
|
||||||
//ExecutionProcess Variables
|
//ExecutionProcess Variables
|
||||||
double d1, d2;
|
double d1, d2;
|
||||||
long long i1, i2;
|
long long i1, i2;
|
||||||
short s1, s2;
|
unsigned short s1;
|
||||||
|
short s2;
|
||||||
char *code;
|
char *code;
|
||||||
int ip, startfunc;
|
int ip, startfunc;
|
||||||
|
|
||||||
|
@ -374,31 +375,31 @@ int run_interpreter(char* filename)
|
||||||
break;
|
break;
|
||||||
case LOADDVAR:
|
case LOADDVAR:
|
||||||
//DO(LOADDVAR, "Load double from variable, whose 2-byte is id inlined to insn stream, push on TOS.", 3)
|
//DO(LOADDVAR, "Load double from variable, whose 2-byte is id inlined to insn stream, push on TOS.", 3)
|
||||||
s1 = *((short*)(code+ip));
|
s1 = *((unsigned short*)(code+ip));
|
||||||
d1 = getlocal_double(current_context, s1);
|
d1 = getlocal_double(current_context, s1);
|
||||||
push_double(d1);
|
push_double(d1);
|
||||||
ip+=2; break;
|
ip+=2; break;
|
||||||
case LOADIVAR:
|
case LOADIVAR:
|
||||||
//DO(LOADIVAR, "Load int from variable, whose 2-byte id is inlined to insn stream, push on TOS.", 3)
|
//DO(LOADIVAR, "Load int from variable, whose 2-byte id is inlined to insn stream, push on TOS.", 3)
|
||||||
s1 = *((short*)(code+ip));
|
s1 = *((unsigned short*)(code+ip));
|
||||||
i1 = getlocal_int(current_context, s1);
|
i1 = getlocal_int(current_context, s1);
|
||||||
push_int(i1);
|
push_int(i1);
|
||||||
ip+=2; break;
|
ip+=2; break;
|
||||||
case LOADSVAR:
|
case LOADSVAR:
|
||||||
//DO(LOADSVAR, "Load string from variable, whose 2-byte id is inlined to insn stream, push on TOS.", 3)
|
//DO(LOADSVAR, "Load string from variable, whose 2-byte id is inlined to insn stream, push on TOS.", 3)
|
||||||
s1 = *((short*)(code+ip));
|
s1 = *((unsigned short*)(code+ip));
|
||||||
i1 = (long long)getlocal_string(current_context, s1);
|
i1 = (long long)getlocal_string(current_context, s1);
|
||||||
push_int(i1);
|
push_int(i1);
|
||||||
ip+=2; break;
|
ip+=2; break;
|
||||||
case STOREDVAR:
|
case STOREDVAR:
|
||||||
//DO(STOREDVAR, "Pop TOS and store to double variable, whose 2-byte id is inlined to insn stream.", 3)
|
//DO(STOREDVAR, "Pop TOS and store to double variable, whose 2-byte id is inlined to insn stream.", 3)
|
||||||
s1 = *((short*)(code+ip));
|
s1 = *((unsigned short*)(code+ip));
|
||||||
d1 = pop_double();
|
d1 = pop_double();
|
||||||
putlocal_double(&d1, current_context, s1);
|
putlocal_double(&d1, current_context, s1);
|
||||||
ip+=2; break;
|
ip+=2; break;
|
||||||
case STOREIVAR:
|
case STOREIVAR:
|
||||||
//DO(STOREIVAR, "Pop TOS and store to int variable, whose 2-byte id is inlined to insn stream.", 3)
|
//DO(STOREIVAR, "Pop TOS and store to int variable, whose 2-byte id is inlined to insn stream.", 3)
|
||||||
s1 = *((short*)(code+ip));
|
s1 = *((unsigned short*)(code+ip));
|
||||||
i1 = pop_int();
|
i1 = pop_int();
|
||||||
putlocal_int(&i1, current_context, s1);
|
putlocal_int(&i1, current_context, s1);
|
||||||
ip+=2; break;
|
ip+=2; break;
|
||||||
|
@ -410,7 +411,7 @@ int run_interpreter(char* filename)
|
||||||
ip+=2; break;
|
ip+=2; break;
|
||||||
case LOADCTXDVAR:
|
case LOADCTXDVAR:
|
||||||
//DO(LOADCTXDVAR, "Load double from variable, whose 2-byte context and 2-byte id inlined to insn stream, push on TOS.", 5)
|
//DO(LOADCTXDVAR, "Load double from variable, whose 2-byte context and 2-byte id inlined to insn stream, push on TOS.", 5)
|
||||||
s1 = *((short*)(code+ip));
|
s1 = *((unsigned short*)(code+ip));
|
||||||
ip+=2;
|
ip+=2;
|
||||||
s2 = *((short*)(code+ip));
|
s2 = *((short*)(code+ip));
|
||||||
if (find_context(s1) != NULL)
|
if (find_context(s1) != NULL)
|
||||||
|
@ -426,7 +427,7 @@ int run_interpreter(char* filename)
|
||||||
ip+=2; break;
|
ip+=2; break;
|
||||||
case LOADCTXIVAR:
|
case LOADCTXIVAR:
|
||||||
//DO(LOADCTXIVAR, "Load int from variable, whose 2-byte context and 2-byte id is inlined to insn stream, push on TOS.", 5)
|
//DO(LOADCTXIVAR, "Load int from variable, whose 2-byte context and 2-byte id is inlined to insn stream, push on TOS.", 5)
|
||||||
s1 = *((short*)(code+ip));
|
s1 = *((unsigned short*)(code+ip));
|
||||||
ip+=2;
|
ip+=2;
|
||||||
s2 = *((short*)(code+ip));
|
s2 = *((short*)(code+ip));
|
||||||
if (find_context(s1) != NULL)
|
if (find_context(s1) != NULL)
|
||||||
|
@ -442,7 +443,7 @@ int run_interpreter(char* filename)
|
||||||
ip+=2; break;
|
ip+=2; break;
|
||||||
case LOADCTXSVAR:
|
case LOADCTXSVAR:
|
||||||
//DO(LOADCTXSVAR, "Load string from variable, whose 2-byte context and 2-byte id is inlined to insn stream, push on TOS.", 5)
|
//DO(LOADCTXSVAR, "Load string from variable, whose 2-byte context and 2-byte id is inlined to insn stream, push on TOS.", 5)
|
||||||
s1 = *((short*)(code+ip));
|
s1 = *((unsigned short*)(code+ip));
|
||||||
ip+=2;
|
ip+=2;
|
||||||
s2 = *((short*)(code+ip));
|
s2 = *((short*)(code+ip));
|
||||||
if (find_context(s1) != NULL)
|
if (find_context(s1) != NULL)
|
||||||
|
@ -458,7 +459,7 @@ int run_interpreter(char* filename)
|
||||||
ip+=2; break;
|
ip+=2; break;
|
||||||
case STORECTXDVAR:
|
case STORECTXDVAR:
|
||||||
//DO(STORECTXDVAR, "Pop TOS and store to double variable, whose 2-byte context and 2-byte id is inlined to insn stream.", 5)
|
//DO(STORECTXDVAR, "Pop TOS and store to double variable, whose 2-byte context and 2-byte id is inlined to insn stream.", 5)
|
||||||
s1 = *((short*)(code+ip));
|
s1 = *((unsigned short*)(code+ip));
|
||||||
ip+=2;
|
ip+=2;
|
||||||
s2 = *((short*)(code+ip));
|
s2 = *((short*)(code+ip));
|
||||||
d1 = pop_double();
|
d1 = pop_double();
|
||||||
|
@ -474,7 +475,7 @@ int run_interpreter(char* filename)
|
||||||
ip+=2; break;
|
ip+=2; break;
|
||||||
case STORECTXIVAR:
|
case STORECTXIVAR:
|
||||||
//DO(STORECTXIVAR, "Pop TOS and store to int variable, whose 2-byte context and 2-byte id is inlined to insn stream.", 5)
|
//DO(STORECTXIVAR, "Pop TOS and store to int variable, whose 2-byte context and 2-byte id is inlined to insn stream.", 5)
|
||||||
s1 = *((short*)(code+ip));
|
s1 = *((unsigned short*)(code+ip));
|
||||||
ip+=2;
|
ip+=2;
|
||||||
s2 = *((short*)(code+ip));
|
s2 = *((short*)(code+ip));
|
||||||
i1 = pop_int();
|
i1 = pop_int();
|
||||||
|
@ -490,7 +491,7 @@ int run_interpreter(char* filename)
|
||||||
ip+=2; break;
|
ip+=2; break;
|
||||||
case STORECTXSVAR:
|
case STORECTXSVAR:
|
||||||
//DO(STORECTXSVAR, "Pop TOS and store to string variable, whose 2-byte context and 2-byte id is inlined to insn stream.", 5)
|
//DO(STORECTXSVAR, "Pop TOS and store to string variable, whose 2-byte context and 2-byte id is inlined to insn stream.", 5)
|
||||||
s1 = *((short*)(code+ip));
|
s1 = *((unsigned short*)(code+ip));
|
||||||
ip+=2;
|
ip+=2;
|
||||||
s2 = *((short*)(code+ip));
|
s2 = *((short*)(code+ip));
|
||||||
i1 = pop_int();
|
i1 = pop_int();
|
||||||
|
@ -518,61 +519,61 @@ int run_interpreter(char* filename)
|
||||||
break;
|
break;
|
||||||
case JA:
|
case JA:
|
||||||
//DO(JA, "Jump always, next two bytes - signed offset of jump destination.", 3)
|
//DO(JA, "Jump always, next two bytes - signed offset of jump destination.", 3)
|
||||||
s1 = *((short*)(code+ip));
|
s2 = *((short*)(code+ip));
|
||||||
ip += (2+s1); break;
|
ip += (2+s2); break;
|
||||||
case IFICMPNE:
|
case IFICMPNE:
|
||||||
// DO(IFICMPNE, "Compare two topmost integers and jump if upper != lower, next two bytes - signed offset of jump destination.", 3)
|
// DO(IFICMPNE, "Compare two topmost integers and jump if upper != lower, next two bytes - signed offset of jump destination.", 3)
|
||||||
s1 = *((short*)(code+ip));
|
s2 = *((short*)(code+ip));
|
||||||
ip+=2;
|
ip+=2;
|
||||||
i1 = get_int(tp-1);
|
i1 = get_int(tp-1);
|
||||||
i2 = get_int(tp-2);
|
i2 = get_int(tp-2);
|
||||||
if (i1 != i2)
|
if (i1 != i2)
|
||||||
ip += s1;
|
ip += s2;
|
||||||
break;
|
break;
|
||||||
case IFICMPE:
|
case IFICMPE:
|
||||||
//DO(IFICMPE, "Compare two topmost integers and jump if upper == lower, next two bytes - signed offset of jump destination.", 3)
|
//DO(IFICMPE, "Compare two topmost integers and jump if upper == lower, next two bytes - signed offset of jump destination.", 3)
|
||||||
s1 = *((short*)(code+ip));
|
s2 = *((short*)(code+ip));
|
||||||
ip+=2;
|
ip+=2;
|
||||||
i1 = get_int(tp-1);
|
i1 = get_int(tp-1);
|
||||||
i2 = get_int(tp-2);
|
i2 = get_int(tp-2);
|
||||||
if (i1 == i2)
|
if (i1 == i2)
|
||||||
ip += s1;
|
ip += s2;
|
||||||
break;
|
break;
|
||||||
case IFICMPG:
|
case IFICMPG:
|
||||||
//DO(IFICMPG, "Compare two topmost integers and jump if upper > lower, next two bytes - signed offset of jump destination.", 3)
|
//DO(IFICMPG, "Compare two topmost integers and jump if upper > lower, next two bytes - signed offset of jump destination.", 3)
|
||||||
s1 = *((short*)(code+ip));
|
s2 = *((short*)(code+ip));
|
||||||
ip+=2;
|
ip+=2;
|
||||||
i1 = get_int(tp-1);
|
i1 = get_int(tp-1);
|
||||||
i2 = get_int(tp-2);
|
i2 = get_int(tp-2);
|
||||||
if (i1 > i2)
|
if (i1 > i2)
|
||||||
ip += s1;
|
ip += s2;
|
||||||
break;
|
break;
|
||||||
case IFICMPGE:
|
case IFICMPGE:
|
||||||
//DO(IFICMPGE, "Compare two topmost integers and jump if upper >= lower, next two bytes - signed offset of jump destination.", 3)
|
//DO(IFICMPGE, "Compare two topmost integers and jump if upper >= lower, next two bytes - signed offset of jump destination.", 3)
|
||||||
s1 = *((short*)(code+ip));
|
s2 = *((short*)(code+ip));
|
||||||
ip+=2;
|
ip+=2;
|
||||||
i1 = get_int(tp-1);
|
i1 = get_int(tp-1);
|
||||||
i2 = get_int(tp-2);
|
i2 = get_int(tp-2);
|
||||||
if (i1 >= i2)
|
if (i1 >= i2)
|
||||||
ip += s1;
|
ip += s2;
|
||||||
break;
|
break;
|
||||||
case IFICMPL:
|
case IFICMPL:
|
||||||
//DO(IFICMPL, "Compare two topmost integers and jump if upper < lower, next two bytes - signed offset of jump destination.", 3)
|
//DO(IFICMPL, "Compare two topmost integers and jump if upper < lower, next two bytes - signed offset of jump destination.", 3)
|
||||||
s1 = *((short*)(code+ip));
|
s2 = *((short*)(code+ip));
|
||||||
ip+=2;
|
ip+=2;
|
||||||
i1 = get_int(tp-1);
|
i1 = get_int(tp-1);
|
||||||
i2 = get_int(tp-2);
|
i2 = get_int(tp-2);
|
||||||
if (i1 < i2)
|
if (i1 < i2)
|
||||||
ip += s1;
|
ip += s2;
|
||||||
break;
|
break;
|
||||||
case IFICMPLE:
|
case IFICMPLE:
|
||||||
//DO(IFICMPLE, "Compare two topmost integers and jump if upper <= lower, next two bytes - signed offset of jump destination.", 3)
|
//DO(IFICMPLE, "Compare two topmost integers and jump if upper <= lower, next two bytes - signed offset of jump destination.", 3)
|
||||||
s1 = *((short*)(code+ip));
|
s2 = *((short*)(code+ip));
|
||||||
ip+=2;
|
ip+=2;
|
||||||
i1 = get_int(tp-1);
|
i1 = get_int(tp-1);
|
||||||
i2 = get_int(tp-2);
|
i2 = get_int(tp-2);
|
||||||
if (i1 <= i2)
|
if (i1 <= i2)
|
||||||
ip += s1;
|
ip += s2;
|
||||||
break;
|
break;
|
||||||
case DUMP:
|
case DUMP:
|
||||||
//DO(DUMP, "Dump value on TOS, without removing it.", 1)
|
//DO(DUMP, "Dump value on TOS, without removing it.", 1)
|
||||||
|
@ -586,7 +587,7 @@ int run_interpreter(char* filename)
|
||||||
break;
|
break;
|
||||||
case CALL:
|
case CALL:
|
||||||
//DO(CALL, "Call function, next two bytes - unsigned function id.", 3)
|
//DO(CALL, "Call function, next two bytes - unsigned function id.", 3)
|
||||||
s1 = *((short*)(code+ip));
|
s1 = *((unsigned short*)(code+ip));
|
||||||
ip+=2; push_ret(ip);
|
ip+=2; push_ret(ip);
|
||||||
push_context(current_context);
|
push_context(current_context);
|
||||||
current_context = create_context(s1, phash_table, &code);
|
current_context = create_context(s1, phash_table, &code);
|
||||||
|
|
Loading…
Reference in a new issue