forked from enlightenment/efl
1. test.sma will become a comprehensive test now... starting anyway
2. fixed OP_SWITCH handling - man it was so broken! SVN revision: 10239
This commit is contained in:
parent
b1d6bc1b60
commit
d27f9301a0
|
@ -2,18 +2,18 @@ Embryo 0.0.1
|
||||||
|
|
||||||
WARNING: gcc compatibility!!!
|
WARNING: gcc compatibility!!!
|
||||||
There seems to be some bug (or disagreement) between embryo and gcc 3.2.x
|
There seems to be some bug (or disagreement) between embryo and gcc 3.2.x
|
||||||
where ieee floating point format encoding does not "agree" with embryo's own
|
where IEEE floating point format encoding does not "agree" with embryo's own
|
||||||
hand-made tests. embryo_cc may not work if you compile using gcc 3.2.x. gcc
|
hand-made tests. embryo_cc may not work if you compile using gcc 3.2.x. gcc
|
||||||
3.3.x is known to work fine. we are not 100% sure whose fault this is yet, so
|
3.3.x is known to work fine. we are not 100% sure whose fault this is yet, so
|
||||||
we won't be jumping up and down, but be warned - gcc 3.2.x does not agree
|
we won't be jumping up and down, but be warned - gcc 3.2.x does not agree
|
||||||
with embryo.
|
with embryo.
|
||||||
|
|
||||||
|
|
||||||
OK a lot of peolpe ask this. What is Embryo?
|
OK a lot of people ask this. What is Embryo?
|
||||||
|
|
||||||
Embryo is primarily a shared library that gives you an API to load and control
|
Embryo is primarily a shared library that gives you an API to load and control
|
||||||
interpredted programs compiled into the abstract machine bytecode that it
|
interpreted programs compiled into an abstract machine bytecode that it
|
||||||
understands. This abstrac (or virtual) machine is imilar to a real machine
|
understands. This abstract (or virtual) machine is similar to a real machine
|
||||||
with a CPU, but it is emulated in software. The architecture is simple and is
|
with a CPU, but it is emulated in software. The architecture is simple and is
|
||||||
the same as the abstract machine (AMX) in the
|
the same as the abstract machine (AMX) in the
|
||||||
<a href=http://www.compuphase.com/small.htm>SMALL</a> language as it is based
|
<a href=http://www.compuphase.com/small.htm>SMALL</a> language as it is based
|
||||||
|
@ -21,18 +21,18 @@ on exactly the same code. Embryo has modified the code for the AMX extensively
|
||||||
and has made it smaller and more portable. It is VERY small. The total size
|
and has made it smaller and more portable. It is VERY small. The total size
|
||||||
of the virtual machine code AND header files is less than 2500 lines of code.
|
of the virtual machine code AND header files is less than 2500 lines of code.
|
||||||
It includes the floating point library support by default as well. This makes
|
It includes the floating point library support by default as well. This makes
|
||||||
it one of the smallest interpreting engines around, and thus makes is very
|
it one of the smallest interpreters around, and thus makes is very
|
||||||
efficient to use in code.
|
efficient to use in code.
|
||||||
|
|
||||||
Embryo also uses the SMALL compiler from the same codebase. This code has
|
Embryo also uses the SMALL compiler from the same code base. This code has
|
||||||
barely been touched and so sufferes from lots of portability issues. It has
|
barely been touched and so suffers from lots of portability issues. It has
|
||||||
been partially fixed and now works on both big and little endian but the code
|
been partially fixed and now works on both big and little endian but the code
|
||||||
still need to be gone over and really cleaned up. It does work, but it's only
|
still need to be gone over and really cleaned up . It does work, but it's only
|
||||||
just working. It has been called embryo_cc and compiled a subset of SMALL
|
just working. It has been called embryo_cc and compiled a subset of SMALL
|
||||||
binary outputs. it does not support packed strings, variable alignment, or
|
binary outputs. It does not support packed strings, variable alignment, or
|
||||||
debugging output. it does not support many features of the full SMALL
|
debugging output. It does not support many features of the full SMALL
|
||||||
compiler because the Embryo AMX does not support these either. You will find
|
compiler because the Embryo AMX does not support these either. You will find
|
||||||
the Embryo codebase to work muich better on Linux (and BSD and MacOS X) and
|
the Embryo codebase to work much better on Linux (and BSD and MacOS X) and
|
||||||
other UNIX operating systems as it has been developed and tested on them. IT
|
other UNIX operating systems as it has been developed and tested on them. IT
|
||||||
is known to work on:
|
is known to work on:
|
||||||
gcc Linux (x86-32)
|
gcc Linux (x86-32)
|
||||||
|
@ -40,9 +40,9 @@ is known to work on:
|
||||||
gcc MacOS X (PPC)
|
gcc MacOS X (PPC)
|
||||||
|
|
||||||
And will likely work on more combinations. IT currently has problems on 64bit
|
And will likely work on more combinations. IT currently has problems on 64bit
|
||||||
SPARC cpu's. Other 64bit systems are untested. It is the aim to fix the code
|
SPARC CPUs. Other 64bit systems are untested. It is the aim to fix the code
|
||||||
so it works on all commonly used architectures (32, 64bit, big and little
|
so it works on all commonly used architectures (32, 64bit, big and little
|
||||||
endian, alignment forgiving/unforgiving). ASo far 64bit support is the major
|
endian, alignment forgiving/unforgiving). So far 64bit support is the major
|
||||||
issue.
|
issue.
|
||||||
|
|
||||||
For more documentation please see the Language guide here:
|
For more documentation please see the Language guide here:
|
||||||
|
@ -55,11 +55,11 @@ syntax of files it can compile (.sma files).
|
||||||
Any help is appreciated in helping clean and port this code, so feel free to
|
Any help is appreciated in helping clean and port this code, so feel free to
|
||||||
send patches to the Enlightenment development lists.
|
send patches to the Enlightenment development lists.
|
||||||
|
|
||||||
The main aim of Embryo is to provide an easy to usse library for running
|
The main aim of Embryo is to provide an easy to use library for running
|
||||||
compiled SMALL programs and giving them access to the calling program and
|
compiled SMALL programs and giving them access to the calling program and
|
||||||
any API it exports to the SMALL script. SMALL programs/scripts are completely
|
any API it exports to the SMALL script. SMALL programs/scripts are completely
|
||||||
sandboxed. They cannot access any system or function calls other than the
|
sand-boxed. They cannot access any system or function calls other than the
|
||||||
ones provided by the calling appllication to the Embryo API. This mjeans a
|
ones provided by the calling application to the Embryo API. This means a
|
||||||
SMALL script cannot open or write to, delete or load files. It is fairly
|
SMALL script cannot open or write to, delete or load files. It is fairly
|
||||||
harmless and this also keeps Embryo small.
|
harmless and this also keeps Embryo small.
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,43 @@ public global2 = 77;
|
||||||
|
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
testfn(12345, "Panties!!!!", 7);
|
printf("Testing switch and case statements...\n");
|
||||||
|
|
||||||
return 77;
|
new var = 4;
|
||||||
|
|
||||||
|
switch (var) {
|
||||||
|
case 0:
|
||||||
|
printf("It's 0\n");
|
||||||
|
case 1:
|
||||||
|
printf("It's 1\n");
|
||||||
|
case 2:
|
||||||
|
printf("It's 2\n");
|
||||||
|
case 3:
|
||||||
|
printf("It's 3\n");
|
||||||
|
case 4:
|
||||||
|
printf("It's 4\n");
|
||||||
|
case 5:
|
||||||
|
printf("It's 5\n");
|
||||||
|
case 6:
|
||||||
|
printf("It's 6\n");
|
||||||
|
case 7:
|
||||||
|
printf("It's 7\n");
|
||||||
|
default:
|
||||||
|
printf("It's something else\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
printf("\n\n");
|
||||||
|
printf("The printf() call is a native exported function. This should work\n");
|
||||||
|
printf("Calling testfn()...\n");
|
||||||
|
|
||||||
|
new ret;
|
||||||
|
ret = testfn(12345, "A Test String", 7);
|
||||||
|
printf("Done. Return value of testfn() was %i\n", ret);
|
||||||
|
|
||||||
|
printf("\n\n");
|
||||||
|
|
||||||
|
return 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
tester(arg1=0, str[]="", arg2=0)
|
tester(arg1=0, str[]="", arg2=0)
|
||||||
|
|
|
@ -620,7 +620,7 @@ embryo_data_string_set(Embryo_Program *ep, char *src, Embryo_Cell *str_cell)
|
||||||
for (i = 0; src[i] != 0; i++)
|
for (i = 0; src[i] != 0; i++)
|
||||||
{
|
{
|
||||||
if ((void *)(&(str_cell[i])) >= (void *)(ep->base + hdr->stp)) return;
|
if ((void *)(&(str_cell[i])) >= (void *)(ep->base + hdr->stp)) return;
|
||||||
else if ((void *)(&(str_cell[i]) == (void *)(ep->base + hdr->stp - 1)))
|
else if ((void *)(&(str_cell[i])) == (void *)(ep->base + hdr->stp - 1))
|
||||||
{
|
{
|
||||||
str_cell[i] = 0;
|
str_cell[i] = 0;
|
||||||
return;
|
return;
|
||||||
|
@ -1509,10 +1509,10 @@ embryo_program_run(Embryo_Program *ep, Embryo_Function fn)
|
||||||
ep->hea = hea;
|
ep->hea = hea;
|
||||||
ep->frm = frm;
|
ep->frm = frm;
|
||||||
ep->stk = stk;
|
ep->stk = stk;
|
||||||
pri = ((Embryo_Native)offs)(ep, (Embryo_Cell *)(data + (int)stk));
|
num = _embryo_native_call(ep, offs, &pri, (Embryo_Cell *)(data + (int)stk));
|
||||||
if (ep->error != EMBRYO_ERROR_NONE)
|
if (num != EMBRYO_ERROR_NONE)
|
||||||
{
|
{
|
||||||
if (ep->error == EMBRYO_ERROR_SLEEP)
|
if (num == EMBRYO_ERROR_SLEEP)
|
||||||
{
|
{
|
||||||
ep->pri = pri;
|
ep->pri = pri;
|
||||||
ep->alt = alt;
|
ep->alt = alt;
|
||||||
|
@ -1529,13 +1529,20 @@ embryo_program_run(Embryo_Program *ep, Embryo_Function fn)
|
||||||
break;
|
break;
|
||||||
case EMBRYO_OP_SWITCH:
|
case EMBRYO_OP_SWITCH:
|
||||||
{
|
{
|
||||||
Embryo_Cell *cptr;
|
Embryo_Cell *cptr, *tbl;
|
||||||
|
|
||||||
cptr = (Embryo_Cell *)*cip + 1; /* +1, to skip the "casetbl" opcode */
|
/* +1, to skip the "casetbl" opcode */
|
||||||
cip = (Embryo_Cell *)*(cptr + 1); /* preset to "none-matched" case */
|
cptr = (Embryo_Cell *)(code + (*cip)) + 1;
|
||||||
num = (int)*cptr; /* number of records in the case table */
|
/* number of records in the case table */
|
||||||
for (cptr += 2; (num > 0) && (*cptr != pri); num--, cptr += 2);
|
num = (int)(*cptr);
|
||||||
if (num > 0) cip = (Embryo_Cell *)*(cptr + 1); /* case found */
|
/* preset to "none-matched" case */
|
||||||
|
cip = (Embryo_Cell *)(code + *(cptr + 1));
|
||||||
|
for (cptr += 2;
|
||||||
|
(num > 0) && (*cptr != pri);
|
||||||
|
num--, cptr += 2);
|
||||||
|
/* case found */
|
||||||
|
if (num > 0)
|
||||||
|
cip = (Embryo_Cell *)(code + *(cptr + 1));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EMBRYO_OP_SWAP_PRI:
|
case EMBRYO_OP_SWAP_PRI:
|
||||||
|
|
Loading…
Reference in New Issue