Fix a crash when properties have setters but not getters.

This commit is contained in:
David Anderson 2014-10-29 20:42:24 -07:00
parent 86ddf1fea0
commit e7fc06910b
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. // Must have one extra argument taking the return type.
arginfo *arg = &target->dim.arglist[1]; arginfo *arg = &target->dim.arglist[1];
if (arg->ident == 0 || if (arg->ident != iVARIABLE ||
arg->ident != iVARIABLE ||
arg->hasdefault || arg->hasdefault ||
arg->numtags != 1 || arg->numtags != 1 ||
arg->tags[0] != type->tag) arg->tags[0] != type->tag)

View File

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

View File

@ -85,6 +85,19 @@ typedef struct methodmap_method_s
symbol *target; symbol *target;
symbol *getter; symbol *getter;
symbol *setter; 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; } methodmap_method_t;
typedef struct methodmap_s 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;
}