added more code to check interface conformance
This commit is contained in:
parent
d638adc434
commit
9656d87816
@ -253,7 +253,7 @@ static int compile_class_definition (moo_t* moo, int class_type);
|
|||||||
static int compile_block_statement (moo_t* moo);
|
static int compile_block_statement (moo_t* moo);
|
||||||
static int compile_method_statement (moo_t* moo);
|
static int compile_method_statement (moo_t* moo);
|
||||||
static int compile_method_expression (moo_t* moo, int pop);
|
static int compile_method_expression (moo_t* moo, int pop);
|
||||||
static int add_literal (moo_t* moo, moo_oop_t lit, moo_oow_t* index);
|
static MOO_INLINE int add_literal (moo_t* moo, moo_oop_t lit, moo_oow_t* index);
|
||||||
static moo_oop_t token_to_literal (moo_t* moo, int rdonly);
|
static moo_oop_t token_to_literal (moo_t* moo, int rdonly);
|
||||||
static moo_oop_t find_element_in_compiling_pooldic (moo_t* moo, const moo_oocs_t* name);
|
static moo_oop_t find_element_in_compiling_pooldic (moo_t* moo, const moo_oocs_t* name);
|
||||||
|
|
||||||
@ -925,7 +925,7 @@ static MOO_INLINE void unget_char (moo_t* moo, const moo_iolxc_t* c)
|
|||||||
static int get_char (moo_t* moo)
|
static int get_char (moo_t* moo)
|
||||||
{
|
{
|
||||||
moo_ooi_t n;
|
moo_ooi_t n;
|
||||||
moo_ooci_t lc, ec;
|
moo_ooci_t lc;
|
||||||
|
|
||||||
if (moo->c->nungots > 0)
|
if (moo->c->nungots > 0)
|
||||||
{
|
{
|
||||||
@ -7785,9 +7785,13 @@ static int process_class_interfaces (moo_t* moo)
|
|||||||
if (add_oop_to_oopbuf_nodup(moo, &cc->ifces, var.u.gbl->value, &ifce_index) <= -1) return -1;
|
if (add_oop_to_oopbuf_nodup(moo, &cc->ifces, var.u.gbl->value, &ifce_index) <= -1) return -1;
|
||||||
if (ifce_index < old_ifce_count)
|
if (ifce_index < old_ifce_count)
|
||||||
{
|
{
|
||||||
|
/* add_oop_to_oopbuf_nodup() returns the index to an existing item
|
||||||
|
* if it's found. the index should be between 0 and the previous count - 1 inclusive.
|
||||||
|
* the index returned will be the previous count if it's added this time */
|
||||||
moo_setsynerrbfmt (moo, MOO_SYNERR_NAMEDUPL, TOKEN_LOC(moo), TOKEN_NAME(moo), "duplicate interface name");
|
moo_setsynerrbfmt (moo, MOO_SYNERR_NAMEDUPL, TOKEN_LOC(moo), TOKEN_NAME(moo), "duplicate interface name");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (find_word_in_string(&cc->ifce_names, TOKEN_NAME(moo), MOO_NULL) >= 0)
|
if (find_word_in_string(&cc->ifce_names, TOKEN_NAME(moo), MOO_NULL) >= 0)
|
||||||
{
|
{
|
||||||
@ -7816,6 +7820,12 @@ static int process_class_interfaces (moo_t* moo)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int class_implements_interface (moo_t* moo, moo_oop_class_t _class, moo_oop_interface_t ifce)
|
||||||
|
{
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int check_class_interface_conformance (moo_t* moo)
|
static int check_class_interface_conformance (moo_t* moo)
|
||||||
{
|
{
|
||||||
moo_cunit_class_t* cc = (moo_cunit_class_t*)moo->c->cunit;
|
moo_cunit_class_t* cc = (moo_cunit_class_t*)moo->c->cunit;
|
||||||
@ -7823,13 +7833,20 @@ static int check_class_interface_conformance (moo_t* moo)
|
|||||||
|
|
||||||
for (i = 0; i < cc->ifces.count; i++)
|
for (i = 0; i < cc->ifces.count; i++)
|
||||||
{
|
{
|
||||||
// TODO: check conformance...
|
moo_oop_interface_t ifce = (moo_oop_interface_t)cc->ifces.ptr[i];
|
||||||
|
if (!class_implements_interface(moo, cc->self_oop, ifce))
|
||||||
|
{
|
||||||
|
moo_setsynerrbfmt (moo, MOO_SYNERR_ARGNAMEDUPL, &cc->fqn_loc, &cc->fqn,
|
||||||
|
"%.*js not implementing interface %.*js",
|
||||||
|
cc->fqn.len, cc->fqn.ptr,
|
||||||
|
MOO_OBJ_GET_SIZE(ifce->name), MOO_OBJ_GET_CHAR_SLOT(ifce->name));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int __compile_class_definition (moo_t* moo, int class_type)
|
static int __compile_class_definition (moo_t* moo, int class_type)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -7886,7 +7903,6 @@ static int __compile_class_definition (moo_t* moo, int class_type)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* [NOTE] TOKEN_NAME(moo) doesn't contain the full name if it's nested
|
/* [NOTE] TOKEN_NAME(moo) doesn't contain the full name if it's nested
|
||||||
* inside a class. it is merely a name that appeared in the source
|
* inside a class. it is merely a name that appeared in the source
|
||||||
* code.
|
* code.
|
||||||
|
Loading…
Reference in New Issue
Block a user