Difference between revisions of "Peer-nodal.as"
(Make more OO with node prototype) |
(Start reduction method using get/set methods) |
||
Line 4: | Line 4: | ||
// so either add get/set which use resolve, or remove object-freedom and have only .data | // so either add get/set which use resolve, or remove object-freedom and have only .data | ||
− | // NODAL PROPERTIES | + | // NODAL PROPERTIES & CORE NODAL CONCEPTS |
// idcount is a accumulating-only counter for locally-unique-id number | // idcount is a accumulating-only counter for locally-unique-id number | ||
// nodes is the current number of instantiated node objects | // nodes is the current number of instantiated node objects | ||
// queue is the root reduction queue | // queue is the root reduction queue | ||
− | + | ROOT = { queue: [], idcount: 0, nodes: 0 }; | |
+ | NEXT = new node(); | ||
+ | PREV = new node(); | ||
+ | FUNC = new node(); | ||
+ | FOCUS = new node(); | ||
// NODE OBJECT | // NODE OBJECT | ||
function node() { | function node() { | ||
− | + | ROOT.nodes++; | |
− | this.id = | + | this.id = ROOT.idcount++; |
− | this.queue = []; | + | this.queue = []; // get rid of this, back to nodal-linked-list |
}; | }; | ||
Line 31: | Line 35: | ||
node.prototype.get() { | node.prototype.get() { | ||
− | return value; | + | return value; // returns a node-ref or an "external" kind like method or object |
}; | }; | ||
Line 51: | Line 55: | ||
// the structures necessary to build the fucntion are child assocs too | // the structures necessary to build the fucntion are child assocs too | ||
node.prototype.reduce = function() { | node.prototype.reduce = function() { | ||
− | var | + | var ptr = this; |
− | + | ||
+ | // Queue rotation | ||
+ | var focus = ptr.get( [FOCUS] ); | ||
+ | ptr.set( [FOCUS], ptr.get( [FOCUS,NEXT] ) ); | ||
− | + | // If there's a local function declaration, execute | |
− | + | if ( func = ptr.get( [FUNC] ) ) { | |
− | // | + | ref = func.call |
+ | // also call class.reduce() | ||
+ | }; | ||
− | } | + | // if not, send the quanta downstairs if there's a basement |
+ | else if ( ) { | ||
+ | }; | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
}; | }; |
Revision as of 09:06, 8 April 2006
// ISSUES // - associations (maintained class:instance relationships) // - get should use class content as default - resolve() doesn't // so either add get/set which use resolve, or remove object-freedom and have only .data
// NODAL PROPERTIES & CORE NODAL CONCEPTS // idcount is a accumulating-only counter for locally-unique-id number // nodes is the current number of instantiated node objects // queue is the root reduction queue ROOT = { queue: [], idcount: 0, nodes: 0 }; NEXT = new node(); PREV = new node(); FUNC = new node(); FOCUS = new node();
// NODE OBJECT function node() {
ROOT.nodes++; this.id = ROOT.idcount++; this.queue = []; // get rid of this, back to nodal-linked-list
};
// NODAL METHODS // - the delete-list is only needed for limited list-space env // - Actionscript failed ref-as-hashkey test, // so we use a id (locally unique identifier) as a lookup-key // - no delete currently // - just get/set properties with normal object-accessor way // - but keep all hierarchy nodal
node.prototype.set( value ) { };
node.prototype.get() { return value; // returns a node-ref or an "external" kind like method or object };
// Resolve creates if non existent and returns reference to result node.prototype.resolve = function( path ) { var context = this; while( path.length ) { var key = path.shift(); context = context[key.id] == null ? context[key.id] = new node() : context[ key.id ]; } return context; };
// Consume one quanta // - each quantum is actually two, one for local instance, one for global class // - all instance-loops work by going cd this.current then assigning this.current.next to it // when a function executes, it can update the loop at that location (equiv to array.push) // - a functions parameters (and even further methods and tools) are child associations // the structures necessary to build the fucntion are child assocs too node.prototype.reduce = function() { var ptr = this;
// Queue rotation var focus = ptr.get( [FOCUS] ); ptr.set( [FOCUS], ptr.get( [FOCUS,NEXT] ) );
// If there's a local function declaration, execute if ( func = ptr.get( [FUNC] ) ) { ref = func.call // also call class.reduce() };
// if not, send the quanta downstairs if there's a basement else if ( ) { };
};