"use strict";
/* @flow */

const Value = require('../Value');

let serial = 0;

//TODO: We should call this a PropertyDescriptor, not a variable.

class PropertyDescriptor {
	constructor(value) {
		this.value = value;
		this.serial = serial++;
		this.configurable = true;
		this.enumerable = true;
		this.writeable = true;
	}

	set(value) {
		if ( !this.writeable ) return;
		this.value = value;
	}

	*getValue(thiz) {
		thiz = thiz || Value.null;
		if ( this.getter ) {
			return yield * this.getter.call(thiz, []);
		}
		return this.value;
	}

	*setValue(thiz, to) {
		if ( !this.writeable ) return;
		thiz = thiz || Value.null;
		if ( this.getter ) {
			return yield * this.setter.call(thiz, [to]);
		}
		this.value = to;
		return this.value;
	}
}

module.exports = PropertyDescriptor;
@@ -566,41 +566,8 @@
 ) %7B%0A
-%09%09if ( !this.writeable ) return;%0A
 %09%09th
@@ -666,16 +666,60 @@
 %5D);%0A%09%09%7D%0A
+%09%09if ( !this.writeable ) return this.value;%0A
 %09%09this.v

Call setter even if object isn't writable.