extensions
Steven Massey 5 years ago
parent 6391a179e1
commit b20d90aa3d

@ -48,7 +48,7 @@ m3ret_t PushArg_p##INDEX (d_m3BindingArgList, M3State * _state) \
i32 offset = (u32) * (_state->sp++); \
_i##INDEX = (i64) (_state->mem + offset); \
M3ArgPusher pusher = (* _state->pc++); \
printf ("push ptr: r%d off: %d\n", INDEX, offset);\
if (0) printf ("push ptr: r%d off: %d\n", INDEX, offset); \
return pusher (d_m3BindingArgs, _state); \
}

@ -1749,7 +1749,7 @@ _ (Compile_BlockStatements (& o));
u32 numConstants = o.constSlotIndex - o.firstConstSlotIndex;
io_function->numConstants = numConstants; m3log (compile, "unique constants: %d unused slots: %d", numConstants, o.firstSlotIndex - o.constSlotIndex);
io_function->numConstants = numConstants; m3log (compile, "unique constants: %d; unused slots: %d", numConstants, o.firstSlotIndex - o.constSlotIndex);
if (numConstants)
{

@ -12,8 +12,9 @@
#include "m3_exception.h"
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <unistd.h>
#include <sys/ioctl.h>
void m3_printf (cstr_t i_format, const void * i_varArgs)
{
@ -228,12 +229,17 @@ M3Result SuppressLookupFailure (M3Result i_result)
return i_result;
}
#include <sys/ioctl.h>
M3Result m3_LinkCStd (IM3Module io_module)
{
M3Result result = c_m3Err_none;
_ (SuppressLookupFailure (m3_LinkFunction (io_module, "_printf", "v(**)", (void *) m3_printf)));
_ (SuppressLookupFailure (m3_LinkFunction (io_module, "_malloc", "i(Mi)", (void *) m3_malloc)));
_ (SuppressLookupFailure (m3_LinkFunction (io_module, "_free", "v(Mi)", (void *) m3_free)));
_ (SuppressLookupFailure (m3_LinkFunction (io_module, "_memset", "*(*ii)", (void *) m3_memset)));
_ (SuppressLookupFailure (m3_LinkFunction (io_module, "_memcpy", "*(**i)", (void *) m3_memcpy)));
_ (SuppressLookupFailure (m3_LinkFunction (io_module, "_fopen", "i(M**)", (void *) m3_fopen)));
_ (SuppressLookupFailure (m3_LinkFunction (io_module, "_fread", "i(*ii*)", (void *) m3_fread)));

@ -70,18 +70,18 @@ int main (int i_argc, const char * i_argv [])
m3_LinkFunction (module, "_TestReturn", "F(i)", (void *) TestReturn);
m3_LinkFunction (module, "abortStackOverflow", "v(i)", (void *) m3_abort);
m3_LinkFunction (module, "_malloc", "i(Mi)", (void *) m3_malloc);
m3_LinkFunction (module, "_free", "v(Mi)", (void *) m3_free);
m3_LinkFunction (module, "_memset", "*(*ii)", (void *) m3_memset);
m3_LinkFunction (module, "_memcpy", "*(**i)", (void *) m3_memcpy);
result = m3_LinkCStd (module); if (result) throw result;
m3_PrintRuntimeInfo (env);
IM3Function f;
result = m3_FindFunction (& f, env, "__post_instantiate"); if (result) throw result;
result = m3_Call (f); if (result) throw result;
result = m3_FindFunction (& f, env, "__post_instantiate"); //if (result) throw result;
if (not result)
{
result = m3_Call (f); if (result) throw result;
}
IM3Function main;
result = m3_FindFunction (& main, env, "_main"); if (result) throw result;

Loading…
Cancel
Save