+
+static int flags2access(int flags)
+{
+ int access = 0;
+ if(flags&FLAG_PUBLIC) {
+ if(access&(FLAG_PRIVATE|FLAG_PROTECTED|FLAG_PACKAGEINTERNAL))
+ syntaxerror("invalid combination of access levels");
+ access = ACCESS_PACKAGE;
+ } else if(flags&FLAG_PRIVATE) {
+ if(access&(FLAG_PUBLIC|FLAG_PROTECTED|FLAG_PACKAGEINTERNAL))
+ syntaxerror("invalid combination of access levels");
+ access = ACCESS_PRIVATE;
+ } else if(flags&FLAG_PROTECTED) {
+ if(access&(FLAG_PUBLIC|FLAG_PRIVATE|FLAG_PACKAGEINTERNAL))
+ syntaxerror("invalid combination of access levels");
+ access = ACCESS_PROTECTED;
+ } else {
+ access = ACCESS_PACKAGEINTERNAL;
+ }
+ return access;
+}
+
+
+static memberinfo_t*registerfunction(enum yytokentype getset, int flags, char*name, params_t*params, classinfo_t*return_type, int slot)
+{
+ memberinfo_t*minfo = 0;
+ if(!state->cls) {
+ //package method
+ minfo = memberinfo_register_global(flags2access(flags), state->package, name, MEMBER_METHOD);
+ minfo->return_type = return_type;
+ } else if(getset != KW_GET && getset != KW_SET) {
+ //class method
+ if((minfo = registry_findmember(state->cls->info, name, 0))) {
+ if(minfo->parent == state->cls->info) {
+ syntaxerror("class already contains a member/method called '%s'", name);
+ } else if(!minfo->parent) {
+ syntaxerror("internal error: overriding method %s, which doesn't have parent", name);
+ } else {
+ if(!(minfo->flags&(FLAG_STATIC|FLAG_PRIVATE)))
+ syntaxerror("function %s already exists in superclass. Did you forget the 'override' keyword?");
+ }
+ }
+ minfo = memberinfo_register(state->cls->info, name, MEMBER_METHOD);
+ minfo->return_type = return_type;
+ // getslot on a member slot only returns "undefined", so no need
+ // to actually store these
+ //state->minfo->slot = state->method->abc->method->trait->slot_id;
+ } else {
+ //class getter/setter
+ int gs = getset==KW_GET?MEMBER_GET:MEMBER_SET;
+ classinfo_t*type=0;
+ if(getset == KW_GET)
+ type = return_type;
+ else if(params->list)
+ type = params->list->param->type;
+ // not sure wether to look into superclasses here, too
+ if((minfo=registry_findmember(state->cls->info, name, 0))) {
+ if(minfo->kind & ~(MEMBER_GET|MEMBER_SET))
+ syntaxerror("class already contains a member or method called '%s'", name);
+ if(minfo->kind & gs)
+ syntaxerror("getter/setter for '%s' already defined", name);
+ /* make a setter or getter into a getset */
+ minfo->kind |= gs;
+ if(!minfo->type)
+ minfo->type = type;
+ else
+ if(type && minfo->type != type)
+ syntaxerror("different type in getter and setter");
+ } else {
+ minfo = memberinfo_register(state->cls->info, name, gs);
+ minfo->type = type;
+ }
+ /* can't assign a slot as getter and setter might have different slots */
+ //minfo->slot = slot;
+ }
+ if(flags&FLAG_STATIC) minfo->flags |= FLAG_STATIC;
+ if(flags&FLAG_PUBLIC) minfo->flags |= FLAG_PUBLIC;
+ if(flags&FLAG_PRIVATE) minfo->flags |= FLAG_PRIVATE;
+ if(flags&FLAG_PROTECTED) minfo->flags |= FLAG_PROTECTED;
+ if(flags&FLAG_PACKAGEINTERNAL) minfo->flags |= FLAG_PACKAGEINTERNAL;
+ if(flags&FLAG_OVERRIDE) minfo->flags |= FLAG_OVERRIDE;
+ return minfo;
+}
+
+static void innerfunction(char*name, params_t*params, classinfo_t*return_type)