#include <stdio.h>
#include <string.h>
-#ifdef HAVE_EVIL
-# include <Evil.h>
+#ifdef HAVE_EXOTIC
+# include <Exotic.h>
#endif
#include "Embryo.h"
static void _embryo_byte_swap_16 (unsigned short *v);
static void _embryo_byte_swap_32 (unsigned int *v);
#endif
-static int _embryo_native_call (Embryo_Program *ep, Embryo_Cell index, Embryo_Cell *result, Embryo_Cell *params);
-static int _embryo_func_get (Embryo_Program *ep, int index, char *funcname);
-static int _embryo_var_get (Embryo_Program *ep, int index, char *varname, Embryo_Cell *ep_addr);
+static int _embryo_native_call (Embryo_Program *ep, Embryo_Cell idx, Embryo_Cell *result, Embryo_Cell *params);
+static int _embryo_func_get (Embryo_Program *ep, int idx, char *funcname);
+static int _embryo_var_get (Embryo_Program *ep, int idx, char *varname, Embryo_Cell *ep_addr);
static int _embryo_program_init (Embryo_Program *ep, void *code);
#ifdef WORDS_BIGENDIAN
#endif
static int
-_embryo_native_call(Embryo_Program *ep, Embryo_Cell index, Embryo_Cell *result, Embryo_Cell *params)
+_embryo_native_call(Embryo_Program *ep, Embryo_Cell idx, Embryo_Cell *result, Embryo_Cell *params)
{
Embryo_Header *hdr;
Embryo_Func_Stub *func_entry;
Embryo_Native f;
hdr = (Embryo_Header *)ep->base;
- func_entry = GETENTRY(hdr, natives, index);
+ func_entry = GETENTRY(hdr, natives, idx);
if ((func_entry->address <= 0) ||
(func_entry->address > ep->native_calls_size))
{
}
static int
-_embryo_func_get(Embryo_Program *ep, int index, char *funcname)
+_embryo_func_get(Embryo_Program *ep, int idx, char *funcname)
{
Embryo_Header *hdr;
Embryo_Func_Stub *func;
hdr = (Embryo_Header *)ep->code;
- if (index >= (Embryo_Cell)NUMENTRIES(hdr, publics, natives))
+ if (idx >= (Embryo_Cell)NUMENTRIES(hdr, publics, natives))
return EMBRYO_ERROR_INDEX;
- func = GETENTRY(hdr, publics, index);
+ func = GETENTRY(hdr, publics, idx);
strcpy(funcname, GETENTRYNAME(hdr, func));
return EMBRYO_ERROR_NONE;
}
static int
-_embryo_var_get(Embryo_Program *ep, int index, char *varname, Embryo_Cell *ep_addr)
+_embryo_var_get(Embryo_Program *ep, int idx, char *varname, Embryo_Cell *ep_addr)
{
Embryo_Header *hdr;
Embryo_Func_Stub *var;
hdr=(Embryo_Header *)ep->base;
- if (index >= (Embryo_Cell)NUMENTRIES(hdr, pubvars, tags))
+ if (idx >= (Embryo_Cell)NUMENTRIES(hdr, pubvars, tags))
return EMBRYO_ERROR_INDEX;
- var = GETENTRY(hdr, pubvars, index);
+ var = GETENTRY(hdr, pubvars, idx);
strcpy(varname, GETENTRYNAME(hdr, var));
*ep_addr = var->address;
return EMBRYO_ERROR_NONE;
#endif
ep->flags = EMBRYO_FLAG_RELOC;
+#ifdef WORDS_BIGENDIAN
+/* until we do more... this is only used for bigendian */
{
Embryo_Cell cip, code_size, cip_end;
Embryo_Cell *code;
#ifdef WORDS_BIGENDIAN
embryo_swap_32(&(code[cip]));
#endif
-
}
}
+#endif
+
/* init native api for handling floating point - default in embryo */
_embryo_args_init(ep);
_embryo_fp_init(ep);
if (!f) return NULL;
fseek(f, 0, SEEK_END);
program_size = ftell(f);
- rewind(f);
+ fseek(f, 0L, SEEK_SET);
if (program_size < (int)sizeof(Embryo_Header))
{
fclose(f);
fclose(f);
return NULL;
}
- rewind(f);
+ fseek(f, 0L, SEEK_SET);
#ifdef WORDS_BIGENDIAN
embryo_swap_32((unsigned int *)(&hdr.size));
#endif
return;
}
hdr = (Embryo_Header *)ep->code;
- ep->base = malloc(hdr->stp);
+ ep->base = calloc(1, hdr->stp);
if (!ep->base)
{
ep->pushes = 0;