kopia lustrzana https://github.com/backface/turtlestitch
remove experimental list methods for object-use
rodzic
3f23cc9fce
commit
176936a211
|
@ -3367,3 +3367,7 @@ Fixes:
|
|||
170209
|
||||
------
|
||||
* Blocks: fixed #1406
|
||||
|
||||
170214
|
||||
------
|
||||
* Lists: remove experimental methods for object-use
|
||||
|
|
64
lists.js
64
lists.js
|
@ -62,7 +62,7 @@ CellMorph, ArrowMorph, MenuMorph, snapEquals, Morph, isNil, localize,
|
|||
MorphicPreferences, TableDialogMorph, SpriteBubbleMorph, SpeechBubbleMorph,
|
||||
TableFrameMorph, TableMorph, Variable, isSnapObject*/
|
||||
|
||||
modules.lists = '2017-January-31';
|
||||
modules.lists = '2017-February-14';
|
||||
|
||||
var List;
|
||||
var ListWatcherMorph;
|
||||
|
@ -314,68 +314,6 @@ List.prototype.version = function (startRow, rows) {
|
|||
return v;
|
||||
};
|
||||
|
||||
// List object use (hierarchical dictionary)
|
||||
// *very* experimental and ineffective as hell
|
||||
// don't rely on any of this to stay around, -Jens
|
||||
|
||||
function snapObject(parent) {
|
||||
return new List([new List(['__proto__', parent])]);
|
||||
}
|
||||
|
||||
List.prototype.setAttribute = function (key, value) {
|
||||
var assoc = this.assoc(key);
|
||||
if (assoc) {
|
||||
assoc.put(value, 2);
|
||||
this.changed();
|
||||
} else {
|
||||
this.add(new List([key, value]));
|
||||
}
|
||||
};
|
||||
|
||||
List.prototype.getAttribute = function (key) {
|
||||
var assoc = this.assoc(key),
|
||||
proto;
|
||||
if (assoc) {
|
||||
return assoc.at(2);
|
||||
}
|
||||
proto = this.getAttribute('__proto__');
|
||||
if (proto) {
|
||||
return proto.getAttribute(key);
|
||||
}
|
||||
throw new Error('unknown attribute: ' + key.toString());
|
||||
};
|
||||
|
||||
List.prototype.removeAttribute = function (key) {
|
||||
var i, assoc;
|
||||
for (i = 1; i <= this.length(); i += 1) {
|
||||
assoc = this.at(i);
|
||||
if (snapEquals(assoc.at(1), key)) {
|
||||
this.remove(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
List.prototype.attributes = function () {
|
||||
var i, arr = [];
|
||||
for (i = 1; i <= this.length(); i += 1) {
|
||||
arr.push(this.at(i).at(1));
|
||||
}
|
||||
return new List(arr);
|
||||
};
|
||||
|
||||
List.prototype.assoc = function (key) {
|
||||
// private
|
||||
var i, assoc;
|
||||
for (i = 1; i <= this.length(); i += 1) {
|
||||
assoc = this.at(i);
|
||||
if (snapEquals(assoc.at(1), key)) {
|
||||
return assoc;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// List conversion:
|
||||
|
||||
List.prototype.asArray = function () {
|
||||
|
|
Ładowanie…
Reference in New Issue