fixed primitive value load from load

This commit is contained in:
hyunghwan.chung 2019-10-25 14:59:13 +00:00
parent 484f5ef7f9
commit 6a80f08bae
4 changed files with 62 additions and 25 deletions

View File

@ -13,9 +13,9 @@ class FileAccessor(InputOutputStud) from "io.file"
{ {
//O_RDONLY := 0, //O_RDONLY := 0,
//O_WRONLY := 1 //O_WRONLY := 1
O_RDONLY from "io.file.O_RDONLY", O_RDONLY from "O_RDONLY",
O_WRONLY from "io.file.O_WRONLY", O_WRONLY from "O_WRONLY",
O_RDWR from "io.file.O_RDWR" O_RDWR from "O_RDWR"
} }
method(#primitive,#lenient) _open: path flags: flags. method(#primitive,#lenient) _open: path flags: flags.

View File

@ -10195,6 +10195,9 @@ static int __compile_pooldic_definition (moo_t* moo)
if (TOKEN_TYPE(moo) == MOO_IOTOK_IDENT && is_token_word(moo, VOCA_FROM)) if (TOKEN_TYPE(moo) == MOO_IOTOK_IDENT && is_token_word(moo, VOCA_FROM))
{ {
moo_pvbase_t* pvbase; moo_pvbase_t* pvbase;
moo_cunit_class_t* pcc;
moo_oow_t savedlen;
/* /*
* pooldic X { * pooldic X {
* O_RDONLY := 0, * O_RDONLY := 0,
@ -10202,20 +10205,46 @@ static int __compile_pooldic_definition (moo_t* moo)
* } * }
*/ */
/* TODO: check if this pooldic definition is nested inside a class */ if (!pd->cunit_parent || pd->cunit_parent->cunit_type != MOO_CUNIT_CLASS)
/* TODO: make it more robust */
GET_TOKEN (moo);
if (TOKEN_TYPE(moo) != MOO_IOTOK_STRLIT)
{ {
moo_setsynerrbfmt (moo, MOO_SYNERR_STRING, TOKEN_LOC(moo), TOKEN_NAME(moo), "primitive value name to import expected"); moo_setsynerrbfmt (moo, MOO_SYNERR_PVIMPBANNED, TOKEN_LOC(moo), TOKEN_NAME(moo), "primitive value from module not allowed in non-nested pooldic");
goto oops; goto oops;
} }
pvbase = moo_querymodpv(moo, TOKEN_NAME_PTR(moo), TOKEN_NAME_LEN(moo), MOO_NULL); pcc = (moo_cunit_class_t*)pd->cunit_parent;
if (pcc->modname.len <= 0)
{
moo_setsynerrbfmt (moo, MOO_SYNERR_PVIMPBANNED, TOKEN_LOC(moo), TOKEN_NAME(moo), "primitive value from module not allowed without module from class");
goto oops;
}
GET_TOKEN (moo);
if (TOKEN_TYPE(moo) != MOO_IOTOK_STRLIT)
{
moo_setsynerr (moo, MOO_SYNERR_PVIDINVAL, TOKEN_LOC(moo), TOKEN_NAME(moo));
goto oops;
}
if (moo_rfind_oochar(TOKEN_NAME_PTR(moo), TOKEN_NAME_LEN(moo), '.'))
{
moo_setsynerrbfmt (moo, MOO_SYNERR_PVIDINVAL, TOKEN_LOC(moo), TOKEN_NAME(moo), "primitive value identifier disallowed to have period");
goto oops;
}
/* append the primitive value name to the module name of the parent class.
* it is restored to the saved length after module query for primitive value */
savedlen = pcc->modname.len;
if (copy_string_to (moo, TOKEN_NAME(moo), &pcc->modname, &pcc->modname_capa, 1, '.') <= -1)
{
pcc->modname.len = savedlen;
goto oops;
}
pvbase = moo_querymodpv(moo, pcc->modname.ptr, pcc->modname.len, MOO_NULL);
pcc->modname.len = savedlen;
if (!pvbase) if (!pvbase)
{ {
/* TODO: backup error message and use it */ const moo_ooch_t* oldmsg = moo_backuperrmsg(moo);
moo_setsynerrbfmt (moo, MOO_SYNERR_STRING, TOKEN_LOC(moo), TOKEN_NAME(moo), "primitive value name unknown"); moo_setsynerrbfmt (moo, MOO_SYNERR_PVIDINVAL, TOKEN_LOC(moo), TOKEN_NAME(moo), "wrong primitive value identifier - %js", oldmsg);
goto oops; goto oops;
} }
@ -10234,8 +10263,11 @@ static int __compile_pooldic_definition (moo_t* moo)
break; break;
} }
/* case MOO_PV_STR:
*/
default: default:
moo_setsynerrbfmt (moo, MOO_SYNERR_STRING, TOKEN_LOC(moo), TOKEN_NAME(moo), "unsupported pvtype"); moo_setsynerrbfmt (moo, MOO_SYNERR_STRING, TOKEN_LOC(moo), TOKEN_NAME(moo), "unsupported primitive value type - %d", pvbase->type);
goto oops; goto oops;
} }

View File

@ -139,18 +139,20 @@ static moo_ooch_t synerrstr_63[] = {'i','n','s','t','r','u','c','t','i','o','n',
static moo_ooch_t synerrstr_64[] = {'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_64[] = {'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_65[] = {'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_65[] = {'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_66[] = {'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_66[] = {'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_67[] = {'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_67[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','v','a','l','u','e',' ','i','d','e','n','t','i','f','i','e','r','\0'};
static moo_ooch_t synerrstr_68[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\0'}; static moo_ooch_t synerrstr_68[] = {'p','r','i','m','i','t','i','v','e',' ','v','a','l','u','e',' ','l','o','a','d',' ','f','r','o','m',' ','m','o','d','u','l','e',' ','n','o','t',' ','a','l','l','o','w','e','d','\0'};
static moo_ooch_t synerrstr_69[] = {'w','r','o','n','g',' ','p','r','a','g','m','a',' ','n','a','m','e','\0'}; static moo_ooch_t synerrstr_69[] = {'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_70[] = {'w','r','o','n','g',' ','n','a','m','e','s','p','a','c','e',' ','n','a','m','e','\0'}; static moo_ooch_t synerrstr_70[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\0'};
static moo_ooch_t synerrstr_71[] = {'w','r','o','n','g',' ','p','o','o','l','d','i','c',' ','i','m','p','o','r','t',' ','n','a','m','e','\0'}; static moo_ooch_t synerrstr_71[] = {'w','r','o','n','g',' ','p','r','a','g','m','a',' ','n','a','m','e','\0'};
static moo_ooch_t synerrstr_72[] = {'d','u','p','l','i','c','a','t','e',' ','p','o','o','l','d','i','c',' ','i','m','p','o','r','t',' ','n','a','m','e','\0'}; static moo_ooch_t synerrstr_72[] = {'w','r','o','n','g',' ','n','a','m','e','s','p','a','c','e',' ','n','a','m','e','\0'};
static moo_ooch_t synerrstr_73[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\0'}; static moo_ooch_t synerrstr_73[] = {'w','r','o','n','g',' ','p','o','o','l','d','i','c',' ','i','m','p','o','r','t',' ','n','a','m','e','\0'};
static moo_ooch_t synerrstr_74[] = {'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_74[] = {'d','u','p','l','i','c','a','t','e',' ','p','o','o','l','d','i','c',' ','i','m','p','o','r','t',' ','n','a','m','e','\0'};
static moo_ooch_t synerrstr_75[] = {'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_75[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\0'};
static moo_ooch_t synerrstr_76[] = {'w','h','i','l','e',' ','e','x','p','e','c','t','e','d','\0'}; static moo_ooch_t synerrstr_76[] = {'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_77[] = {'i','n','v','a','l','i','d',' ','g','o','t','o',' ','t','a','r','g','e','t','\0'}; static moo_ooch_t synerrstr_77[] = {'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_78[] = {'l','a','b','e','l',' ','a','t',' ','e','n','d','\0'}; static moo_ooch_t synerrstr_78[] = {'w','h','i','l','e',' ','e','x','p','e','c','t','e','d','\0'};
static moo_ooch_t synerrstr_79[] = {'i','n','v','a','l','i','d',' ','g','o','t','o',' ','t','a','r','g','e','t','\0'};
static moo_ooch_t synerrstr_80[] = {'l','a','b','e','l',' ','a','t',' ','e','n','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,
@ -162,7 +164,8 @@ static moo_ooch_t* synerrstr[] =
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_70, synerrstr_71, synerrstr_64, synerrstr_65, synerrstr_66, synerrstr_67, synerrstr_68, synerrstr_69, synerrstr_70, synerrstr_71,
synerrstr_72, synerrstr_73, synerrstr_74, synerrstr_75, synerrstr_76, synerrstr_77, synerrstr_78 synerrstr_72, synerrstr_73, synerrstr_74, synerrstr_75, synerrstr_76, synerrstr_77, synerrstr_78, synerrstr_79,
synerrstr_80
}; };
#endif #endif
/* END: GENERATED WITH generr.moo */ /* END: GENERATED WITH generr.moo */

View File

@ -1971,6 +1971,8 @@ enum moo_synerrnum_t
MOO_SYNERR_PFNUMINVAL, /* wrong primitive function number */ MOO_SYNERR_PFNUMINVAL, /* wrong primitive function number */
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_PVIDINVAL, /* wrong primitive value identifier */
MOO_SYNERR_PVIMPBANNED, /* primitive value load from module not allowed */
MOO_SYNERR_MODIMPFAIL, /* failed to import module */ MOO_SYNERR_MODIMPFAIL, /* failed to import module */
MOO_SYNERR_INCLUDE, /* #include error */ MOO_SYNERR_INCLUDE, /* #include error */
MOO_SYNERR_PRAGMAINVAL, /* wrong pragma name */ MOO_SYNERR_PRAGMAINVAL, /* wrong pragma name */