Merge pull request #172 from alliedmodders/fix-setters

Fix a crash when properties have setters but not getters.
This commit is contained in:
David Anderson 2014-10-29 23:09:23 -07:00
commit a7303568d6
4 changed files with 27 additions and 3 deletions

View File

@ -3686,8 +3686,7 @@ int parse_property_accessor(const typeinfo_t *type, methodmap_t *map, methodmap_
// Must have one extra argument taking the return type.
arginfo *arg = &target->dim.arglist[1];
if (arg->ident == 0 ||
arg->ident != iVARIABLE ||
if (arg->ident != iVARIABLE ||
arg->hasdefault ||
arg->numtags != 1 ||
arg->tags[0] != type->tag)

View File

@ -2174,7 +2174,7 @@ restart:
rvalue(lval1);
clear_value(lval1);
lval1->ident = iACCESSOR;
lval1->tag = method->getter->tag;
lval1->tag = method->property_tag();
lval1->accessor = method;
lvalue = TRUE;
goto restart;

View File

@ -85,6 +85,19 @@ typedef struct methodmap_method_s
symbol *target;
symbol *getter;
symbol *setter;
int property_tag() const {
assert(getter || setter);
if (getter)
return getter->tag;
arginfo *thisp = &setter->dim.arglist[0];
if (thisp->ident == 0)
return pc_tag_void;
arginfo *valp = &setter->dim.arglist[1];
if (valp->ident != iVARIABLE || valp->numtags != 1)
return pc_tag_void;
return valp->tags[0];
}
} methodmap_method_t;
typedef struct methodmap_s

View File

@ -0,0 +1,12 @@
methodmap Crab
{
property int X {
public native set(int value);
}
}
public main()
{
Crab crab;
crab.X = 12;
}