Difference between revisions of "NodeSpace.h"
m |
m |
||
Line 1: | Line 1: | ||
#define ROOT 0 | #define ROOT 0 | ||
+ | #define NULL 0 | ||
#define CURRENT 1 | #define CURRENT 1 | ||
#define AND 2 | #define AND 2 | ||
Line 7: | Line 8: | ||
#define DESKTOP 6 | #define DESKTOP 6 | ||
− | typedef int node; | + | typedef int node; // node: a type for referring to nodes |
− | typedef void (*code)(); | + | typedef void (*code)(); // code: a type for referring to functions |
node nodeTraverse(node subject, node path) { | node nodeTraverse(node subject, node path) { | ||
Line 47: | Line 48: | ||
// - returns false if no more to reduce | // - returns false if no more to reduce | ||
int nodeReduce(node subject) { | int nodeReduce(node subject) { | ||
− | |||
node cur; | node cur; | ||
− | if ((cur = nodeGetValue(subject, CURRENT)) == | + | code state; |
− | nodeSetValue(subject, CURRENT, nodeGetValue(cur, AND)); | + | // return if no CURRENT node |
− | if (nodeGetValue(cur, CODE)) { | + | if ((cur = nodeGetValue(subject, CURRENT)) == NULL) return; |
− | code | + | nodeSetValue(subject, CURRENT, nodeGetValue(cur, AND)); // test AND first? |
− | + | if (nodeGetValue(cur, CODE) != NULL) { | |
+ | state = (code)nodeGetState(cur); | ||
+ | state(); | ||
// Later this must declare and build if no function-reference | // Later this must declare and build if no function-reference | ||
// replace self in loop with n.THEN if non-zero | // replace self in loop with n.THEN if non-zero |
Revision as of 07:56, 6 July 2006
- define ROOT 0
- define NULL 0
- define CURRENT 1
- define AND 2
- define CODE 3
- define THEN 4
- define NETWORK 5
- define DESKTOP 6
typedef int node; // node: a type for referring to nodes typedef void (*code)(); // code: a type for referring to functions
node nodeTraverse(node subject, node path) { // select node wco selNode return subject; }
// set nodal value of node/path // - path is array-of-node node nodeGetValue(node subject, node path) { node value; return value; }
void nodeSetValue(node subject, node path, node value) { }
void* nodeGetState(node subject) { void* state; return state; }
void nodeSetState(node subject, void* state) { }
node nodeInsertKey(node subject, node key) { node instance; return instance; }
void nodeRemoveKey(node subject, node key) { }
// - Consumes quanta of execution // - Creates History from change events // - Builds, declares and executes functionality // - Should reduction handle cyles (current-cycle etc), or a separate root-thread // - returns false if no more to reduce int nodeReduce(node subject) { node cur; code state; // return if no CURRENT node if ((cur = nodeGetValue(subject, CURRENT)) == NULL) return; nodeSetValue(subject, CURRENT, nodeGetValue(cur, AND)); // test AND first? if (nodeGetValue(cur, CODE) != NULL) { state = (code)nodeGetState(cur); state(); // Later this must declare and build if no function-reference // replace self in loop with n.THEN if non-zero } else nodeReduce(cur); return 1; }