The attached patch implements the current() function in Sablotron.
It works for me, but I haven't tested it comprehensively.
There's a bit of fuzz because I've manually removed irrelevant
changes from the patch.
If you try it, let me know if it works for you too...
.robin.
--
Are we not drawn onward, we few, drawn onward to new era?
diff -aur Sablot-0.40/Sablot/context.cpp Sablot-0.40-patched/Sablot/context.cpp
--- Sablot-0.40/Sablot/context.cpp Fri Jun 30 11:23:25 2000
+++ Sablot-0.40-patched/Sablot/context.cpp Wed Jul 5 02:24:18 2000
@@ -67,6 +67,7 @@
Context::Context()
{
array = new CList;
+ currentNode = NULL;
position = -1;
}
@@ -85,6 +86,19 @@
return NULL;
};
+Vertex *Context::getCurrentNode() const
+{
+ if (currentNode)
+ return currentNode;
+ else
+ return current();
+}
+
+void Context::setCurrentNode(Vertex * v)
+{
+ currentNode = v;
+}
+
void Context::reset()
{
if (!array -> number())
@@ -152,6 +166,7 @@
{
Context *newc = new Context;
delete NZ(newc -> array);
+ newc -> currentNode = currentNode;
newc -> array = array;
array -> incRefCount();
newc -> reset();
diff -aur Sablot-0.40/Sablot/context.h Sablot-0.40-patched/Sablot/context.h
--- Sablot-0.40/Sablot/context.h Fri Jun 30 11:23:25 2000
+++ Sablot-0.40-patched/Sablot/context.h Wed Jul 5 02:08:55 2000
@@ -68,6 +68,10 @@
~Context();
Vertex
*current() const;
+ Vertex
+ *getCurrentNode() const;
+ void
+ setCurrentNode(Vertex *);
void
reset();
Bool
@@ -99,6 +103,8 @@
protected:
CList
*array;
+ Vertex
+ *currentNode;
};
#endif //ifndef ContextHIncl
diff -aur Sablot-0.40/Sablot/expr.cpp Sablot-0.40-patched/Sablot/expr.cpp
--- Sablot-0.40/Sablot/expr.cpp Fri Jun 30 11:23:25 2000
+++ Sablot-0.40-patched/Sablot/expr.cpp Wed Jul 5 14:56:07 2000
@@ -868,7 +868,9 @@
Vertex
*baseV = (*c)[baseIndex],
*v;
+ Vertex *currentNode = c->getCurrentNode();
c = new Context;
+ c->setCurrentNode(currentNode);
switch(ax)
{
@@ -2731,6 +2734,14 @@
else
retxpr.setAtom(Str(""));
}; break;
+
+ case EXFF_CURRENT:
+ {
+ Context *newc = new Context;
+ newc -> set (c -> getCurrentNode());
+ retxpr.setAtom (newc);
+ }; break;
+
default:
Err1(ET_FUNC_NOT_SUPPORTED, getFuncName(functor));
}
@@ -2746,7 +2757,8 @@
c = new Context;
return OK;
};
- E( args[0] -> createContext(myctxt = c, baseNdx) );
+ ( myctxt = c ) -> setCurrentNode ( c->getCurrentNode() );
+ E( args[0] -> createContext(myctxt, baseNdx) );
E( createLPContextSum(1, c = myctxt) );
delete myctxt;
return OK;
diff -aur Sablot-0.40/Sablot/verts.cpp Sablot-0.40-patched/Sablot/verts.cpp
--- Sablot-0.40/Sablot/verts.cpp Fri Jun 30 11:23:25 2000
+++ Sablot-0.40-patched/Sablot/verts.cpp Wed Jul 5 14:57:17 2000
@@ -1106,6 +1106,7 @@
if (c -> isFinished())
return OK;
+ c->setCurrentNode(NULL);
situation.pushCurrV(this);
Vertex *v = c -> current();
assert(v);