Added a new syntax error code MODIMPFAIL

This commit is contained in:
hyunghwan.chung 2017-06-08 14:39:17 +00:00
parent 40ec8fc157
commit 9b3c3007fd
8 changed files with 74 additions and 20 deletions

View File

@ -106,6 +106,7 @@ class MyObject(Object)
'wrong primitive function identifier' 'wrong primitive function identifier'
'wrong primitive function argument definition' 'wrong primitive function argument definition'
'wrong module name' 'wrong module name'
'failed to import module'
'#include error' '#include error'
'wrong namespace name' 'wrong namespace name'
'wrong pool dictionary name' 'wrong pool dictionary name'

View File

@ -7,6 +7,8 @@
class MyObject(Object) class MyObject(Object)
{ {
## TODO: support import in extend??
var(#class) a := 100. var(#class) a := 100.
method(#class) proc1 method(#class) proc1
@ -20,7 +22,7 @@ class MyObject(Object)
| tc limit | | tc limit |
tc := #{ tc := #{
## 0 - 4 ## 0 - 4
[ self proc1 == 100 ], [ self proc1 == 100 ],
[ Processor sleepFor: 2. self proc1 == 200 ] [ Processor sleepFor: 2. self proc1 == 200 ]
}. }.

View File

@ -4164,7 +4164,6 @@ static MOO_INLINE int find_undotted_ident (moo_t* moo, const moo_oocs_t* name, c
return 0; return 0;
} }
MOO_DEBUG0 (moo, "2222222222222222\n");
/* find an undotted identifier in dictionaries */ /* find an undotted identifier in dictionaries */
if (moo->c->cls.ns_oop) if (moo->c->cls.ns_oop)
{ {
@ -7298,6 +7297,7 @@ static int __compile_class_definition (moo_t* moo, int extend)
} }
if (set_class_modname (moo, TOKEN_NAME(moo)) <= -1) return -1; if (set_class_modname (moo, TOKEN_NAME(moo)) <= -1) return -1;
moo->c->cls.modname_loc = *TOKEN_LOC(moo);
GET_TOKEN (moo); GET_TOKEN (moo);
} }
@ -7441,7 +7441,11 @@ static int __compile_class_definition (moo_t* moo, int extend)
* memory(not part of the object memory) to moo_importmod(). * memory(not part of the object memory) to moo_importmod().
* no big overhead as it's already available. but Accessing * no big overhead as it's already available. but Accessing
* this extra module name, i'm free from GC headache */ * this extra module name, i'm free from GC headache */
if (moo_importmod (moo, moo->c->cls.self_oop, moo->c->cls.modname.ptr, moo->c->cls.modname.len) <= -1) return -1; if (moo_importmod (moo, moo->c->cls.self_oop, moo->c->cls.modname.ptr, moo->c->cls.modname.len) <= -1)
{
set_syntax_error (moo, MOO_SYNERR_MODIMPFAIL, &moo->c->cls.modname_loc, &moo->c->cls.modname);
return -1;
}
} }
if (moo->c->cls.self_oop->trsize == moo->_nil && if (moo->c->cls.self_oop->trsize == moo->_nil &&

View File

@ -132,14 +132,15 @@ static moo_ooch_t synerrstr_58[] = {'w','r','o','n','g',' ','p','r','i','m','i',
static moo_ooch_t synerrstr_59[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','i','d','e','n','t','i','f','i','e','r','\0'}; static moo_ooch_t synerrstr_59[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','i','d','e','n','t','i','f','i','e','r','\0'};
static moo_ooch_t synerrstr_60[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','a','r','g','u','m','e','n','t',' ','d','e','f','i','n','i','t','i','o','n','\0'}; static moo_ooch_t synerrstr_60[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','a','r','g','u','m','e','n','t',' ','d','e','f','i','n','i','t','i','o','n','\0'};
static moo_ooch_t synerrstr_61[] = {'w','r','o','n','g',' ','m','o','d','u','l','e',' ','n','a','m','e','\0'}; static moo_ooch_t synerrstr_61[] = {'w','r','o','n','g',' ','m','o','d','u','l','e',' ','n','a','m','e','\0'};
static moo_ooch_t synerrstr_62[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\0'}; static moo_ooch_t synerrstr_62[] = {'f','a','i','l','e','d',' ','t','o',' ','i','m','p','o','r','t',' ','m','o','d','u','l','e','\0'};
static moo_ooch_t synerrstr_63[] = {'w','r','o','n','g',' ','n','a','m','e','s','p','a','c','e',' ','n','a','m','e','\0'}; static moo_ooch_t synerrstr_63[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\0'};
static moo_ooch_t synerrstr_64[] = {'w','r','o','n','g',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'}; static moo_ooch_t synerrstr_64[] = {'w','r','o','n','g',' ','n','a','m','e','s','p','a','c','e',' ','n','a','m','e','\0'};
static moo_ooch_t synerrstr_65[] = {'d','u','p','l','i','c','a','t','e',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'}; static moo_ooch_t synerrstr_65[] = {'w','r','o','n','g',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'};
static moo_ooch_t synerrstr_66[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\0'}; static moo_ooch_t synerrstr_66[] = {'d','u','p','l','i','c','a','t','e',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'};
static moo_ooch_t synerrstr_67[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','n','o','t',' ','w','i','t','h','i','n',' ','a',' ','l','o','o','p','\0'}; static moo_ooch_t synerrstr_67[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\0'};
static moo_ooch_t synerrstr_68[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','w','i','t','h','i','n',' ','a',' ','b','l','o','c','k','\0'}; static moo_ooch_t synerrstr_68[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','n','o','t',' ','w','i','t','h','i','n',' ','a',' ','l','o','o','p','\0'};
static moo_ooch_t synerrstr_69[] = {'w','h','i','l','e',' ','e','x','p','e','c','t','e','d','\0'}; static moo_ooch_t synerrstr_69[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','w','i','t','h','i','n',' ','a',' ','b','l','o','c','k','\0'};
static moo_ooch_t synerrstr_70[] = {'w','h','i','l','e',' ','e','x','p','e','c','t','e','d','\0'};
static moo_ooch_t* synerrstr[] = static moo_ooch_t* synerrstr[] =
{ {
synerrstr_0, synerrstr_1, synerrstr_2, synerrstr_3, synerrstr_4, synerrstr_5, synerrstr_6, synerrstr_7, synerrstr_0, synerrstr_1, synerrstr_2, synerrstr_3, synerrstr_4, synerrstr_5, synerrstr_6, synerrstr_7,
@ -150,7 +151,7 @@ static moo_ooch_t* synerrstr[] =
synerrstr_40, synerrstr_41, synerrstr_42, synerrstr_43, synerrstr_44, synerrstr_45, synerrstr_46, synerrstr_47, synerrstr_40, synerrstr_41, synerrstr_42, synerrstr_43, synerrstr_44, synerrstr_45, synerrstr_46, synerrstr_47,
synerrstr_48, synerrstr_49, synerrstr_50, synerrstr_51, synerrstr_52, synerrstr_53, synerrstr_54, synerrstr_55, synerrstr_48, synerrstr_49, synerrstr_50, synerrstr_51, synerrstr_52, synerrstr_53, synerrstr_54, synerrstr_55,
synerrstr_56, synerrstr_57, synerrstr_58, synerrstr_59, synerrstr_60, synerrstr_61, synerrstr_62, synerrstr_63, synerrstr_56, synerrstr_57, synerrstr_58, synerrstr_59, synerrstr_60, synerrstr_61, synerrstr_62, synerrstr_63,
synerrstr_64, synerrstr_65, synerrstr_66, synerrstr_67, synerrstr_68, synerrstr_69 synerrstr_64, synerrstr_65, synerrstr_66, synerrstr_67, synerrstr_68, synerrstr_69, synerrstr_70
}; };
#endif #endif
/* END: GENERATED WITH generr.moo */ /* END: GENERATED WITH generr.moo */

View File

@ -32,7 +32,9 @@
#include <limits.h> #include <limits.h>
#include <errno.h> #include <errno.h>
#define USE_THREAD #if !defined(__DOS__)
# define USE_THREAD
#endif
#if defined(_WIN32) #if defined(_WIN32)
# include <windows.h> # include <windows.h>
@ -53,10 +55,19 @@
# include <dos.h> # include <dos.h>
# include <time.h> # include <time.h>
# include <io.h> # include <io.h>
# include <signal.h>
/* fake XPOLLXXX values */
# define XPOLLIN (1 << 0)
# define XPOLLOUT (1 << 1)
# define XPOLLERR (1 << 2)
# define XPOLLHUP (1 << 3)
#elif defined(macintosh) #elif defined(macintosh)
# include <Types.h> # include <Types.h>
# include <OSUtils.h> # include <OSUtils.h>
# include <Timer.h> # include <Timer.h>
#else #else
# if defined(MOO_ENABLE_LIBLTDL) # if defined(MOO_ENABLE_LIBLTDL)
@ -831,7 +842,10 @@ static int _add_poll_fd (moo_t* moo, int fd, int event_mask, moo_oow_t event_dat
return 0; return 0;
#else #else
# error UNSUPPORTED
MOO_DEBUG1 (moo, "Cannot add file descriptor %d to poll - not implemented\n", fd);
moo_seterrnum (moo, MOO_ENOIMPL);
return -1;
#endif #endif
} }
@ -886,11 +900,15 @@ static int _del_poll_fd (moo_t* moo, int fd)
} }
moo_seterrnum (moo, MOO_ENOENT);
MOO_DEBUG1 (moo, "Cannot remove file descriptor %d from poll - not found\n", fd); MOO_DEBUG1 (moo, "Cannot remove file descriptor %d from poll - not found\n", fd);
moo_seterrnum (moo, MOO_ENOENT);
return -1; return -1;
#else #else
# error NOT SUPPORTED
MOO_DEBUG1 (moo, "Cannot remove file descriptor %d from poll - not implemented\n", fd);
moo_seterrnum (moo, MOO_ENOIMPL);
return -1;
#endif #endif
} }
@ -946,7 +964,9 @@ static int _mod_poll_fd (moo_t* moo, int fd, int event_mask, moo_oow_t event_dat
return -1; return -1;
#else #else
# error NOT SUPPORTED MOO_DEBUG1 (moo, "Cannot modify file descriptor %d in poll - not implemented\n", fd);
moo_seterrnum (moo, MOO_ENOIMPL);
return -1;
#endif #endif
} }
@ -1446,7 +1466,7 @@ static void vm_muxwait (moo_t* moo, const moo_ntime_t* dur, moo_vmprim_muxwait_c
#elif defined(USE_EPOLL) #elif defined(USE_EPOLL)
revents = xtn->ev.buf[n].events; revents = xtn->ev.buf[n].events;
#else #else
# error UNSUPPORTED revents = 0; /* TODO: fake. unsupported */
#endif #endif
mask = 0; mask = 0;
@ -1461,7 +1481,7 @@ static void vm_muxwait (moo_t* moo, const moo_ntime_t* dur, moo_vmprim_muxwait_c
#elif defined(USE_EPOLL) #elif defined(USE_EPOLL)
muxwcb (moo, mask, xtn->ev.buf[n].data.ptr); muxwcb (moo, mask, xtn->ev.buf[n].data.ptr);
#else #else
# error UNSUPPORTED /* TODO: fake. unsupported */
#endif #endif
} }
@ -1672,12 +1692,36 @@ static void handle_term (int sig)
static void setup_term (void) static void setup_term (void)
{ {
#if defined(_WIN32)
SetConsoleCtrlHandler (handle_term, TRUE);
#elif defined(__OS2__)
os2_excrr.ExceptionHandler = (ERR)__intr_handler;
DosSetExceptionHandler (&os2_excrr); /* TODO: check if NO_ERROR is returned */
#elif defined(__DOS__)
signal (SIGINT, handle_term);
#else
struct sigaction sa; struct sigaction sa;
memset (&sa, 0, MOO_SIZEOF(sa)); memset (&sa, 0, MOO_SIZEOF(sa));
sa.sa_handler = handle_term; sa.sa_handler = handle_term;
sigaction (SIGINT, &sa, MOO_NULL); sigaction (SIGINT, &sa, MOO_NULL);
#endif
} }
static void clear_term (void)
{
#if defined(_WIN32)
SetConsoleCtrlHandler (handle_term, FALSE);
#elif defined(__OS2__)
DosUnsetExceptionHandler (&os2_excrr);
#elif defined(__DOS__)
signal (SIGINT, SIG_DFL);
#else
struct sigaction sa;
memset (&sa, 0, MOO_SIZEOF(sa));
sa.sa_handler = SIG_DFL;
sigaction (SIGINT, &sa, MOO_NULL);
#endif
}
/* ========================================================================= */ /* ========================================================================= */
int main (int argc, char* argv[]) int main (int argc, char* argv[])
@ -1858,6 +1902,7 @@ int main (int argc, char* argv[])
} }
cancel_tick (); cancel_tick ();
clear_term ();
g_moo = MOO_NULL; g_moo = MOO_NULL;
/*moo_dumpsymtab(moo); /*moo_dumpsymtab(moo);

View File

@ -517,6 +517,7 @@ struct moo_compiler_t
moo_oocs_t modname; /* module name after 'from' */ moo_oocs_t modname; /* module name after 'from' */
moo_oow_t modname_capa; moo_oow_t modname_capa;
moo_ioloc_t modname_loc;
/* instance variable, class variable, class instance variable, constant /* instance variable, class variable, class instance variable, constant
* var[0] - named instance variables * var[0] - named instance variables

View File

@ -473,7 +473,6 @@ moo_mod_data_t* moo_openmod (moo_t* moo, const moo_ooch_t* name, moo_oow_t namel
mdp = (moo_mod_data_t*)MOO_RBT_VPTR(pair); mdp = (moo_mod_data_t*)MOO_RBT_VPTR(pair);
MOO_ASSERT (moo, MOO_SIZEOF(mdp->mod.hints) == MOO_SIZEOF(int)); MOO_ASSERT (moo, MOO_SIZEOF(mdp->mod.hints) == MOO_SIZEOF(int));
MOO_DEBUG2 (moo, "xxxxxxxxxxxxxxxxxxxxxxxxx %p %d\n", mdp, (int)MOO_IS_ALIGNED_POW2((moo_oow_t)mdp, 8));
mdp->mod.hints = hints; mdp->mod.hints = hints;
if (load (moo, &mdp->mod) <= -1) if (load (moo, &mdp->mod) <= -1)
{ {

View File

@ -1351,6 +1351,7 @@ enum moo_synerrnum_t
MOO_SYNERR_PFIDINVAL, /* wrong primitive function identifier */ MOO_SYNERR_PFIDINVAL, /* wrong primitive function identifier */
MOO_SYNERR_PFARGDEFINVAL, /* wrong primitive function argument definition */ MOO_SYNERR_PFARGDEFINVAL, /* wrong primitive function argument definition */
MOO_SYNERR_MODNAMEINVAL, /* wrong module name */ MOO_SYNERR_MODNAMEINVAL, /* wrong module name */
MOO_SYNERR_MODIMPFAIL, /* failed to import module */
MOO_SYNERR_INCLUDE, /* #include error */ MOO_SYNERR_INCLUDE, /* #include error */
MOO_SYNERR_NAMESPACEINVAL, /* wrong namespace name */ MOO_SYNERR_NAMESPACEINVAL, /* wrong namespace name */
MOO_SYNERR_POOLDICINVAL, /* wrong pool dictionary */ MOO_SYNERR_POOLDICINVAL, /* wrong pool dictionary */