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,37 +2,37 @@ Embryo 0.0.1
|
|||
|
||||
WARNING: gcc compatibility!!!
|
||||
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
|
||||
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
|
||||
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
|
||||
interpredted programs compiled into the abstract machine bytecode that it
|
||||
understands. This abstrac (or virtual) machine is imilar to a real machine
|
||||
with a CPU, but it is emulated in software. The architecture is simple and is
|
||||
interpreted programs compiled into an abstract machine bytecode that it
|
||||
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
|
||||
the same as the abstract machine (AMX) in the
|
||||
<a href=http://www.compuphase.com/small.htm>SMALL</a> language as it is based
|
||||
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.
|
||||
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 includes the floating point library support by default as well. This makes
|
||||
it one of the smallest interpreters around, and thus makes is very
|
||||
efficient to use in code.
|
||||
|
||||
Embryo also uses the SMALL compiler from the same codebase. This code has
|
||||
barely been touched and so sufferes from lots of portability issues. It has
|
||||
Embryo also uses the SMALL compiler from the same code base. This code 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
|
||||
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
|
||||
binary outputs. it does not support packed strings, variable alignment, or
|
||||
debugging output. it does not support many features of the full SMALL
|
||||
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
|
||||
binary outputs. It does not support packed strings, variable alignment, or
|
||||
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
|
||||
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
|
||||
is known to work on:
|
||||
gcc Linux (x86-32)
|
||||
|
@ -40,9 +40,9 @@ is known to work on:
|
|||
gcc MacOS X (PPC)
|
||||
|
||||
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
|
||||
endian, alignment forgiving/unforgiving). ASo far 64bit support is the major
|
||||
endian, alignment forgiving/unforgiving). So far 64bit support is the major
|
||||
issue.
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
ones provided by the calling appllication to the Embryo API. This mjeans a
|
||||
any API it exports to the SMALL script. SMALL programs/scripts are completely
|
||||
sand-boxed. They cannot access any system or function calls other than the
|
||||
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
|
||||
harmless and this also keeps Embryo small.
|
||||
|
||||
|
|
|
@ -14,9 +14,43 @@ public global2 = 77;
|
|||
|
||||
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)
|
||||
|
|
|
@ -620,7 +620,7 @@ embryo_data_string_set(Embryo_Program *ep, char *src, Embryo_Cell *str_cell)
|
|||
for (i = 0; src[i] != 0; i++)
|
||||
{
|
||||
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;
|
||||
return;
|
||||
|
@ -1509,10 +1509,10 @@ embryo_program_run(Embryo_Program *ep, Embryo_Function fn)
|
|||
ep->hea = hea;
|
||||
ep->frm = frm;
|
||||
ep->stk = stk;
|
||||
pri = ((Embryo_Native)offs)(ep, (Embryo_Cell *)(data + (int)stk));
|
||||
if (ep->error != EMBRYO_ERROR_NONE)
|
||||
num = _embryo_native_call(ep, offs, &pri, (Embryo_Cell *)(data + (int)stk));
|
||||
if (num != EMBRYO_ERROR_NONE)
|
||||
{
|
||||
if (ep->error == EMBRYO_ERROR_SLEEP)
|
||||
if (num == EMBRYO_ERROR_SLEEP)
|
||||
{
|
||||
ep->pri = pri;
|
||||
ep->alt = alt;
|
||||
|
@ -1529,13 +1529,20 @@ embryo_program_run(Embryo_Program *ep, Embryo_Function fn)
|
|||
break;
|
||||
case EMBRYO_OP_SWITCH:
|
||||
{
|
||||
Embryo_Cell *cptr;
|
||||
|
||||
cptr = (Embryo_Cell *)*cip + 1; /* +1, to skip the "casetbl" opcode */
|
||||
cip = (Embryo_Cell *)*(cptr + 1); /* preset to "none-matched" case */
|
||||
num = (int)*cptr; /* number of records in the case table */
|
||||
for (cptr += 2; (num > 0) && (*cptr != pri); num--, cptr += 2);
|
||||
if (num > 0) cip = (Embryo_Cell *)*(cptr + 1); /* case found */
|
||||
Embryo_Cell *cptr, *tbl;
|
||||
|
||||
/* +1, to skip the "casetbl" opcode */
|
||||
cptr = (Embryo_Cell *)(code + (*cip)) + 1;
|
||||
/* number of records in the case table */
|
||||
num = (int)(*cptr);
|
||||
/* 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;
|
||||
case EMBRYO_OP_SWAP_PRI:
|
||||
|
|
Loading…
Reference in New Issue