adding default values for beyond the array.length access

This commit is contained in:
Brahma Giri Abhijith Chatra 2017-01-08 19:08:09 -08:00
parent 91321dab83
commit c938618d29

View File

@ -152,7 +152,6 @@ namespace pxt {
{
return data[i];
}
error(ERR_OUT_OF_BOUNDS);
return Segment::DefaultValue;
}
@ -275,7 +274,6 @@ namespace pxt {
--length;
return value;
}
error(ERR_OUT_OF_BOUNDS);
return Segment::DefaultValue;
}
@ -304,7 +302,6 @@ namespace pxt {
#endif
return ret;
}
error(ERR_OUT_OF_BOUNDS);
return Segment::DefaultValue;
}
@ -386,8 +383,6 @@ namespace pxt {
}
uint32_t RefCollection::getAt(int i)
{
if (head.isValidIndex(i))
{
uint32_t tmp = head.get(i);
if (isRef())
@ -396,20 +391,9 @@ namespace pxt {
}
return tmp;
}
else
{
error(ERR_OUT_OF_BOUNDS);
return 0;
}
}
uint32_t RefCollection::removeAt(int i)
{
if (!head.isValidIndex((uint32_t)i))
{
error(ERR_OUT_OF_BOUNDS);
return 0;
}
if (isRef())
{
decr(head.get(i));
@ -418,8 +402,6 @@ namespace pxt {
}
void RefCollection::insertAt(int i, uint32_t value)
{
if (((uint32_t)i) < length())
{
head.insert(i, value);
if (isRef())
@ -427,11 +409,6 @@ namespace pxt {
incr(value);
}
}
else
{
error(ERR_OUT_OF_BOUNDS);
}
}
void RefCollection::setAt(int i, uint32_t value)
{