diff --git a/moo/lib/comp.c b/moo/lib/comp.c index 5348493..6678d51 100644 --- a/moo/lib/comp.c +++ b/moo/lib/comp.c @@ -51,7 +51,8 @@ enum class_mod_t { CLASS_INDEXED = (1 << 0), - CLASS_LIMITED = (1 << 1) + CLASS_LIMITED = (1 << 1), + CLASS_FINAL = (1 << 2) }; enum var_type_t @@ -102,6 +103,7 @@ static struct voca_t { 9, { 'e','x','c','e','p','t','i','o','n' } }, { 6, { 'e','x','t','e','n','d' } }, { 5, { 'f','a','l','s','e' } }, + { 6, { '#','f','i','n','a','l' } }, { 4, { 'f','r','o','m' } }, { 9, { '#','h','a','l','f','w','o','r','d' } }, { 2, { 'i','f' } }, @@ -159,6 +161,7 @@ enum voca_id_t VOCA_EXCEPTION, VOCA_EXTEND, VOCA_FALSE, + VOCA_FINAL_S, VOCA_FROM, VOCA_HALFWORD_S, VOCA_IF, @@ -6630,6 +6633,16 @@ static int __compile_class_definition (moo_t* moo, int extend) if (_set_class_indexed_type (moo, MOO_OBJ_TYPE_LIWORD) <= -1) return -1; GET_TOKEN (moo); } + else if (is_token_symbol(moo, VOCA_FINAL_S)) + { + if (moo->c->cls.flags & CLASS_FINAL) + { + set_syntax_error (moo, MOO_SYNERR_MODIFIERDUPL, TOKEN_LOC(moo), TOKEN_NAME(moo)); + return -1; + } + moo->c->cls.flags |= CLASS_FINAL; + GET_TOKEN(moo); + } else if (is_token_symbol(moo, VOCA_LIMITED_S)) { if (moo->c->cls.flags & CLASS_LIMITED) diff --git a/moo/lib/moo-prv.h b/moo/lib/moo-prv.h index c96ec2d..953b192 100644 --- a/moo/lib/moo-prv.h +++ b/moo/lib/moo-prv.h @@ -89,17 +89,27 @@ # else # define MOO_MEMCMP(dst,src,size) memcmp(dst,src,size) # endif -#elif defined(__GNUC__) && (__GNUC__ >= 3 || (defined(__GNUC_MINOR) && __GNUC__ == 2 && __GNUC_MINOR__ >= 91)) - /* gcc 2.91 or higher */ -# define MOO_MEMSET(dst,src,size) __builtin_memset(dst,src,size) -# define MOO_MEMCPY(dst,src,size) __builtin_memcpy(dst,src,size) -# define MOO_MEMMOVE(dst,src,size) __builtin_memmove(dst,src,size) -# define MOO_MEMCMP(dst,src,size) __builtin_memcmp(dst,src,size) #else -# define MOO_MEMSET(dst,src,size) memset(dst,src,size) -# define MOO_MEMCPY(dst,src,size) memcpy(dst,src,size) -# define MOO_MEMMOVE(dst,src,size) memmove(dst,src,size) -# define MOO_MEMCMP(dst,src,size) memcmp(dst,src,size) +# if defined(HAVE___BUILTIN_MEMSET) +# define MOO_MEMSET(dst,src,size) __builtin_memset(dst,src,size) +# else +# define MOO_MEMSET(dst,src,size) memset(dst,src,size) +# endif +# if defined(HAVE___BUILTIN_MEMCPY) +# define MOO_MEMCPY(dst,src,size) __builtin_memcpy(dst,src,size) +# else +# define MOO_MEMCPY(dst,src,size) memcpy(dst,src,size) +# endif +# if defined(HAVE___BUILTIN_MEMMOVE) +# define MOO_MEMMOVE(dst,src,size) __builtin_memmove(dst,src,size) +# else +# define MOO_MEMMOVE(dst,src,size) memmove(dst,src,size) +# endif +# if defined(HAVE___BUILTIN_MEMCMP) +# define MOO_MEMCMP(dst,src,size) __builtin_memcmp(dst,src,size) +# else +# define MOO_MEMCMP(dst,src,size) memcmp(dst,src,size) +# endif #endif