richter 01/10/23 12:35:13
Modified: . Tag: Embperl2c epdom.c epdom.h
Log:
Embperl 2 - tree structure rewrite
Revision Changes Path
No revision
No revision
1.4.2.54 +124 -21 embperl/Attic/epdom.c
Index: epdom.c
===================================================================
RCS file: /home/cvs/embperl/Attic/epdom.c,v
retrieving revision 1.4.2.53
retrieving revision 1.4.2.54
diff -u -r1.4.2.53 -r1.4.2.54
--- epdom.c 2001/10/22 13:52:16 1.4.2.53
+++ epdom.c 2001/10/23 19:35:13 1.4.2.54
@@ -9,7 +9,7 @@
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: epdom.c,v 1.4.2.53 2001/10/22 13:52:16 richter Exp $
+# $Id: epdom.c,v 1.4.2.54 2001/10/23 19:35:13 richter Exp $
#
###################################################################################*/
@@ -1014,12 +1014,28 @@
return pDomTree -> xNdx ;
}
-/* ------------------------------------------------------------------------ */
+/*!------------------------------------------------------------------------ */
/* */
/* DomTree_checkpoint */
/* */
+/* \_en */
/* Compare checkpoint from programm execution with list build during */
-/* compilation and change the DomTree and repeat level accordingly */
+/* compilation and change the DomTree and repeat level according to the */
+/* programm flow */
+/* */
+/* @param r Embperl request data */
+/* @param xDomTree current DomTree we are working on */
+/* @param nRunCheckpoint Number of checkpoint that was just executed */
+/* \_ */
+/* \_de */
+/* Vergeleicht den Checkpoint von der Programmausf�hrung mit dem Checkpoint */
+/* beim Compilieren und �ndert den DomTree entsprechend dem Programmflu� ab */
+/* */
+/* @param r Embperl Requestdaten */
+/* @param xDomTree akuteller DomTree der bearbeitet wird */
+/* @param nRunCheckpoint Nummer des Checkpoints der gerade abgearbeitet */
+/* wurde */
+/* \_ */
/* */
/* ------------------------------------------------------------------------ */
@@ -1047,8 +1063,8 @@
tNodeData * pRunNode = Node_selfLevel (pDomTree,
pCheckpoints[nRunCheckpoint].xNode, r -> nCurrRepeatLevel) ;
tNodeData * pPrevNode = Node_selfPreviousSibling (pDomTree,
pCompileNode, r -> nCurrRepeatLevel) ;
- tNodeData * pCompileParent = Node_selfParentNode (pDomTree, pCompileNode, r
-> nCurrRepeatLevel) ;
- tNodeData * pRunParent = Node_selfParentNode (pDomTree, pRunNode, r ->
nCurrRepeatLevel) ;
+ tNodeData * pCompileParent = NodeAttr_selfParentNode (pDomTree,
pCompileNode, r -> nCurrRepeatLevel) ;
+ tNodeData * pRunParent = NodeAttr_selfParentNode (pDomTree, pRunNode, r
-> nCurrRepeatLevel) ;
if (pPrevNode)
pPrevNode = Node_selfCondCloneNode (pDomTree, pPrevNode, r ->
nCurrRepeatLevel) ;
@@ -1072,14 +1088,37 @@
}
else if (pCompileParent && pRunParent)
{
- tNodeData * pCompileParent2 = Node_selfParentNode (pDomTree,
pCompileParent, r -> nCurrRepeatLevel) ;
- tNodeData * pRunParent2 = Node_selfParentNode (pDomTree,
pRunParent, r -> nCurrRepeatLevel) ;
+ tNodeData * pCompileParent2 = NodeAttr_selfParentNode (pDomTree,
pCompileParent, r -> nCurrRepeatLevel) ;
+ tNodeData * pRunParent2 = NodeAttr_selfParentNode (pDomTree,
pRunParent, r -> nCurrRepeatLevel) ;
if (pCompileParent2 == pRunParent2)
{
- pPrevNode -> xNext = Node_selfFirstChild (pDomTree, pCompileParent,
, r -> nCurrRepeatLevel) -> xNdx ;
+ if (pRunParent -> nType != ntypAttr && pCompileParent -> nType !=
ntypAttr)
+ {
+ pRunParent = Node_selfCondCloneNode (pDomTree, pRunParent, r ->
nCurrRepeatLevel) ;
+ pCompileParent = Node_selfCondCloneNode (pDomTree, pCompileParent,
r -> nCurrRepeatLevel) ;
+ pRunParent -> xPrev = pCompileParent -> xNdx ;
+ pCompileParent -> xNext = pRunParent -> xNdx ;
+ }
+ else
+ {
+ int nCompile = Attr_selfAttrNum(((tAttrData *)pCompileParent)) ;
+ int nRun = Attr_selfAttrNum(((tAttrData *)pRunParent)) ;
+ int i ;
+
+ pCompileParent2 = Node_selfCondCloneNode (pDomTree,
pCompileParent2, r -> nCurrRepeatLevel) ;
+
+ for (i = nRun - 1 ; i > nCompile; i--)
+ {
+ tAttrData * pAttr = Element_selfGetNthAttribut (pDomTree,
pCompileParent2, i) ;
+ /* lprintf (r, "remove attr #%d flags=%x node=%d\n", i, pAttr
-> bFlags, pAttr ->xNdx) ; */
+ Element_selfRemoveNthAttribut (pDomTree, pCompileParent2, r ->
nCurrRepeatLevel, i) ;
+ }
+ }
+
+ pPrevNode -> xNext = Node_selfFirstChild (pDomTree, pCompileParent, r
-> nCurrRepeatLevel) -> xNdx ;
if (pCurrReq -> bDebug & dbgParse)
- lprintf (pCurrReq, "[%d]Checkpoint: jump forward2 DomTree=%d
Index=%d Node=%d Line=%d -> Index=%d Node=%d Line=%d SVs=%d\n", pCurrReq -> nPid,
xDomTree, nCompileCheckpoint, pPrevNode -> xNdx, pPrevNode -> nLinenumber,
nRunCheckpoint, pRunNode -> xNdx, pRunNode -> nLinenumber, sv_count) ;
+ lprintf (pCurrReq, "[%d]Checkpoint: jump forward2 DomTree=%d
Index=%d Node=%d,%d,%d Line=%d -> Index=%d Node=%d,%d,%d Line=%d SVs=%d\n", pCurrReq
-> nPid, xDomTree, nCompileCheckpoint, pPrevNode -> xNdx, pCompileParent -> xNdx,
pCompileParent2 -> xNdx, pPrevNode -> nLinenumber, nRunCheckpoint, pRunNode -> xNdx,
pRunParent -> xNdx, pRunParent2 -> xNdx, pRunNode -> nLinenumber, sv_count) ;
}
else
{
@@ -1100,10 +1139,45 @@
return ;
}
- if (pCurrReq -> bDebug & dbgParse)
- lprintf (pCurrReq, "[%d]Checkpoint: jump backward DomTree=%d %d -> %d
SVs=%d\n", pCurrReq -> nPid, xDomTree, nCompileCheckpoint, nRunCheckpoint, sv_count) ;
-
- mydie ("Loops not implemented") ;
+ {
+ tDomTree * pDomTree = DomTree_self (xDomTree) ;
+ tDomTreeCheckpoint * pCheckpoints = pDomTree -> pCheckpoints ;
+
+ tNodeData * pCompileNode = Node_selfLevel (pDomTree,
pCheckpoints[nCompileCheckpoint].xNode, r -> nCurrRepeatLevel) ;
+ tNodeData * pRunNode = Node_selfLevel (pDomTree,
pCheckpoints[nRunCheckpoint].xNode, r -> nCurrRepeatLevel+1) ;
+ tNodeData * pPrevNode = Node_selfPreviousSibling (pDomTree,
pCompileNode, r -> nCurrRepeatLevel) ;
+
+ tNodeData * pCompileParent = NodeAttr_selfParentNode (pDomTree,
pCompileNode, r -> nCurrRepeatLevel) ;
+ tNodeData * pRunParent = NodeAttr_selfParentNode (pDomTree, pRunNode, r
-> nCurrRepeatLevel) ;
+
+ if (pPrevNode)
+ pPrevNode = Node_selfCondCloneNode (pDomTree, pPrevNode, r ->
nCurrRepeatLevel) ;
+ else
+ {
+ pPrevNode = Node_selfCondCloneNode (pDomTree, pCompileNode, r ->
nCurrRepeatLevel) ;
+ pPrevNode -> bFlags |= nflgIgnore ;
+ }
+
+ if (pCompileParent == pRunParent)
+ {
+ pRunNode = Node_selfCondCloneNode (pDomTree, pRunNode, r ->
nCurrRepeatLevel) ;
+
+ pRunNode -> xPrev = pPrevNode -> xNdx ;
+ pPrevNode -> xNext = pRunNode -> xNdx ;
+
+ if (pCurrReq -> bDebug & dbgParse)
+ lprintf (pCurrReq, "[%d]Checkpoint: jump backward DomTree=%d Index=%d
Node=%d Line=%d -> Index=%d Node=%d Line=%d SVs=%d\n", pCurrReq -> nPid, xDomTree,
nCompileCheckpoint, pPrevNode -> xNdx, pPrevNode -> nLinenumber, nRunCheckpoint,
pRunNode -> xNdx, pRunNode -> nLinenumber, sv_count) ;
+
+ r -> nCurrRepeatLevel++ ;
+ }
+ else
+ {
+ if (pCurrReq -> bDebug & dbgParse)
+ lprintf (pCurrReq, "[%d]Checkpoint: jump forward2 DomTree=%d Index=%d
Node=%d,%d Line=%d -> Index=%d Node=%d,%d Line=%d SVs=%d\n", pCurrReq -> nPid,
xDomTree, nCompileCheckpoint, pPrevNode -> xNdx, pCompileParent -> xNdx, pPrevNode ->
nLinenumber, nRunCheckpoint, pRunNode -> xNdx, pRunParent -> xNdx, pRunNode ->
nLinenumber, sv_count) ;
+
+ mydie ("Unstrutured backward jump") ;
+ }
+ }
}
@@ -2774,8 +2848,7 @@
pNextNode = Node_selfNextSibling (pDomTree, pNextNode, nRepeatLevel) ;
// if (pNode -> nType == ntypStartTag && (pNode -> bFlags & nflgIgnore)
== 0 &&
// (pNextNode == NULL || (pNextNode -> bFlags & nflgCheckpoint) == 0
|| pDomTree -> pOrder[nOrderNdx].xFromNode == pNextNode -> xNdx))
- if (pNode -> nType == ntypStartTag && (pNode -> bFlags & nflgIgnore)
== 0 &&
- (pNextNode == NULL || (pNextNode -> bFlags & nflgCheckpoint) == 0))
+ if (pNode -> nType == ntypStartTag && (pNode -> bFlags & nflgIgnore)
== 0)
{
char * pNodeName = Node_selfNodeName (pNode) ;
@@ -3027,20 +3100,17 @@
-tAttrData * Element_selfRemoveAttribut (/*in*/ tDomTree * pDomTree,
+tAttrData * Element_selfRemoveAttributPtr (/*in*/ tDomTree *
pDomTree,
/*in*/ struct tNodeData * pNode,
/*in*/ tRepeatLevel nRepeatLevel,
- /*in*/ const char * sAttrName,
- /*in*/ int nAttrNameLen,
+ /*in*/ tAttrData * pAttr,
/*in*/ int bClone)
{
- tAttrData * pAttr ;
tNodeData * pNewNode ;
pNode = Node_selfCondCloneNode (pDomTree, pNode, nRepeatLevel) ;
- pAttr = Element_selfGetAttribut (pDomTree, pNode, sAttrName, nAttrNameLen) ;
if (bClone)
{
if (pAttr != NULL && (pNode -> bFlags & nflgModified))
@@ -3048,7 +3118,7 @@
pNode -> bFlags |= nflgReturn | nflgModified ;
pNewNode = Node_selfCloneNode (pDomTree, pNode, nRepeatLevel, 1) ;
- pAttr = Element_selfGetAttribut (pDomTree, pNewNode, sAttrName,
nAttrNameLen) ;
+ //???? pAttr = Element_selfGetAttribut (pDomTree, pNewNode, sAttrName,
nAttrNameLen) ;
DomTree_selfCheckpoint (pDomTree, pNode -> xNdx, pNewNode -> xNdx) ;
}
@@ -3092,6 +3162,39 @@
return pAttr ;
}
+
+tAttrData * Element_selfRemoveAttribut (/*in*/ tDomTree * pDomTree,
+ /*in*/ struct tNodeData * pNode,
+ /*in*/ tRepeatLevel nRepeatLevel,
+ /*in*/ const char * sAttrName,
+ /*in*/ int nAttrNameLen,
+ /*in*/ int bClone)
+
+ {
+ tAttrData * pAttr ;
+
+ pNode = Node_selfCondCloneNode (pDomTree, pNode, nRepeatLevel) ;
+
+ pAttr = Element_selfGetAttribut (pDomTree, pNode, sAttrName, nAttrNameLen) ;
+
+ return Element_selfRemoveAttributPtr (pDomTree, pNode, nRepeatLevel, pAttr,
bClone) ;
+ }
+
+tAttrData * Element_selfRemoveNthAttribut (/*in*/ tDomTree *
pDomTree,
+ /*in*/ struct tNodeData * pNode,
+ /*in*/ tRepeatLevel nRepeatLevel,
+ /*in*/ int n)
+
+ {
+ tAttrData * pAttr ;
+
+ pNode = Node_selfCondCloneNode (pDomTree, pNode, nRepeatLevel) ;
+
+ pAttr = Element_selfGetNthAttribut (pDomTree, pNode, n) ;
+
+ return Element_selfRemoveAttributPtr (pDomTree, pNode, nRepeatLevel, pAttr, 0) ;
+ }
+
/* ------------------------------------------------------------------------
1.4.2.32 +20 -1 embperl/Attic/epdom.h
Index: epdom.h
===================================================================
RCS file: /home/cvs/embperl/Attic/epdom.h,v
retrieving revision 1.4.2.31
retrieving revision 1.4.2.32
diff -u -r1.4.2.31 -r1.4.2.32
--- epdom.h 2001/10/22 13:52:16 1.4.2.31
+++ epdom.h 2001/10/23 19:35:13 1.4.2.32
@@ -9,7 +9,7 @@
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: epdom.h,v 1.4.2.31 2001/10/22 13:52:16 richter Exp $
+# $Id: epdom.h,v 1.4.2.32 2001/10/23 19:35:13 richter Exp $
#
###################################################################################*/
@@ -262,6 +262,9 @@
int ArrayAdd (/*in*/ const tArray * pArray,
/*in*/ int numElements) ;
+int ArraySub (/*in*/ const tArray * pArray,
+ /*in*/ int numElements) ;
+
void StringNew (/*in*/ char * * pArray,
/*in*/ int nAdd) ;
@@ -353,6 +356,7 @@
#define Node_selfParentNode(pDomTree,pNode,nLevel)
(Node_selfLevel(pDomTree,(pNode)->xParent,nLevel))
#define xNode_selfParentNode(pDomTree,pNode) ((pNode)->xParent)
+
#define Node_firstChild(pDomTree,xNode,nLevel)
(Node_selfLevel(pDomTree,xNode,nLevel)->xChilds)
#define Node_selfFirstChild(pDomTree,pNode,nLevel)
(Node_selfLevel(pDomTree,(pNode)->xChilds,nLevel))
@@ -449,7 +453,18 @@
/*in*/ int nNewValueLen,
/*in*/ int bClone) ;
+tAttrData * Element_selfRemoveAttributPtr (/*in*/ tDomTree *
pDomTree,
+ /*in*/ struct tNodeData * pNode,
+ /*in*/ tRepeatLevel nRepeatLevel,
+ /*in*/ tAttrData * pAttr,
+ /*in*/ int bClone) ;
+tAttrData * Element_selfRemoveNthAttribut (/*in*/ tDomTree *
pDomTree,
+ /*in*/ struct tNodeData * pNode,
+ /*in*/ tRepeatLevel nRepeatLevel,
+ /*in*/ int n) ;
+
+
tAttrData * Element_selfRemoveAttribut (/*in*/ tDomTree * pDomTree,
/*in*/ struct tNodeData * pNode,
/*in*/ tRepeatLevel nRepeatLevel,
@@ -466,3 +481,7 @@
/*in*/ struct tAttrData * pAttr,
/*in*/ tRepeatLevel nRepeatLevel,
/*out*/ char * * ppAttr) ;
+
+
+#define NodeAttr_selfParentNode(pDomTree,pNode,nLevel) (pNode->nType ==
ntypAttr?Attr_selfNode(((tAttrData
*)pNode)):(Node_selfLevel(pDomTree,(pNode)->xParent,nLevel)))
+
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]