2015-05-08 14:29:35 +00:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
2019-11-19 09:40:26 +00:00
|
|
|
Copyright (c) 2014-2019 Chung, Hyung-Hwan. All rights reserved.
|
2015-05-08 14:29:35 +00:00
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
|
|
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2018-11-11 16:53:21 +00:00
|
|
|
#include <moo-std.h>
|
|
|
|
#include <moo-utl.h>
|
|
|
|
#include <moo-opt.h>
|
2015-05-07 15:58:04 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2018-11-11 16:53:21 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <locale.h>
|
2017-02-22 09:48:58 +00:00
|
|
|
|
2018-12-04 03:34:54 +00:00
|
|
|
#if (defined(__unix) || defined(__linux) || defined(__ultrix) || defined(_AIX) || defined(__hpux) || defined(__sgi)) && defined(HAVE_SIGNAL_H)
|
|
|
|
# include <signal.h>
|
|
|
|
#endif
|
|
|
|
|
2018-11-26 09:49:03 +00:00
|
|
|
static void print_syntax_error (moo_t* moo, const char* main_src_file)
|
2018-11-15 08:40:22 +00:00
|
|
|
{
|
2018-11-26 09:49:03 +00:00
|
|
|
moo_synerr_t synerr;
|
2018-11-15 08:40:22 +00:00
|
|
|
|
2018-11-26 09:49:03 +00:00
|
|
|
moo_getsynerr (moo, &synerr);
|
2016-05-27 15:01:54 +00:00
|
|
|
|
2018-11-26 09:49:03 +00:00
|
|
|
moo_logbfmt (moo, MOO_LOG_STDERR, "ERROR: ");
|
|
|
|
if (synerr.loc.file)
|
2018-05-18 16:41:45 +00:00
|
|
|
{
|
2018-11-26 09:49:03 +00:00
|
|
|
moo_logbfmt (moo, MOO_LOG_STDERR, "%js", synerr.loc.file);
|
2018-05-18 16:41:45 +00:00
|
|
|
}
|
2018-11-26 09:49:03 +00:00
|
|
|
else
|
2018-05-18 16:41:45 +00:00
|
|
|
{
|
2018-11-26 09:49:03 +00:00
|
|
|
moo_logbfmt (moo, MOO_LOG_STDERR, "%s", main_src_file);
|
2018-05-18 16:41:45 +00:00
|
|
|
}
|
|
|
|
|
2018-11-26 09:49:03 +00:00
|
|
|
moo_logbfmt (moo, MOO_LOG_STDERR, "[%zu,%zu] %js",
|
|
|
|
synerr.loc.line, synerr.loc.colm,
|
|
|
|
(moo_geterrmsg(moo) != moo_geterrstr(moo)? moo_geterrmsg(moo): moo_geterrstr(moo))
|
|
|
|
);
|
2018-05-18 16:41:45 +00:00
|
|
|
|
2018-11-26 09:49:03 +00:00
|
|
|
if (synerr.tgt.len > 0)
|
|
|
|
{
|
|
|
|
moo_logbfmt (moo, MOO_LOG_STDERR, " - %.*js", synerr.tgt.len, synerr.tgt.ptr);
|
|
|
|
}
|
2018-05-18 16:41:45 +00:00
|
|
|
|
2018-11-26 09:49:03 +00:00
|
|
|
moo_logbfmt (moo, MOO_LOG_STDERR, "\n");
|
2017-02-14 14:00:14 +00:00
|
|
|
}
|
|
|
|
|
2016-05-27 15:01:54 +00:00
|
|
|
/* ========================================================================= */
|
|
|
|
|
2019-10-22 14:25:52 +00:00
|
|
|
#define MIN_HEAPSIZE 2048000ul
|
2017-12-16 16:14:23 +00:00
|
|
|
|
2015-05-07 15:58:04 +00:00
|
|
|
int main (int argc, char* argv[])
|
|
|
|
{
|
2017-02-10 09:06:53 +00:00
|
|
|
static moo_ooch_t str_my_object[] = { 'M', 'y', 'O', 'b','j','e','c','t' }; /*TODO: make this an argument */
|
|
|
|
static moo_ooch_t str_main[] = { 'm', 'a', 'i', 'n' };
|
|
|
|
|
2017-01-09 09:54:49 +00:00
|
|
|
moo_t* moo;
|
2018-11-13 09:53:48 +00:00
|
|
|
moo_cfgstd_t cfg;
|
2018-11-11 16:53:21 +00:00
|
|
|
moo_errinf_t errinf;
|
|
|
|
|
2017-01-09 09:54:49 +00:00
|
|
|
moo_oocs_t objname;
|
|
|
|
moo_oocs_t mthname;
|
2019-10-22 14:25:52 +00:00
|
|
|
moo_oow_t heapsize;
|
2016-05-17 15:12:27 +00:00
|
|
|
int i, xret;
|
2015-05-16 07:31:16 +00:00
|
|
|
|
2017-11-22 04:52:45 +00:00
|
|
|
moo_bci_t c;
|
2017-12-03 17:08:04 +00:00
|
|
|
static moo_bopt_lng_t lopt[] =
|
|
|
|
{
|
2019-05-18 18:01:02 +00:00
|
|
|
{ ":log", 'l' },
|
2019-10-22 14:25:52 +00:00
|
|
|
{ ":heapsize", '\0' },
|
2020-11-25 14:48:26 +00:00
|
|
|
{ ":gctype", '\0' },
|
2019-10-16 09:04:09 +00:00
|
|
|
{ ":procstksize", '\0' },
|
2019-05-18 18:01:02 +00:00
|
|
|
{ "large-pages", '\0' },
|
|
|
|
{ ":base-charset", '\0' },
|
|
|
|
{ ":input-charset", '\0' },
|
|
|
|
{ ":log-charset", '\0' },
|
2018-11-11 16:53:21 +00:00
|
|
|
#if defined(MOO_BUILD_DEBUG)
|
2019-08-07 05:33:35 +00:00
|
|
|
{ ":debug", '\0' }, /* [NOTE] there is no short option for --debug */
|
2018-11-11 16:53:21 +00:00
|
|
|
#endif
|
2019-05-18 18:01:02 +00:00
|
|
|
{ MOO_NULL, '\0' }
|
2017-12-03 17:08:04 +00:00
|
|
|
};
|
2017-11-22 04:52:45 +00:00
|
|
|
static moo_bopt_t opt =
|
|
|
|
{
|
2017-12-16 16:14:23 +00:00
|
|
|
"l:m:",
|
2017-12-03 17:08:04 +00:00
|
|
|
lopt
|
2017-11-22 04:52:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
|
2015-05-28 16:51:37 +00:00
|
|
|
#if !defined(macintosh)
|
2015-06-11 12:09:10 +00:00
|
|
|
if (argc < 2)
|
2015-05-16 07:31:16 +00:00
|
|
|
{
|
2017-11-22 04:52:45 +00:00
|
|
|
print_usage:
|
2018-10-10 04:23:44 +00:00
|
|
|
fprintf (stderr, "Usage: %s [options] filename ...\n", argv[0]);
|
|
|
|
fprintf (stderr, " --log filename[,logopts]\n");
|
2019-10-22 14:25:52 +00:00
|
|
|
fprintf (stderr, " --heapsize=bytes\n");
|
2020-11-25 14:48:26 +00:00
|
|
|
fprintf (stderr, " --gctype=ms|ss\n");
|
2019-10-16 09:04:09 +00:00
|
|
|
fprintf (stderr, " --procstksize=number of oops\n");
|
2018-11-14 08:47:50 +00:00
|
|
|
fprintf (stderr, " --large-pages\n");
|
2019-05-18 18:01:02 +00:00
|
|
|
fprintf (stderr, " --base-charset=name\n");
|
|
|
|
fprintf (stderr, " --input-charset=name\n");
|
|
|
|
fprintf (stderr, " --log-charset=name\n");
|
2020-11-25 14:48:26 +00:00
|
|
|
|
2018-10-10 04:23:44 +00:00
|
|
|
#if defined(MOO_BUILD_DEBUG)
|
|
|
|
fprintf (stderr, " --debug dbgopts\n");
|
|
|
|
#endif
|
2015-05-16 07:31:16 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-11-11 16:53:21 +00:00
|
|
|
memset (&cfg, 0, MOO_SIZEOF(cfg));
|
2018-11-13 09:53:48 +00:00
|
|
|
cfg.type = MOO_CFGSTD_OPTB;
|
2018-11-14 07:59:39 +00:00
|
|
|
cfg.cmgr = moo_get_utf8_cmgr();
|
2019-05-18 18:01:02 +00:00
|
|
|
cfg.input_cmgr = cfg.cmgr;
|
|
|
|
cfg.log_cmgr = cfg.cmgr;
|
2018-11-11 16:53:21 +00:00
|
|
|
|
2019-10-22 14:25:52 +00:00
|
|
|
heapsize = MIN_HEAPSIZE;
|
2018-11-30 10:33:17 +00:00
|
|
|
|
2018-11-11 16:53:21 +00:00
|
|
|
while ((c = moo_getbopt(argc, argv, &opt)) != MOO_BCI_EOF)
|
2017-11-22 04:52:45 +00:00
|
|
|
{
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case 'l':
|
2018-11-13 09:53:48 +00:00
|
|
|
cfg.u.optb.log = opt.arg;
|
2017-11-22 04:52:45 +00:00
|
|
|
break;
|
|
|
|
|
2017-12-16 16:14:23 +00:00
|
|
|
case '\0':
|
2019-10-22 14:25:52 +00:00
|
|
|
if (moo_comp_bcstr(opt.lngopt, "heapsize") == 0)
|
|
|
|
{
|
|
|
|
heapsize = strtoul(opt.arg, MOO_NULL, 0);
|
|
|
|
break;
|
|
|
|
}
|
2020-11-25 14:48:26 +00:00
|
|
|
else if (moo_comp_bcstr(opt.lngopt, "gctype") == 0)
|
|
|
|
{
|
|
|
|
if (moo_comp_bcstr(opt.arg, "ms") == 0)
|
|
|
|
cfg.gc_type = MOO_GC_TYPE_MARK_SWEEP;
|
|
|
|
else
|
|
|
|
cfg.gc_type = MOO_GC_TYPE_SEMISPACE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (moo_comp_bcstr(opt.lngopt, "procstksize") == 0)
|
2019-10-16 09:04:09 +00:00
|
|
|
{
|
|
|
|
cfg.proc_stk_size = strtoul(opt.arg, MOO_NULL, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (moo_comp_bcstr(opt.lngopt, "large-pages") == 0)
|
2018-03-07 08:09:06 +00:00
|
|
|
{
|
2018-11-11 16:53:21 +00:00
|
|
|
cfg.large_pages = 1;
|
2018-03-07 08:09:06 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-05-18 18:01:02 +00:00
|
|
|
else if (moo_comp_bcstr(opt.lngopt, "base-charset") == 0)
|
2018-11-14 08:47:50 +00:00
|
|
|
{
|
2019-05-18 18:01:02 +00:00
|
|
|
cfg.cmgr = moo_get_cmgr_by_bcstr(opt.arg);
|
|
|
|
if (!cfg.cmgr)
|
|
|
|
{
|
|
|
|
fprintf (stderr, "unknown base-charset name - %s\n", opt.arg);
|
|
|
|
return -1;
|
|
|
|
}
|
2018-11-14 08:47:50 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-05-18 18:01:02 +00:00
|
|
|
else if (moo_comp_bcstr(opt.lngopt, "input-charset") == 0)
|
2018-11-14 08:47:50 +00:00
|
|
|
{
|
2019-05-18 18:01:02 +00:00
|
|
|
cfg.input_cmgr = moo_get_cmgr_by_bcstr(opt.arg);
|
|
|
|
if (!cfg.input_cmgr)
|
|
|
|
{
|
|
|
|
fprintf (stderr, "unknown input-charset name - %s\n", opt.arg);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (moo_comp_bcstr(opt.lngopt, "log-charset") == 0)
|
|
|
|
{
|
|
|
|
cfg.log_cmgr = moo_get_cmgr_by_bcstr(opt.arg);
|
|
|
|
if (!cfg.log_cmgr)
|
|
|
|
{
|
|
|
|
fprintf (stderr, "unknown log-charset name - %s\n", opt.arg);
|
|
|
|
return -1;
|
|
|
|
}
|
2018-11-14 08:47:50 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-02-21 09:35:59 +00:00
|
|
|
#if defined(MOO_BUILD_DEBUG)
|
2018-04-07 15:54:09 +00:00
|
|
|
else if (moo_comp_bcstr(opt.lngopt, "debug") == 0)
|
2017-12-16 16:14:23 +00:00
|
|
|
{
|
2018-11-13 09:53:48 +00:00
|
|
|
cfg.u.optb.dbg = opt.arg;
|
2017-12-16 16:14:23 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-12-16 16:27:27 +00:00
|
|
|
#endif
|
2017-12-16 16:14:23 +00:00
|
|
|
goto print_usage;
|
|
|
|
|
2017-11-22 04:52:45 +00:00
|
|
|
case ':':
|
|
|
|
if (opt.lngopt)
|
|
|
|
fprintf (stderr, "bad argument for '%s'\n", opt.lngopt);
|
|
|
|
else
|
|
|
|
fprintf (stderr, "bad argument for '%c'\n", opt.opt);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
default:
|
|
|
|
goto print_usage;
|
|
|
|
}
|
|
|
|
}
|
2017-12-16 05:21:38 +00:00
|
|
|
|
|
|
|
if (opt.ind >= argc) goto print_usage;
|
2017-11-22 04:52:45 +00:00
|
|
|
#endif
|
2017-07-27 08:32:16 +00:00
|
|
|
|
2018-11-11 16:53:21 +00:00
|
|
|
moo = moo_openstd(0, &cfg, &errinf);
|
2017-01-09 09:54:49 +00:00
|
|
|
if (!moo)
|
2015-05-07 15:58:04 +00:00
|
|
|
{
|
2018-11-13 09:53:48 +00:00
|
|
|
#if defined(MOO_OOCH_IS_BCH)
|
|
|
|
fprintf (stderr, "ERROR: cannot open moo - [%d] %s\n", (int)errinf.num, errinf.msg);
|
|
|
|
#elif (MOO_SIZEOF_UCH_T == MOO_SIZEOF_WCHAR_T)
|
|
|
|
fprintf (stderr, "ERROR: cannot open moo - [%d] %ls\n", (int)errinf.num, errinf.msg);
|
|
|
|
#else
|
|
|
|
moo_bch_t bcsmsg[MOO_COUNTOF(errinf.msg) * 2]; /* error messages may get truncated */
|
|
|
|
moo_oow_t wcslen, bcslen;
|
|
|
|
bcslen = MOO_COUNTOF(bcsmsg);
|
|
|
|
moo_conv_ucstr_to_utf8 (errinf.msg, &wcslen, bcsmsg, &bcslen);
|
|
|
|
fprintf (stderr, "ERROR: cannot open moo - [%d] %s\n", (int)errinf.num, bcsmsg);
|
|
|
|
#endif
|
2015-05-07 15:58:04 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2017-01-09 09:54:49 +00:00
|
|
|
moo_oow_t tab_size;
|
2018-12-20 16:11:52 +00:00
|
|
|
tab_size = 5000;
|
2019-05-14 10:22:37 +00:00
|
|
|
moo_setoption (moo, MOO_OPTION_SYMTAB_SIZE, &tab_size);
|
2018-12-20 16:11:52 +00:00
|
|
|
tab_size = 5000;
|
2019-05-14 10:22:37 +00:00
|
|
|
moo_setoption (moo, MOO_OPTION_SYSDIC_SIZE, &tab_size);
|
2015-05-07 15:58:04 +00:00
|
|
|
}
|
|
|
|
|
2020-11-25 14:48:26 +00:00
|
|
|
if (cfg.gc_type == MOO_GC_TYPE_SEMISPACE && heapsize <= MIN_HEAPSIZE) heapsize = MIN_HEAPSIZE;
|
2019-10-22 14:25:52 +00:00
|
|
|
if (moo_ignite(moo, heapsize) <= -1)
|
2015-05-07 15:58:04 +00:00
|
|
|
{
|
2017-12-31 16:46:52 +00:00
|
|
|
moo_logbfmt (moo, MOO_LOG_STDERR, "ERROR: cannot ignite moo - [%d] %js\n", moo_geterrnum(moo), moo_geterrstr(moo));
|
2018-02-03 16:42:13 +00:00
|
|
|
moo_close (moo);
|
2015-05-07 15:58:04 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-07-07 15:24:27 +00:00
|
|
|
/* TODO: don't initialize debug information if debug info is not requested.
|
2019-07-10 09:19:38 +00:00
|
|
|
* call moo_loaddbgi() if loading a compiled image... */
|
|
|
|
if (moo_initdbgi(moo, 102400) <= -1) /* TODO: set initial debug information size from a configurable value */
|
2019-07-07 15:24:27 +00:00
|
|
|
{
|
|
|
|
moo_logbfmt (moo, MOO_LOG_STDERR, "ERROR: cannot initialize debug information - [%d] %js\n", moo_geterrnum(moo), moo_geterrstr(moo));
|
|
|
|
moo_close (moo);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-11-12 09:19:35 +00:00
|
|
|
/*
|
2015-06-11 12:09:10 +00:00
|
|
|
#if defined(macintosh)
|
|
|
|
i = 20;
|
2017-12-16 05:21:38 +00:00
|
|
|
xtn->source_path = "test.moo";
|
2015-06-11 12:09:10 +00:00
|
|
|
goto compile;
|
2015-05-28 16:51:37 +00:00
|
|
|
#endif
|
2018-11-12 09:19:35 +00:00
|
|
|
*/
|
2017-11-22 04:52:45 +00:00
|
|
|
for (i = opt.ind; i < argc; i++)
|
2015-05-15 14:55:12 +00:00
|
|
|
{
|
2018-11-13 06:54:30 +00:00
|
|
|
moo_iostd_t in;
|
2019-05-22 08:49:27 +00:00
|
|
|
|
|
|
|
memset (&in, 0, MOO_SIZEOF(in));
|
2018-11-26 09:49:03 +00:00
|
|
|
#if 1
|
2018-11-13 06:54:30 +00:00
|
|
|
in.type = MOO_IOSTD_FILEB;
|
|
|
|
in.u.fileb.path = argv[i];
|
|
|
|
#else
|
|
|
|
moo_uch_t tmp[1000];
|
|
|
|
moo_oow_t bcslen, ucslen;
|
|
|
|
ucslen = MOO_COUNTOF(tmp);
|
|
|
|
moo_conv_utf8_to_ucstr(argv[i], &bcslen, tmp, &ucslen);
|
|
|
|
in.type = MOO_IOSTD_FILEU;
|
|
|
|
in.u.fileu.path = tmp;
|
|
|
|
#endif
|
2019-05-21 17:24:27 +00:00
|
|
|
in.cmgr = MOO_NULL;
|
2015-05-20 15:52:45 +00:00
|
|
|
|
2018-11-12 09:19:35 +00:00
|
|
|
/*compile:*/
|
2018-11-13 06:54:30 +00:00
|
|
|
if (moo_compilestd(moo, &in, 1) <= -1)
|
2015-06-11 12:09:10 +00:00
|
|
|
{
|
2017-12-17 06:38:08 +00:00
|
|
|
if (moo->errnum == MOO_ESYNERR)
|
2015-05-20 15:52:45 +00:00
|
|
|
{
|
2018-11-26 09:49:03 +00:00
|
|
|
print_syntax_error (moo, argv[i]);
|
2015-05-19 15:16:18 +00:00
|
|
|
}
|
2015-06-11 12:09:10 +00:00
|
|
|
else
|
|
|
|
{
|
2017-12-31 16:46:52 +00:00
|
|
|
moo_logbfmt (moo, MOO_LOG_STDERR, "ERROR: cannot compile code - [%d] %js\n", moo_geterrnum(moo), moo_geterrmsg(moo));
|
2015-06-11 12:09:10 +00:00
|
|
|
}
|
2017-11-22 04:52:45 +00:00
|
|
|
|
2018-02-03 16:42:13 +00:00
|
|
|
moo_close (moo);
|
2015-06-11 12:09:10 +00:00
|
|
|
return -1;
|
2015-05-19 15:16:18 +00:00
|
|
|
}
|
2015-05-15 14:55:12 +00:00
|
|
|
}
|
|
|
|
|
2019-08-12 02:32:04 +00:00
|
|
|
/*MOO_DEBUG2 (moo, "XXXXXXXXXXXXXXXXXXXXX %O %zd\n", moo_ooitoint(moo, MOO_TYPE_MIN(moo_ooi_t)), MOO_TYPE_MIN(moo_ooi_t));
|
|
|
|
MOO_DEBUG2 (moo, "XXXXXXXXXXXXXXXXXXXXX %O %jd\n", moo_intmaxtoint(moo, MOO_TYPE_MIN(moo_intmax_t)), MOO_TYPE_MIN(moo_intmax_t));
|
|
|
|
MOO_DEBUG2 (moo, "XXXXXXXXXXXXXXXXXXXXX %O %ju\n", moo_uintmaxtoint(moo, MOO_TYPE_MAX(moo_uintmax_t)), MOO_TYPE_MAX(moo_uintmax_t));
|
|
|
|
MOO_DEBUG2 (moo, "XXXXXXXXXXXXXXXXXXXXX %O %zu\n", moo_oowtoint(moo, MOO_TYPE_MAX(moo_oow_t)), MOO_TYPE_MAX(moo_oow_t));*/
|
|
|
|
|
2017-01-10 13:56:19 +00:00
|
|
|
MOO_DEBUG0 (moo, "COMPILE OK. STARTING EXECUTION...\n");
|
2016-05-17 15:12:27 +00:00
|
|
|
xret = 0;
|
2018-11-26 09:49:03 +00:00
|
|
|
|
2018-12-04 03:34:54 +00:00
|
|
|
#if defined(SIGINT) && defined(HAVE_SIGNAL)
|
|
|
|
/* i'd like the program to ignore the interrupt signal
|
|
|
|
* before moo_catch_termreq() and after moo_uncatch_termreq() */
|
|
|
|
signal (SIGINT, SIG_IGN);
|
|
|
|
signal (SIGTERM, SIG_IGN);
|
|
|
|
#endif
|
|
|
|
|
2018-11-26 09:49:03 +00:00
|
|
|
moo_catch_termreq ();
|
2018-11-19 15:52:26 +00:00
|
|
|
moo_start_ticker ();
|
2016-05-17 15:12:27 +00:00
|
|
|
|
2018-11-19 15:52:26 +00:00
|
|
|
moo_rcvtickstd (moo, 1);
|
|
|
|
|
2015-06-11 09:11:18 +00:00
|
|
|
objname.ptr = str_my_object;
|
|
|
|
objname.len = 8;
|
2015-06-06 07:24:35 +00:00
|
|
|
mthname.ptr = str_main;
|
|
|
|
mthname.len = 4;
|
2018-02-05 09:56:05 +00:00
|
|
|
if (moo_invoke(moo, &objname, &mthname) <= -1)
|
2015-06-04 18:34:37 +00:00
|
|
|
{
|
2017-12-31 16:46:52 +00:00
|
|
|
moo_logbfmt (moo, MOO_LOG_STDERR, "ERROR: cannot execute code - [%d] %js\n", moo_geterrnum(moo), moo_geterrmsg(moo));
|
2016-05-17 15:12:27 +00:00
|
|
|
xret = -1;
|
2015-06-04 18:34:37 +00:00
|
|
|
}
|
2015-06-06 07:24:35 +00:00
|
|
|
|
2018-11-19 15:52:26 +00:00
|
|
|
moo_stop_ticker ();
|
2018-11-26 09:49:03 +00:00
|
|
|
moo_uncatch_termreq ();
|
2015-06-06 07:24:35 +00:00
|
|
|
|
2017-01-09 09:54:49 +00:00
|
|
|
/*moo_dumpsymtab(moo);
|
2018-12-19 16:57:16 +00:00
|
|
|
moo_dumpdic(moo, moo->sysdic, "System dictionary");*/
|
2016-06-05 18:37:28 +00:00
|
|
|
|
2018-02-03 16:42:13 +00:00
|
|
|
moo_close (moo);
|
2016-05-17 15:12:27 +00:00
|
|
|
return xret;
|
2015-05-07 15:58:04 +00:00
|
|
|
}
|