finished the native method handling code in the compiler
This commit is contained in:
parent
8442968f9c
commit
6a7cbc8dcb
@ -75,6 +75,7 @@ class MyObject(Object)
|
||||
'wrong class name'
|
||||
'non-pointer class inheriting superclass with trailer size set'
|
||||
'dcl not allowed'
|
||||
'#native not allowed'
|
||||
'wrong method name'
|
||||
'duplicate method name'
|
||||
'duplicate argument name'
|
||||
|
@ -5832,6 +5832,12 @@ static int compile_method_definition (moo_t* moo)
|
||||
else if (is_token_symbol(moo, VOCA_NATIVE_S))
|
||||
{
|
||||
/* method(#native) */
|
||||
if (moo->c->cls.self_oop->modname == moo->_nil)
|
||||
{
|
||||
set_syntax_error (moo, MOO_SYNERR_NATIVEBANNED, TOKEN_LOC(moo), TOKEN_NAME(moo));
|
||||
return -1;
|
||||
}
|
||||
|
||||
moo->c->mth.native = 1;
|
||||
GET_TOKEN (moo);
|
||||
}
|
||||
@ -5855,7 +5861,8 @@ static int compile_method_definition (moo_t* moo)
|
||||
|
||||
if (moo->c->mth.native)
|
||||
{
|
||||
moo_oow_t lit_idx;
|
||||
moo_oow_t litidx, savedlen;
|
||||
moo_oocs_t tmp;
|
||||
|
||||
if (TOKEN_TYPE(moo) != MOO_IOTOK_PERIOD)
|
||||
{
|
||||
@ -5867,21 +5874,29 @@ static int compile_method_definition (moo_t* moo)
|
||||
/* TODO: i can check if the native method is available at compile time by querying the module.
|
||||
* do the check depending on the compiler option */
|
||||
|
||||
|
||||
//moo->c->cls.self_oop->modname + "." + moo->c->mth.name and make symbol.
|
||||
#if 0
|
||||
if (add_symbol_literal(moo, xxx, 0, &lit_idx) <= -1 ||
|
||||
!MOO_OOI_IN_METHOD_PREAMBLE_INDEX_RANGE(lit_idx))
|
||||
/* combine the module name and the method name delimited by a period
|
||||
* when doing it, let me reuse the cls.modname buffer and restore it
|
||||
* back once done */
|
||||
MOO_ASSERT (moo, MOO_CLASSOF(moo, moo->c->cls.self_oop->modname) == moo->_symbol);
|
||||
savedlen = moo->c->cls.modname.len;
|
||||
tmp.ptr = ((moo_oop_char_t)moo->c->cls.self_oop->modname)->slot;
|
||||
tmp.len = MOO_OBJ_GET_SIZE(moo->c->cls.self_oop->modname);
|
||||
if (copy_string_to (moo, &tmp, &moo->c->cls.modname, &moo->c->cls.modname_capa, 1, '\0') <= -1 ||
|
||||
copy_string_to (moo, &moo->c->mth.name, &moo->c->cls.modname, &moo->c->cls.modname_capa, 1, '.') <= -1 ||
|
||||
add_symbol_literal(moo, &moo->c->cls.modname, savedlen, &litidx) <= -1)
|
||||
{
|
||||
/* TODO: change error code */
|
||||
set_syntax_error (moo, MOO_SYNERR_PFID, TOKEN_LOC(moo), MOO_NULL);
|
||||
moo->c->cls.modname.len = savedlen;
|
||||
return -1;
|
||||
}
|
||||
moo->c->cls.modname.len = savedlen;
|
||||
|
||||
/* the symbol added must be the first literal to the current method.
|
||||
* so this condition must be true. */
|
||||
MOO_ASSERT (moo, MOO_OOI_IN_METHOD_PREAMBLE_INDEX_RANGE(litidx));
|
||||
|
||||
/* external named primitive containing a period. */
|
||||
moo->c->mth.pftype = PFTYPE_NAMED;
|
||||
moo->c->mth.pfnum = lit_idx;
|
||||
#endif
|
||||
moo->c->mth.pfnum = litidx;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -101,37 +101,38 @@ static moo_ooch_t synerrstr_29[] = {'c','o','n','t','r','a','d','i','c','t','o',
|
||||
static moo_ooch_t synerrstr_30[] = {'w','r','o','n','g',' ','c','l','a','s','s',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_31[] = {'n','o','n','-','p','o','i','n','t','e','r',' ','c','l','a','s','s',' ','i','n','h','e','r','i','t','i','n','g',' ','s','u','p','e','r','c','l','a','s','s',' ','w','i','t','h',' ','t','r','a','i','l','e','r',' ','s','i','z','e',' ','s','e','t','\0'};
|
||||
static moo_ooch_t synerrstr_32[] = {'d','c','l',' ','n','o','t',' ','a','l','l','o','w','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_33[] = {'w','r','o','n','g',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_34[] = {'d','u','p','l','i','c','a','t','e',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_35[] = {'d','u','p','l','i','c','a','t','e',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_36[] = {'d','u','p','l','i','c','a','t','e',' ','t','e','m','p','o','r','a','r','y',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_37[] = {'d','u','p','l','i','c','a','t','e',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_38[] = {'d','u','p','l','i','c','a','t','e',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_39[] = {'u','n','d','e','c','l','a','r','e','d',' ','v','a','r','i','a','b','l','e','\0'};
|
||||
static moo_ooch_t synerrstr_40[] = {'u','n','u','s','a','b','l','e',' ','v','a','r','i','a','b','l','e',' ','i','n',' ','c','o','m','p','i','l','e','d',' ','c','o','d','e','\0'};
|
||||
static moo_ooch_t synerrstr_41[] = {'i','n','a','c','c','e','s','s','i','b','l','e',' ','v','a','r','i','a','b','l','e','\0'};
|
||||
static moo_ooch_t synerrstr_42[] = {'a','m','b','i','g','u','o','u','s',' ','v','a','r','i','a','b','l','e','\0'};
|
||||
static moo_ooch_t synerrstr_43[] = {'w','r','o','n','g',' ','e','x','p','r','e','s','s','i','o','n',' ','p','r','i','m','a','r','y','\0'};
|
||||
static moo_ooch_t synerrstr_44[] = {'t','o','o',' ','m','a','n','y',' ','t','e','m','p','o','r','a','r','i','e','s','\0'};
|
||||
static moo_ooch_t synerrstr_45[] = {'t','o','o',' ','m','a','n','y',' ','a','r','g','u','m','e','n','t','s','\0'};
|
||||
static moo_ooch_t synerrstr_46[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','t','e','m','p','o','r','a','r','i','e','s','\0'};
|
||||
static moo_ooch_t synerrstr_47[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t','s','\0'};
|
||||
static moo_ooch_t synerrstr_48[] = {'t','o','o',' ','l','a','r','g','e',' ','b','l','o','c','k','\0'};
|
||||
static moo_ooch_t synerrstr_49[] = {'t','o','o',' ','l','a','r','g','e',' ','a','r','r','a','y',' ','e','x','p','r','e','s','s','i','o','n','\0'};
|
||||
static moo_ooch_t synerrstr_50[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','n','u','m','b','e','r','\0'};
|
||||
static moo_ooch_t synerrstr_51[] = {'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_52[] = {'w','r','o','n','g',' ','m','o','d','u','l','e',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_53[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\0'};
|
||||
static moo_ooch_t synerrstr_54[] = {'w','r','o','n','g',' ','n','a','m','e','s','p','a','c','e',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_55[] = {'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_56[] = {'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_57[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_58[] = {'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_59[] = {'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_60[] = {'w','h','i','l','e',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_61[] = {'m','i','s','s','i','n','g',' ','a','s','s','o','c','i','a','t','i','o','n',' ','k','e','y','\0'};
|
||||
static moo_ooch_t synerrstr_62[] = {'m','i','s','s','i','n','g',' ','a','s','s','o','c','i','a','t','i','o','n',' ','v','a','l','u','e','\0'};
|
||||
static moo_ooch_t synerrstr_63[] = {'m','i','s','s','i','n','g',' ','a','s','s','o','c','i','a','t','i','o','n','\0'};
|
||||
static moo_ooch_t synerrstr_33[] = {'#','n','a','t','i','v','e',' ','n','o','t',' ','a','l','l','o','w','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_34[] = {'w','r','o','n','g',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_35[] = {'d','u','p','l','i','c','a','t','e',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_36[] = {'d','u','p','l','i','c','a','t','e',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_37[] = {'d','u','p','l','i','c','a','t','e',' ','t','e','m','p','o','r','a','r','y',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_38[] = {'d','u','p','l','i','c','a','t','e',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_39[] = {'d','u','p','l','i','c','a','t','e',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_40[] = {'u','n','d','e','c','l','a','r','e','d',' ','v','a','r','i','a','b','l','e','\0'};
|
||||
static moo_ooch_t synerrstr_41[] = {'u','n','u','s','a','b','l','e',' ','v','a','r','i','a','b','l','e',' ','i','n',' ','c','o','m','p','i','l','e','d',' ','c','o','d','e','\0'};
|
||||
static moo_ooch_t synerrstr_42[] = {'i','n','a','c','c','e','s','s','i','b','l','e',' ','v','a','r','i','a','b','l','e','\0'};
|
||||
static moo_ooch_t synerrstr_43[] = {'a','m','b','i','g','u','o','u','s',' ','v','a','r','i','a','b','l','e','\0'};
|
||||
static moo_ooch_t synerrstr_44[] = {'w','r','o','n','g',' ','e','x','p','r','e','s','s','i','o','n',' ','p','r','i','m','a','r','y','\0'};
|
||||
static moo_ooch_t synerrstr_45[] = {'t','o','o',' ','m','a','n','y',' ','t','e','m','p','o','r','a','r','i','e','s','\0'};
|
||||
static moo_ooch_t synerrstr_46[] = {'t','o','o',' ','m','a','n','y',' ','a','r','g','u','m','e','n','t','s','\0'};
|
||||
static moo_ooch_t synerrstr_47[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','t','e','m','p','o','r','a','r','i','e','s','\0'};
|
||||
static moo_ooch_t synerrstr_48[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t','s','\0'};
|
||||
static moo_ooch_t synerrstr_49[] = {'t','o','o',' ','l','a','r','g','e',' ','b','l','o','c','k','\0'};
|
||||
static moo_ooch_t synerrstr_50[] = {'t','o','o',' ','l','a','r','g','e',' ','a','r','r','a','y',' ','e','x','p','r','e','s','s','i','o','n','\0'};
|
||||
static moo_ooch_t synerrstr_51[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','n','u','m','b','e','r','\0'};
|
||||
static moo_ooch_t synerrstr_52[] = {'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_53[] = {'w','r','o','n','g',' ','m','o','d','u','l','e',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_54[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\0'};
|
||||
static moo_ooch_t synerrstr_55[] = {'w','r','o','n','g',' ','n','a','m','e','s','p','a','c','e',' ','n','a','m','e','\0'};
|
||||
static moo_ooch_t synerrstr_56[] = {'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_57[] = {'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_58[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_59[] = {'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_60[] = {'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_61[] = {'w','h','i','l','e',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_62[] = {'m','i','s','s','i','n','g',' ','a','s','s','o','c','i','a','t','i','o','n',' ','k','e','y','\0'};
|
||||
static moo_ooch_t synerrstr_63[] = {'m','i','s','s','i','n','g',' ','a','s','s','o','c','i','a','t','i','o','n',' ','v','a','l','u','e','\0'};
|
||||
static moo_ooch_t synerrstr_64[] = {'m','i','s','s','i','n','g',' ','a','s','s','o','c','i','a','t','i','o','n','\0'};
|
||||
static moo_ooch_t* synerrstr[] =
|
||||
{
|
||||
synerrstr_0, synerrstr_1, synerrstr_2, synerrstr_3, synerrstr_4, synerrstr_5, synerrstr_6, synerrstr_7,
|
||||
@ -141,8 +142,10 @@ static moo_ooch_t* synerrstr[] =
|
||||
synerrstr_32, synerrstr_33, synerrstr_34, synerrstr_35, synerrstr_36, synerrstr_37, synerrstr_38, synerrstr_39,
|
||||
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_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
|
||||
};
|
||||
|
||||
#endif
|
||||
/* END: GENERATED WITH generr.st */
|
||||
|
||||
|
@ -41,12 +41,12 @@ MOO_EXPORT moo_oow_t moo_hashbytes (
|
||||
#if defined(MOO_HAVE_INLINE)
|
||||
static MOO_INLINE moo_oow_t moo_hashbchars (const moo_bch_t* ptr, moo_oow_t len)
|
||||
{
|
||||
return moo_hashbytes((const moo_oob_t*)ptr,len * MOO_SIZEOF(moo_bch_t));
|
||||
return moo_hashbytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_bch_t));
|
||||
}
|
||||
|
||||
static MOO_INLINE moo_oow_t moo_hashuchars (const moo_uch_t* ptr, moo_oow_t len)
|
||||
{
|
||||
return moo_hashbytes((const moo_oob_t*)ptr,len * MOO_SIZEOF(moo_uch_t));
|
||||
return moo_hashbytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_uch_t));
|
||||
}
|
||||
|
||||
static MOO_INLINE moo_oow_t moo_hashwords (const moo_oow_t* ptr, moo_oow_t len)
|
||||
@ -59,8 +59,8 @@ MOO_EXPORT moo_oow_t moo_hashbytes (
|
||||
return moo_hashbytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_oohw_t));
|
||||
}
|
||||
#else
|
||||
# define moo_hashbchars(ptr,len) moo_hashbytes((const moo_oob_t*)ptr,len * MOO_SIZEOF(moo_bch_t))
|
||||
# define moo_hashuchars(ptr,len) moo_hashbytes((const moo_oob_t*)ptr,len * MOO_SIZEOF(moo_uch_t))
|
||||
# define moo_hashbchars(ptr,len) moo_hashbytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_bch_t))
|
||||
# define moo_hashuchars(ptr,len) moo_hashbytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_uch_t))
|
||||
# define moo_hashwords(ptr,len) moo_hashbytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_oow_t))
|
||||
# define moo_hashhalfwords(ptr,len) moo_hashbytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_oohw_t))
|
||||
#endif
|
||||
|
@ -1207,6 +1207,7 @@ enum moo_synerrnum_t
|
||||
MOO_SYNERR_CLASSNAME, /* wrong class name */
|
||||
MOO_SYNERR_CLASSTRSIZE, /* non-pointer class inheriting a superclass with trailer size set */
|
||||
MOO_SYNERR_DCLBANNED, /* #dcl not allowed */
|
||||
MOO_SYNERR_NATIVEBANNED, /* #native not allowed */
|
||||
MOO_SYNERR_MTHNAME, /* wrong method name */
|
||||
MOO_SYNERR_MTHNAMEDUP, /* duplicate method name */
|
||||
MOO_SYNERR_ARGNAMEDUP, /* duplicate argument name */
|
||||
|
@ -47,7 +47,6 @@ typedef struct x11_win_t x11_win_t;
|
||||
struct x11_win_t
|
||||
{
|
||||
xcb_window_t w;
|
||||
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
@ -265,7 +264,8 @@ static moo_pfinfo_t x11_pfinfo[] =
|
||||
static int x11_import (moo_t* moo, moo_mod_t* mod, moo_oop_class_t _class)
|
||||
{
|
||||
if (moo_setclasstrsize(moo, _class, MOO_SIZEOF(x11_t)) <= -1) return -1;
|
||||
return moo_genpfmethods(moo, mod, _class, x11_pfinfo, MOO_COUNTOF(x11_pfinfo));
|
||||
/*return moo_genpfmethods(moo, mod, _class, x11_pfinfo, MOO_COUNTOF(x11_pfinfo));*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
static moo_pfimpl_t x11_query (moo_t* moo, moo_mod_t* mod, const moo_ooch_t* name)
|
||||
|
Loading…
Reference in New Issue
Block a user