EP1200894A1 - Method and arrangement for determining a total error description of at least one part of a computer programme and computer programme product and computer-readable storage medium - Google Patents

Method and arrangement for determining a total error description of at least one part of a computer programme and computer programme product and computer-readable storage medium

Info

Publication number
EP1200894A1
EP1200894A1 EP00929272A EP00929272A EP1200894A1 EP 1200894 A1 EP1200894 A1 EP 1200894A1 EP 00929272 A EP00929272 A EP 00929272A EP 00929272 A EP00929272 A EP 00929272A EP 1200894 A1 EP1200894 A1 EP 1200894A1
Authority
EP
European Patent Office
Prior art keywords
int
error
description
slicec
iterator
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Withdrawn
Application number
EP00929272A
Other languages
German (de)
French (fr)
Inventor
Peter Liggesmeyer
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Siemens AG
Original Assignee
Siemens AG
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Siemens AG filed Critical Siemens AG
Publication of EP1200894A1 publication Critical patent/EP1200894A1/en
Withdrawn legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/008Reliability or availability analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0796Safety measures, i.e. ensuring safe condition in the event of error, e.g. for controlling element

Definitions

  • the invention relates to a method and an arrangement for determining an overall error description of at least part of a computer program as well as a computer product and a computer-readable storage medium.
  • a control flow description in the form of a control flow graph is determined for the computer program.
  • an element error description is determined using a stored error description, which is assigned to a stored reference element.
  • the error description of a reference element describes possible errors of the respective reference element.
  • the overall error description is determined from the element error descriptions in the form of element error trees, taking into account the control flow graph for the computer program.
  • the method and the arrangement from [1] have the following disadvantages in particular.
  • the overall fault tree determined is incomplete with regard to the faults examined and their causes and is therefore unreliable. Thus, this procedure cannot be used sensibly for safety-critical applications in the context of fault tree generation for a computer program.
  • Slicing corresponds to the analysis that is carried out when searching for the cause of a malfunction of a computer program. This procedure checks whether the misconduct was caused by an instruction that is currently being viewed. If this is not the case, the statements that supply data for the statement or control its execution are checked. This process continues until no more processes exist, that is, input data of the computer program are reached. So-called slices are determined during slicing. A slice is used to show which instructions are influenced in which way by a value under consideration. In the following, the term slicing is always understood to mean backward slicing.
  • the invention is based on the problem of determining an overall fault description which is more reliable than a determination of an overall fault tree known according to the method from [1].
  • a method for determining an overall error description of at least part of a computer program by a computer at least the part of the computer program is stored.
  • a control flow description and a data flow description for the part of the computer program are determined and program elements are selected from the part of the computer program.
  • An element error description is determined for each selected program element using a stored error description.
  • the error description is assigned to a reference element.
  • the element error description describes possible errors of the respective program element.
  • An error description of a reference element describes possible errors of the respective reference element.
  • the overall error description is determined from the element error descriptions taking into account the control flow description and the data flow description.
  • An arrangement for determining an overall fault description of at least part of a computer program has a processor which is set up in such a way that the following method steps can be carried out: at least the part of the computer program is stored,
  • control flow description and a data flow description are determined for the part of the computer program
  • an element error description is determined using a stored error description, which is assigned to a reference element, with which possible errors of the respective program element are described,
  • the total error description is determined from the element error descriptions taking into account the control flow description and the data flow description.
  • a computer program product comprises a computer readable storage medium on which a program is stored that enables a computer after it has been stored in a memory of the
  • At least the part of the computer program is stored, a control flow description and a data flow description for the part of the computer program are determined,
  • Program elements are selected from the part of the computer program, - For each selected program element, an element error is used using a stored error description, which is assigned to a reference element. ler description determined with which possible errors of the respective program element are described,
  • an error description of a reference element describes possible errors of the respective reference element
  • the overall error description is determined taking into account the control flow description and the data flow description.
  • a program is stored on a computer-readable storage medium, which enables a computer, after it has been loaded into a memory of the computer, to carry out the following steps to determine an overall error description of at least part of a computer program: At least the part of the computer program is stored,
  • control flow description and a data flow description are determined for the part of the computer program
  • an element error description is determined using a stored error description, which is assigned to a reference element, with which possible errors of the respective program element are described,
  • the total error description is determined from the element error descriptions taking into account the control flow description and the data flow description.
  • the invention now makes it possible to determine a reliable overall error description for a computer program or a part thereof, taking into account the peculiarities of a computer program. Since the determined overall fault description is much more reliable than that according to The method can be determined from [1] overall error description, the invention is also suitable for security-critical applications, ie in particular for determining an overall error description of a security-critical computer program.
  • control flow description and / or the data flow description can be in the form of a control flow graph or a data flow graph.
  • the error description can be in the form of a stored error tree and the element error description can be determined as an element error tree.
  • the overall error description can be determined as an overall error tree.
  • the overall error description can be used in a further development for error analysis of the part of the computer program.
  • the overall error description is determined as an overall error tree and the overall error tree is changed with regard to predefinable framework conditions.
  • the change can be made by adding a supplementary fault tree.
  • FIG. 1 shows a computer with which the method according to the embodiment is carried out;
  • FIG. 2 shows a flow chart in which the individual method steps of the method according to the exemplary embodiment are shown;
  • FIG. 3 shows a general fault tree, as it is principally formed for a reference element; 4a to 4c a control flow graph (FIG. 4a), a slice (FIG. 4b) and a fault tree (FIG. 4c) for an instruction sequence as a reference element of a computer program;
  • FIG. 5a to 5c a control flow graph (FIG. 5a), a slice (FIG. 5b) and an error tree (FIG. 5c) for a selection sequence as a reference element of a computer program; 6a to 6c a control flow graph (FIG. 6a), a slice (FIG. 6b) and an error tree (FIG. 6c) for a loop as a reference element of a computer program;
  • FIG. 7 shows a control flow graph with a data flow graph for a computer program according to the exemplary embodiment
  • Figures 8a and 8b a slice of the output of the variable max
  • FIG. 8a or a slice for the variable avr (FIG. 8b) for the program according to the exemplary embodiment
  • FIG. 9 shows the slice for the variable avr, in which a structure of the loop is highlighted from the program of the exemplary embodiment
  • FIG. 10 shows an error tree for the assumption that the variable avr is incorrect
  • FIG. 11 shows the overall fault construction according to FIG. 10, redundant events from the overall fault tree according to FIG. 10 having been combined into one event.
  • Fig.l shows a computer 100 with which the method described below is carried out.
  • the computer 100 has a processor 101 which is connected to a memory 102 via a bus 103.
  • An input / output interface 106 is also connected to the bus 103.
  • a computer program 104 is stored in the memory 102, for which an overall error description is determined in the manner described below.
  • a program 105 is also stored in the memory 102, by means of which the method described below is implemented.
  • error descriptions 115 are different in the memory
  • Reference elements of a computer program saved.
  • An error description of a reference element describes possible errors of the respective reference element.
  • Various reference elements and error descriptions assigned to the reference elements are explained in detail below.
  • a keyboard 108 is connected to the input / output interface 106 via a first connection 107.
  • the input / output interface 106 is connected to a computer mouse 110 via a second connection 109, and the input / output interface 106 is connected to a screen 112 via a third connection 111, on which the determined overall error description of the computer program 104 is displayed.
  • Output cut parts 106 connected to an external storage medium 114. 2 shows in a block diagram the procedure according to the exemplary embodiment described below.
  • a control flow graph 201 and a data flow graph 202 for the computer program 104 are determined from the stored computer program 104.
  • Individual program elements are selected from the computer program (step 203). For each selected program element, an element error description is determined using a stored error description that is assigned to a reference element corresponding to the selected program element (step 204). The element error description describes possible errors of the selected program element.
  • an overall error description of the computer program for the error case to be examined is determined from the element error descriptions, taking into account the control flow graph and the data flow graph .
  • the determined overall fault tree is displayed to the user on the screen 112.
  • FIG 3 shows the basic procedure for creating an error tree, as was used in the context of the starting example, to form the error trees described below for the reference elements.
  • an erroneous output of a variable can be a selected erroneous event (undesirable event) 301 are caused by a control flow error 303 and / or a data error 304 (INCLUSIVE-OR link 302).
  • a control flow error 303 is to be understood as an incorrect control of the processing of the respective variables.
  • the data flow error 304 is to be understood as an error that arises from incorrect data during processing.
  • the data flow error 304 can arise again in the processing step currently under consideration (block 306) and / or it can already have been present and can only be retained by error propagation (block 307) (INCLUSIVE-OR link 305).
  • the fault tree 420 shown in FIG. C results for the following predetermined undesired event 421:
  • the faulty event 421 may have been generated by an error in the considered third instruction 404 even with data correct up to this instruction step (element 422 in FIG. 4c).
  • the erroneous event 421 can also be caused by corrupted input data of the third instruction, i.e. by INCLUSIVE-ORing 424 the events that the second variable k after the second
  • FIGS. 5 a to 5 c there is a control flow graph 501 (see FIG. 5 a), a slice 520 (see FIG. 5 b) and an error tree 540 (see Fig. 5c) for an If-Then-Else statement as a selection element.
  • a third instruction 504 in which it is checked whether the second variable k has a value greater than 0; if the value of the second variable is greater than 0, the instruction branches to a fourth instruction 505, otherwise to a fifth instruction 506,
  • the control flow graph 501 shown in FIG. 5 a results in the slice 520 shown in FIG. 5 b for the selection element.
  • Solid edges in the slice 520 represent a data dependency of the different instructions from one another.
  • Control dependencies of the corresponding instructions from one another are indicated with dashed edges.
  • control edges are directed from instructions which contain a predictive reference (failure constructs, loop control) to the instructions which are directly controlled, ie to those instructions which are only executed if the predicate has a certain value.
  • Control edges are only drawn between the control instruction and immediately nested instructions. If another control level is nested in a controlled block, no control edges are drawn that cover more than one level. Since a control relationship is transitive, this indirect control can be inferred from the slice by using transitivity.
  • - Solid edges hereinafter referred to as data flow edges, are directed from instructions in which a variable is defined to instructions in which this variable is referenced. The considered variable must not be redefined between the definition and the reference. This is known as the path free of definition with regard to the variables under consideration.
  • the slice is determined by searching the control flow graph against the edge direction for the definition of the variables under consideration, based on the instruction with the variables under consideration, for which the undesired event is specified. If there are computational references to the definition, the process continues recursively until no additional nodes are found.
  • the dependencies between statements found in this way are data dependencies. If a node under consideration is in a block, the execution of which is directly controlled by a decision, this represents a control dependency. For the predictive references of the variables involved in the decision, nodes with corresponding definitions - that is, data flow dependencies - are recursively searched for have further control dependencies.
  • 5b shows the slice 520 belonging to the failure element with corresponding control edges and data flow edges.
  • 5c shows the error tree 540 for the specified event "the third variable i is faulty before the 6th instruction" 541.
  • a multiple selection element as a reference element can be treated according to the above-described scheme by breaking the multiple selection into a cascade of two-sided selection elements which are processed in accordance with the above procedure, in order thus to determine an error tree for a multiple selection element.
  • FIGS. 6 a to 6 c show an error tree 601 (see FIG. 6 a), the corresponding slice 620 (see FIG. 6 b) and the associated error tree 640 (see FIG. 6 c) for the reference element of a loop.
  • the control flow graph 601 for a loop element has the following seven instructions:
  • a fourth instruction 605 which specifies as a loop instruction a condition that a fifth instruction and a sixth instruction are carried out as long as the value of the second variable is j> 0 (WHILE j> 0 DO),
  • FIG. 6b shows the corresponding slice 620 for the control flow graph 601 shown in FIG. 6a with associated control flow edges and data flow edges.
  • the fault tree 640 shown in FIG. 6c is formed for the predetermined event 641 that the "first variable i before the seventh instruction is faulty".
  • the error tree 640 results from the INCLUSIVE-OR link 642 of the following four events:
  • Loop body has been run through at least twice (element 645) and the event that the sixth instruction 607 is incorrect (646),
  • error trees described above which are assigned to the individual reference elements, are stored in the memory 102 as error trees 115.
  • 7 shows a control flow graph 700 for the following computer program:
  • FIG. 8a shows the associated slice 800 for the variable max
  • FIG. 8b shows the associated slice 810 for the variable avr .
  • the numbering of the individual instructions in the slices corresponds to the numbering of the individual instructions in the control flow graph 700 from FIG. 7.
  • FIG. 9 shows the slice 900 for the variable avr, as shown in FIG. 8b.
  • the structure of the loop element contained in the program shown above is highlighted in bold. This structure corresponds to the slice shown in FIG. 6b for a loop element.
  • An overall fault tree 1000 for the computer program shown above is shown in FIG.
  • the overall fault tree for the computer program is generated by instantiating the corresponding fault tree that is assigned to the reference element that corresponds to the selected program element. By proceeding backwards starting from the predetermined undesired event, the overall error tree 1000 is thus determined using the error trees assigned to the reference elements.
  • the fault tree 1000 is related to the event that "the variable avr is faulty before the thirteenth instruction" (element 1001).
  • the variable avr may be incorrect before the thirteenth instruction 13 due to at least one of the following three events, as is also shown in the slice 900 for the variable avr shown in FIG. 9 (INCLUSIVE-OR operation 1002):
  • variable sum is faulty before the eleventh instruction 11 (element 1005) if at least one of the following events is fulfilled (INCLUSIVE-OR link 1006):
  • variable sum is incorrect after the fourth statement 4 (element 1007)
  • the error tree 1000 from FIG. 10 is changed so that events that are shown several times in the error tree 1000 are combined to form a node of a cause and effect graph 1100 (see FIG. 11).
  • a fault tree analysis method as described in [5] is applied to the fault tree 1000 shown in FIG. 10, as a result of which an analysis of the computer program with regard to a predetermined undesired event is analyzed.
  • the overall fault tree generated with the method described above can be used for various purposes:
  • KFGListNode.h "usmg namespace std; class GraphNodeC: public
  • KFGListC SL 2 void sliceForLoops (KFGListC SL 2 , KFGListC:: iterator LOOPIT); KFGListC:: iterator defineVariableToSlice (KFGListC SL 2 );
  • KFGListC:: iterator findUpperLimit KFGListC s Ll, KFGListC:: iterator ITER, KFGP UseListC:: iterator PUSEIT);
  • KFGListC:: iterator fmdLowerLimit (KFGListC & Ll, KFGListC:: iterator ITER, KFGListC :: iterator UPPERLIMIT);
  • KFGListC:: iterator findLowerLimitFromCUse KFGListC S Ll, KFGListC: -.iterator ITER, KFGListC:: iterator UPPERLIMIT
  • KFGListC:: iterator findUpperLimitFromCUse KFGListC S Ll, KFGListC:: iterator ITER
  • KFGUseListC iterator USEIT); int checkForNodes (int NodeNumber); void KFKPUseToCUse (KFGListC:: ⁇ terator PUSEIT, int LoopEnd); void fmdDefToCUse (KFGListC S Ll, KFGListC:: iterator ITER); void deflnLooplKFGListC S Ll, KFGListC:: iterator ITER); void startBuildSlice (KFGListC S Ll); void sliceExpendl); );
  • template ⁇ class corner type, class edge type> void graph ⁇ corner type, edge type>:: verbindeEcken (int posl, int pos2, const edge type value) (
  • MILES.DAT (128 knots).
  • the stack depth corresponds to the number of edges
  • KFGListC public l ⁇ st ⁇ KFGL ⁇ stNodeC> (int number_defs, number_Uses, number_P_Uses, number of declarations; int loop decisions, decisions, counting loop decisions; int instructions; publlc: KFGListC () ( ⁇ ; void TokenL ⁇ st2KFn); node (S) void node identifier (KFGListC:: iterator KFG); void list output!); void addLmelnToList (); void addL ⁇ neToKFG (KFGProgL ⁇ stC S LP); int count declarations (KFGTokenL ⁇ stC S TL); void base size file ();
  • class KFGDefListC public list ⁇ KFGDefC> ( ⁇ ; class KFGUseListC: public reads ⁇ KFGUseC> ( ⁇ ; class KFGP_UseL ⁇ stC: public reads ⁇ KFGUseC> ( ⁇ ;
  • KFGListNodeCO (strcpy (Statement, "- unknown -");
  • NodeNr Dummy myNodeNr ++
  • KFGL ⁇ stNodeC (char _Statement [], KFGNodeTypeT _KFGNodeType) strcpy (statement, _Statement);
  • NodeNr Dummy myNodeNr ++
  • KFGL ⁇ stNodeC (char _Statement [], KFGNodeTypeT _KFGNodeType, int _Level)
  • NodeNr Dummy myNodeNr ++
  • Node number 0; Node identifier - NONE;
  • NodeNr Dummy myNodeNr ++
  • LineNr LineNr; strcpy (CodeLine, "—unknown—”); ⁇ ; from the setStatement (char _Statement []) strcpy (Statement, _Statement); ⁇ ; void setCodeL e (char _CodeL ⁇ ne []) strcpy (CodeLine, _CodeL ⁇ ne); ⁇ ; void setKFGKnoten endeavor (int _KnotenNr)
  • Node ID _ node ID; ⁇ ; int getNodeNumber () (return NodeNumber; ⁇ ; char * getStatement!) (return Statement; ⁇ ; char * getCodeL e () (return CodeLme; ⁇ ; int getLevel () (return Level; ⁇ ; int getNodeNrl) (return NodeNr; ⁇ ; int getL ⁇ neNr () (return LineNr; ⁇ ;
  • NodeC creates " « endl; * / ⁇ ;
  • ScopeLevel 0; ); KFGNodeCIchar _Name [], int _ScopeLevel)
  • NodeC creates " « endl; * / ⁇ ;
  • KFGLlstNodeC (char _Name []) (strcpy (Name, _Name);
  • ScopeLevel 0; ⁇ ; KFGLlstNodeC (char _Name [], int _ScopeLevel)
  • NodeC creates " « endl; * / ⁇ ;
  • ScopeLevel 0; ); KFGLlstNodeC (char _Name [], int _ScopeLevel)
  • KFGListeC inherits all properties // from the list created with STL ⁇ KFGNodeC>.
  • «Lfdef _KFGProgL ⁇ stHeader (quietly « define _KFGProgListHeader ffinclude ⁇ str ⁇ ng> ffinclude ⁇ ostream> ffinclude ⁇ std ⁇ o.h> flinclude ⁇ l ⁇ st> ffinclude ⁇ fstream> ffinclude ⁇ terator> namfinespodehsting using KFNclodGlist using the class; using the FinNodeGlist; KFNclingGlist using the name; using the FinNodeGlead; KFNclodGlist using the "; KFGL ⁇ neNodeC> (public:
  • KFGProgListC (); // void KFGListeAusgabel);
  • KFGTokenListC public reads ⁇ KFGTokenNodeC> (public:
  • KFGTokenListC ( ⁇ ; Void KFGListeAusgabel);
  • KFGTokenNodeC (char _Name [], int _ScopeLevel, TokenNodeTypeT TokenNodeType)
  • ScopeLevel _ScopeLevel
  • KFGTokenNodeC (char _Name [], t _ScopeLevel, TokenNodeTypeT _TokenNodeType, int LineNumber)
  • KFGUseC (strcpy (Use, "- unknown -");
  • ScopeLevelU 0; );
  • KFGUseC (char _Use [], int _ScopeLevelU) (strcpy (Use, _Use);
  • H include "AS Slice. H” using namespace std; class uwggraphC: public graph ⁇ uwgknotenC, uwgkanteC> (public:
  • SliceC iterator definelterator (SliceC S Sl, mt SliceNr); void addFirstNodesToFTISliceC s Sl, int NodeNo, int Posl);
  • SliceC iterator returnCondNode (SliceC S Sl, mt SliceNr); mt checkUWGNode ( ⁇ nt SliceNr); void Slice SliceC S Sl) t void startBuildFT (SliceC S Sl); void buildInLoopTree (SliceC S Sl, int Posl, SliceC:: iterator SLPUSE, SliceC:: iterator SLNODE); void bu ⁇ ldIn_Dl_Part (SliceC S Sl, int posOR_Dl, SliceC:: iterator SLPUSE, SliceC:: iterator SLNODE, int D2_RefNr); SliceC:: ⁇ terator f dOutmostPUse (SliceC S Sl, SliceC:: iterator SLPUSE); int checkPUsesl (SliceC Sl, SliceC:: iterator SLPUSE, SliceC:: iterator SLPUSEREF);
  • SliceC:: iterator f ⁇ nd_Dl_Node (SliceC S Sl, SliceC:: iterator SLPUSE, SliceC:: ⁇ terator SLNODE); void addAllDlNodes (SliceC S Sl, SliceC:: iterator SLNODE, int posGatter, int D2_RefNr);
  • SliceC :: ⁇ terator findLastPUse (SliceC S Sl, int SliceNr);
  • SliceC:: iterator fmdLastPUse2 (SliceC S Sl, int SliceNr, mt RefNr); void checkLoopOrCondl SliceC S Sl, SliceC:: ⁇ terator SLl, SliceC:: ⁇ terator SLORIG, int Posil); void buildIn_D2_Part (SliceC S Sl, int posOR_D2, SliceC:: iterator SLl, SliceC:: iterator SLPUSE, int nodeNoD2); int f ⁇ ndD2Node (SliceC S Sl, SliceC:: iterator PUSE); t buildlnlfTree (SliceC s Sl, SliceC:: ⁇ terator SLIF, SliceC:: iterator SLORIG, int posl);
  • SliceC:: iterator lookForNextPUse (SliceC S Sl, SliceC:: ⁇ terator SNODE, SliceC:: iterator SLPUSE); void bu ⁇ ld_IFKF_Part (SliceC Sl, t posKFOR, SliceC:: iterator SLPUSE); void build_Al_Part (SliceC Sl, int posIFDFOR, SliceC:: iterator SLIF, SliceC:: iterator SLORIG); void bu ⁇ ldD2_IFKF_Part (SliceC Sl, int posKFOR, SliceC:: iterator SLPUSE); void bu ⁇ ldD2_Al_Part (SliceC Sl, int posIFDFOR, SliceC:: iterator SLIF, SliceC:: ⁇ terator SLNODE); int bu ⁇ ldD2InIfTree (SliceC S Sl, SliceC:::: it
  • Gatterldent DummyNr ++; ⁇ ; uwgknotenC (NodeldentT _NodeIdent)
  • Gatterldent DummyNr ++; ); uwgknotenC (NodeldentT _NodeIdent, t _CauseNr / *, char _gattertext [] * / )
  • CauseNr CauseNr; strepyl gate text, "- unknown -”); strepyl gate remark, "—none—”); / * strcpy (gattertext, _gattertext); * /
  • VARDEFI L2.beginl
  • HLevel LOOPIT-> getLevel ();
  • (HELPLOOP-> getLevel ⁇ )! Akt- Level)) ⁇
  • HELPIT HELPLOOP
  • (HELPLOOP-> getLevel () ' HELPIF-> getLevel ())) (
  • KFGListC :: iterator HELPDEF ITER
  • KFGListC :: iterator HELPLOOP ITER
  • HELPLOOP HELPIT; if (HELPIT-> getLevel ()> 2) (
  • HELPIT ⁇ HELPLOOP
  • KFGListC:: iterator HELPIT ITER;
  • KFGListC:: iterator HELPLOOP ITER;
  • KFGListC:: iterator LOWERLIMIT ITER;
  • HELPLOOP HELPIT; if (HELPIT-> getLevel ()> 2) (
  • AktLevel UPPERLIMIT-> getLevel (); while
  • LOWERLIMIT HELPLOOP; ⁇ return LOWERLIMIT;
  • KFGUseLi ⁇ tC iterator USEIT
  • KFGPJJseListC iterator PUSEIT2
  • KFGUseListC iterator CUSEIT2; int node level; int node number;
  • UPPERLIMIT findUpperLimitFromCUse (Ll, ITER, USEIT1); HELPIT - findLowerLimitFromCUse (Ll, ITER, UPPERLIMIT); UPPERLIMIT—;
  • KFGListC :: iterator HELPIT ITER;
  • KFGListC :: iterator HELPLOOP ITER;
  • KFGListC:: iterator LOWERLIMIT ITER;
  • HELPIT HELPLOOP; // iterator points to the end of the outermost
  • HELPIT—; ⁇ if (HELPIT-> getNodeNr () ⁇ UPPERLIMIT-> getNodeNr ()) (LOWERLIMIT HELPLOOP; // upper limit outside the outermost loop;
  • LOWERLIMIT HELPLOOP; // upper limit in the same outer loop, but ⁇ // inside a different loop before the c-use; ice (
  • LOWERLIMIT HELPLOOP; // upper limit in a lower loop than the c-use; ⁇
  • KFGListC:: iterator HELPDEF ITERl
  • KFGListC:: iterator HELPLOOP ITERl
  • KFGListC:: iterator HELPIT ITERl
  • KFGListC:: iterator HELPIF ITERl
  • KFGDefListC iterator DEFIT
  • AktLevel ITERl-> getLevel ();
  • HELPDEF HELPDEFRETURN
  • HELPDEFRETURN HELPDEF
  • KFGListC TokenL ⁇ st2KFGL ⁇ st (KFGTokenListC S Ll) (int dummy;
  • KFGP_UseL ⁇ stC iterator P_USEI
  • KFGUseC hUsel (TLI-> getName (), TLI-> getScopeLevel ());
  • P_USEI f ⁇ nd (HNl. P_Uses.beginl), hNl. P_Uses.end (), hUsel);
  • push_front (hNl); ⁇ break; case DO: push_front (KFGL ⁇ stNodeC ("DOWHILELOOP", DOWL, TLI-> getScopeLevel ())); TLI -;
  • HLevel TLI-> getScopeLevel (); push_front (KFGLlstNodeC ("ENDLOOP", EL, LI-> getScopeLevel ()));
  • KFGLlstNodeC hNl ("NORMAL", NO, TLI-> getScopeLevel (), TLI-> getLmeNumber ()); hNl.Defs.push_back (KFGDefC (TLI-> getName (), TLI-> getScopeLevel ()));
  • Number_defs ++ if (TLI-> getTokenNodeType () - N) (helpNodel.Defs.pop_front (); number_defs—; // in this case it is an array and
  • KFGUseC hUse2 (TLI-> getName (), TLI-> getScopeLevel ());
  • helpNodel Defs .push_back (KFGDefC (TLI-> getName (), TLI-> getScopeLevel ())); push_front (helpNodel);
  • helpNodel > getL ⁇ neNumber ()); helpNodel .Uses. push_back (KFGUseC (TLI-> getName (), TLI-> getScopeLevel ())); push_front (helpNodel);
  • PROG1—; dummy 1; ) else ⁇ PROG1—;
  • Target «" STOP " « endl «endl; Target «" BASIC SIZES: “« endl; Target «" Number of empty branches: “ « “0” «endl; Target «" Number of decisions: “ « Decisions «final;
  • Target « Number of atomic predicates, which are arithmetic relations: " « “0” «endl; Target «" Number of loop decisions: " « Loop decisions «endl;
  • Target «" Number of non-nested loop decisions: “« “0” «endl; Target «" number of counting loop decisions: “ « counting loop decisions «endl;
  • Target «" Number of declarations of structured data types: “ « “0” «endl; Target «" Number of declarations: “« Number_declarations «endl;
  • Target «" Number of real element declarations: “ « “0” «endl; Target «" number of base type declarations: “« number_declarations «endl; Target «" number of defs: “« number_defs «endl; Target «" Number of Uses: “ « Number_Uses «endl; Target «" Number of P-Uses: “ « Number_P_Uses «endl» endl; base size file (); ⁇ void KFGListC:: bas ⁇ sgroessenIn voyage () (ofstream file ("Basisgroessen.bgd”, ⁇ os :: out); file «" 0 "« endl; file «decisions « endl; file «instructions « endl; file «decisions « endl; file «decisions« endl; file «" 0 "« endl; file «loop decisions « endl; file «" 0 " « endl; file «counting loop decisions « endl; file «" 0 " « endl; file «number_declarations
  • KFGTokenList.h D void KFGTokenListC:: KFGL ⁇ steAusgabe () (D ofstream destination ("CFGTokenList”); D ostream_ ⁇ terator ⁇ KFGTokenNodeC> oPos (Z ⁇ el, " ⁇ n");
  • KFGTokenNode.h include ⁇ ostream> ostreamS Operator «(ostreamS os, const KFGTokenNodeCS Node) (os « Node.Name «" "« Node. ScopeLevel «” "« Node. TokenNodeType «” «Node. IneNumber « endl; return os;
  • KFGProgList .h " include ⁇ ostream> static void usagelchar * progname); int maindnt arge, char * argv

Abstract

A control flow description and a data flow description are determined from the part of the computer programme concerned and programme elements are selected from said part of the computer programme. An element error description is determined for each selected programme element using a stored error description that is allocated to each reference element, this element error description describing the possible errors of the respective programme element. The total error description is then determined from the element error descriptions, taking into account the control flow description and the data flow description.

Description

Beschreibungdescription
Verfahren und Anordnung zur Ermittlung einer Gesamtfehlerbe- Schreibung zumindest eines Teils eines Computerprogramms so- wie Computerprogramm-Erzeugnis und computerlesbares SpeichermediumMethod and arrangement for determining an overall error description of at least part of a computer program, as well as computer program product and computer-readable storage medium
Die Erfindung betrifft ein Verfahren und eine Anordnung zur Ermittlung einer Gesamtfehlerbeschreibung zumindest eines Teils eines Computerprogramms sowie ein Computer-Erzeugnis und ein computerlesbares Speichermedium.The invention relates to a method and an arrangement for determining an overall error description of at least part of a computer program as well as a computer product and a computer-readable storage medium.
Ein solches Verfahren und eine solche Anordnung ist aus [1] bekannt.Such a method and such an arrangement are known from [1].
Aus [1] ist bekannt, eine Gesamtfehlerbeschreibung in Form eines Gesamtfehlerbaums für ein Computerprogramm rechnergestützt zu ermitteln. Für das Computerprogramm wird eine Kontrollflußbeschreibung in Form eines Kontrollflußgraphen er- mittelt. Für verschiedene Programmelemente des Computerprogramms wird unter Verwendung einer gespeicherten Fehlerbeschreibung, die jeweils einem gespeicherten Referenzelement zugeordnet ist, eine Elementenfehlerbeschreibung ermittelt. Mit der Fehlerbeschreibung eines Referenzelements werden mög- liehe Fehler des jeweiligen Referenzelements beschrieben. Aus den Elementenfehlerbeschreibungen in Form von Elementenfeh- lerbäumen wird die Gesamtfehlerbeschreibung unter Berücksichtigung des Kontrollflußgraphen zu den Computerprogramm ermittelt.It is known from [1] to determine an overall error description in the form of an overall error tree for a computer program with the aid of a computer. A control flow description in the form of a control flow graph is determined for the computer program. For various program elements of the computer program, an element error description is determined using a stored error description, which is assigned to a stored reference element. The error description of a reference element describes possible errors of the respective reference element. The overall error description is determined from the element error descriptions in the form of element error trees, taking into account the control flow graph for the computer program.
Das Verfahren und die Anordnung aus [1] weisen insbesondere folgende Nachteile auf. Der ermittelte Gesamtfehlerbaum ist hinsichtlich der untersuchten Fehler und deren Ursachen unvollständig und damit unzuverlässig. Somit ist diese Vorge- hensweise für sicherheitskritische Anwendungen im Rahmen der Fehlerbaumgenerierung für ein Computerprogramm nicht sinnvoll einsetzbar. Auch sind die einzelnen Fehlerbäume, die den Re- ferenzelementen zugeordnet sind, unvollständig und damit unzuverlässig.The method and the arrangement from [1] have the following disadvantages in particular. The overall fault tree determined is incomplete with regard to the faults examined and their causes and is therefore unreliable. Thus, this procedure cannot be used sensibly for safety-critical applications in the context of fault tree generation for a computer program. The individual fault trees that are assigned to reference elements, incomplete and therefore unreliable.
In [2] ist eine Übersicht über ein sogenanntes Slicing zu finden. Slicing entspricht der Analyse, die bei der Ursachensuche für ein Fehlverhalten eines Computerprogramm.es durchgeführt wird. Im Rahmen dieses Vorgehens wird geprüft, ob das Fehlverhalten durch eine aktuell betrachtete Anweisung verursacht wurde. Ist dies nicht der Fall, so werden die Anweisun- gen überprüft, die für die Anweisung Daten liefern oder ihre Ausführung steuern. Dieses Verfahren wird fortgesetzt, bis keine Vorgänge mehr existieren, also Eingabedaten des Computerprogramms erreicht werden. Beim Slicing werden sogenannte Slices ermittelt. Mit einem Slice wird dargestellt, welche Anweisungen auf welche Weise von einem betrachteten Wert beeinflußt werden. Im weiteren wird unter dem Begriff Slicing stets ein rückwärts gerichtetes Slicing verstanden.An overview of so-called slicing can be found in [2]. Slicing corresponds to the analysis that is carried out when searching for the cause of a malfunction of a computer program. This procedure checks whether the misconduct was caused by an instruction that is currently being viewed. If this is not the case, the statements that supply data for the statement or control its execution are checked. This process continues until no more processes exist, that is, input data of the computer program are reached. So-called slices are determined during slicing. A slice is used to show which instructions are influenced in which way by a value under consideration. In the following, the term slicing is always understood to mean backward slicing.
Aus [3] ist es bekannt, zu einem Computerprogramm eine Kon- trollflußbeschreibung und eine Datenflußbeschreibung zu ermitteln. In [3] wird diese Darstellung als Ausgangsbasis für sogenanntes datenflußorientiertes Testen des Computerprogramms eingesetzt. Den Anweisungen (Knoten) des Kontrollflußgraphen werden Datenflußattribute (Datenflußbeschreibung) zu- geordnet, die die Art der in den Anweisungen des Computerpro- grammes enthaltenen Datenzugriffe beschreibt. Es werden schreibende Zugriffe und lesende Zugriffe unterschieden. Schreibzugriffe werden als Definitionen (def) bezeichnet. Lesende Zugriffe werden als Referenz bezeichnet. Erfolgt ein lesender Zugriff in einer Entscheidung, so wird dieser Zugriff als prädikative Referenz (p-use, predicate use) bezeichnet. Ein lesender Zugriff in einer Berechnung eines Wertes wird als berechnende Referenz bezeichnet (c-use, computa- tional use) .From [3] it is known to determine a control flow description and a data flow description for a computer program. In [3] this representation is used as the basis for so-called data flow-oriented testing of the computer program. The instructions (nodes) of the control flow graph are assigned data flow attributes (data flow description) which describe the type of data accesses contained in the instructions of the computer program. A distinction is made between write access and read access. Write accesses are called definitions (def). Read accesses are referred to as references. If a read access is made in a decision, this access is referred to as a predictive reference (p-use, predicate use). Read access in a calculation of a value is called a calculation reference (c-use, computational use).
Aus [4] sind Grundlagen über einen Fehlerbaum bekannt. Unter einem Fehlerbaum ist, wie in [4] beschrieben, eine Struktur zu verstehen, die logische Zusammenhänge zwischen Eingangsgrößen des Fehlerbaums beschreibt, welche Eingangsgrößen zu einem vorgegebenen unerwünschten Ereignis führen.Fundamentals of a fault tree are known from [4]. As described in [4], there is a structure under a fault tree understand the logical relationships between input variables of the fault tree, which input variables lead to a given undesired event.
Ferner sind aus [5] verschiedene Verfahren zur Fehlerbaumanalyse bekannt.Various methods for fault tree analysis are also known from [5].
Der Erfindung liegt das Problem zugrunde, eine Gesamtfehlerbeschreibung zu ermitteln, die gegenüber einer gemäß dem Ver- fahren aus [1] bekannten Ermittlung eines Gesamtfehlerbaums zuverlässiger ist.The invention is based on the problem of determining an overall fault description which is more reliable than a determination of an overall fault tree known according to the method from [1].
Das Problem wird durch das Verfahren sowie durch die Anordnung mit den Merkmalen gemäß den unabhängigen Ansprüchen so- wie durch das Computer-Erzeugnis und das computerlesbareThe problem is solved by the method and by the arrangement with the features according to the independent claims, as well as by the computer product and the computer-readable
Speichermedium mit den Merkmalen gemäß den unabhängigen Ansprüchen gelöst.Storage medium with the features according to the independent claims solved.
Bei einem Verfahren zur Ermittlung einer Gesamtfehlerbe- Schreibung zumindest eines Teils eines Computerprogrammes, durch einen Computer, ist zumindest der Teil des Computerprogrammes gespeichert. Es wird eine Kontrollflußbeschreibung und eine Datenflußbeschreibung zu dem Teil des Computerprogrammes ermittelt und es werden Programmelemente aus dem Teil des Computerprogrammes ausgewählt. Für jedes ausgewählte Programmelement wird unter Verwendung einer gespeicherten Fehlerbeschreibung eine Elementenfehlerbeschreibung ermittelt. Die Fehlerbeschreibung ist jeweils einem Referenzelement zugeordnet. Mit der Elementenfehlerbeschreibung werden mögliche Fehler des jeweiligen Programmelementes beschrieben. Mit einer Fehlerbeschreibung eines Referenzelements werden mögliche Fehler des jeweiligen Referenzelements beschrieben. Aus den Elementenfehlerbeschreibungen wird unter Berücksichtigung der Kontrollflußbeschreibung und der Datenflußbeschreibung die Gesamtfehlerbeschreibung ermittelt. Eine Anordnung zur Ermittlung einer Gesamtfehlerbeschreibung zumindest eines Teils eines Computerprogrammes weist einen Prozessor auf, der derart eingerichtet ist, daß folgende Verfahrensschritte durchführbar sind: - Zumindest der Teil des Computerprogramms ist gespeichert,In a method for determining an overall error description of at least part of a computer program by a computer, at least the part of the computer program is stored. A control flow description and a data flow description for the part of the computer program are determined and program elements are selected from the part of the computer program. An element error description is determined for each selected program element using a stored error description. The error description is assigned to a reference element. The element error description describes possible errors of the respective program element. An error description of a reference element describes possible errors of the respective reference element. The overall error description is determined from the element error descriptions taking into account the control flow description and the data flow description. An arrangement for determining an overall fault description of at least part of a computer program has a processor which is set up in such a way that the following method steps can be carried out: at least the part of the computer program is stored,
- es werden eine Kontrollflußbeschreibung und eine Datenflußbeschreibung für den Teil des Computerprogramms ermittelt,a control flow description and a data flow description are determined for the part of the computer program,
- aus dem Teil des Computerprogrammes werden Programmelemen- te ausgewählt,- program elements are selected from the part of the computer program,
- für jedes ausgewählte Programmelement wird unter Verwendung einer gespeicherten Fehlerbeschreibung, die jeweils einem Referenzelement zugeordnet ist, eine Elementenfehlerbeschreibung ermittelt, mit der mögliche Fehler des je- weiligen Programmelements beschrieben werden,for each selected program element, an element error description is determined using a stored error description, which is assigned to a reference element, with which possible errors of the respective program element are described,
- mit einer Fehlerbeschreibung eines Referenzelements werden mögliche Fehler des jeweiligen Referenzelements beschrieben,possible errors of the respective reference element are described with an error description of a reference element,
- aus den Elementenfehlerbeschreibungen wird die Gesamtfeh- lerbeschreibung unter Berücksichtigung der Kontrollflußbeschreibung und der Datenflußbeschreibung ermittelt.- The total error description is determined from the element error descriptions taking into account the control flow description and the data flow description.
Ein Computerprogramm-Erzeugnis umfaßt ein computerlesbares Speichermedium, auf dem ein Programm gespeichert ist, daß es einem Computer ermöglicht, nachdem es in einen Speicher desA computer program product comprises a computer readable storage medium on which a program is stored that enables a computer after it has been stored in a memory of the
Computers geladen worden ist, folgende Schritte durchzuführen zur Ermittlung einer Gesamtfehlerbeschreibung zumindest eines Teils eines Computerprogramms:Computer has been loaded to perform the following steps to determine an overall error description of at least part of a computer program:
- Zumindest der Teil des Computerprogramms ist gespeichert, - es werden eine Kontrollflußbeschreibung und eine Datenflußbeschreibung für den Teil des Computerprogramms ermittelt,At least the part of the computer program is stored, a control flow description and a data flow description for the part of the computer program are determined,
- aus dem Teil des Computerprogrammes werden Programmelemente ausgewählt, - für jedes ausgewählte Programmelement wird unter Verwendung einer gespeicherten Fehlerbeschreibung, die jeweils einem Referenzelement zugeordnet ist, eine Elementenfeh- lerbeschreibung ermittelt, mit der mögliche Fehler des jeweiligen Programmelements beschrieben werden,- Program elements are selected from the part of the computer program, - For each selected program element, an element error is used using a stored error description, which is assigned to a reference element. ler description determined with which possible errors of the respective program element are described,
- mit einer Fehlerbeschreibung eines Referenzelements werden mögliche Fehler des jeweiligen Referenzelements beschrie- ben,- an error description of a reference element describes possible errors of the respective reference element,
- aus den Elementenfehlerbeschreibungen wird die Gesamtfehlerbeschreibung unter Berücksichtigung der Kontrollflußbeschreibung und der Datenflußbeschreibung ermittelt.- From the element error descriptions, the overall error description is determined taking into account the control flow description and the data flow description.
Auf einem computerlesbaren Speichermedium ist ein Programm gespeichert, daß es einem Computer ermöglicht, nachdem es in einen Speicher des Computers geladen worden ist, folgende Schritte durchzuführen zur Ermittlung einer Gesamtfehlerbeschreibung zumindest eines Teils eines Computerprogramms: - Zumindest der Teil des Computerprogramms ist gespeichert,A program is stored on a computer-readable storage medium, which enables a computer, after it has been loaded into a memory of the computer, to carry out the following steps to determine an overall error description of at least part of a computer program: At least the part of the computer program is stored,
- es werden eine Kontrollflußbeschreibung und eine Datenflußbeschreibung für den Teil des Computerprogramms ermittelt,a control flow description and a data flow description are determined for the part of the computer program,
- aus dem Teil des Computerprogrammes werden Programmelemen- te ausgewählt,- program elements are selected from the part of the computer program,
- für jedes ausgewählte Programmelement wird unter Verwendung einer gespeicherten Fehlerbeschreibung, die jeweils einem Referenzelement zugeordnet ist, eine Elementenfehlerbeschreibung ermittelt, mit der mögliche Fehler des je- weiligen Programmelements beschrieben werden,for each selected program element, an element error description is determined using a stored error description, which is assigned to a reference element, with which possible errors of the respective program element are described,
- mit einer Fehlerbeschreibung eines Referenzelements werden mögliche Fehler des jeweiligen Referenzelements beschrieben,possible errors of the respective reference element are described with an error description of a reference element,
- aus den Elementenfehlerbeschreibungen wird die Gesamtfeh- lerbeschreibung unter Berücksichtigung der Kontrollflußbeschreibung und der Datenflußbeschreibung ermittelt.- The total error description is determined from the element error descriptions taking into account the control flow description and the data flow description.
Durch die Erfindung ist es nunmehr möglich, eine zuverlässige, die Eigenheiten eines Computerprogramms berücksichtigende Gesamtfehlerbeschreibung für ein Computerprogramm oder einen Teil desselben zu ermitteln. Da die ermittelte Gesamtfehlerbeschreibung wesentlich zuverlässiger ist als die gemäß dem Verfahren aus [1] ermittelbare Gesamtfehlerbeschreibung, ist die Erfindung auch für sicherheitskritische Anwendungen, d.h. insbesondere für die Ermittlung einer Gesamtfehlerbeschreibung eines sicherheitskritischen Computerprogramms geeignet.The invention now makes it possible to determine a reliable overall error description for a computer program or a part thereof, taking into account the peculiarities of a computer program. Since the determined overall fault description is much more reliable than that according to The method can be determined from [1] overall error description, the invention is also suitable for security-critical applications, ie in particular for determining an overall error description of a security-critical computer program.
Bevorzugte Weiterbildungen der Erfindung ergeben sich aus den abhängigen Ansprüchen.Preferred developments of the invention result from the dependent claims.
Die Kontrollflußbeschreibung und/oder die Datenflußbeschrei- bung kann/können in Form eines Kontrollflußgraphen bzw. eines Datenflußgraphen vorliegen.The control flow description and / or the data flow description can be in the form of a control flow graph or a data flow graph.
Die Fehlerbeschreibung kann in Form eines gespeicherten Fehlerbaums vorliegen und die Elementenfehlerbeschreibung kann als Elementenfehlerbaum ermittelt werden. In diesem Fall kann die Gesamtfehlerbeschreibung als Gesamtfehlerbaum ermittelt werden.The error description can be in the form of a stored error tree and the element error description can be determined as an element error tree. In this case, the overall error description can be determined as an overall error tree.
Durch diese Weiterbildung ist eine standardisierte Darstel- lung einer Fehlerbeschreibung möglich, was es einem Benutzer der Fehlerbeschreibung erheblich vereinfacht, diese zu analysieren.This further development enables a standardized description of an error description, which makes it considerably easier for a user of the error description to analyze it.
Die Gesamtfehlerbeschreibung kann in einer Weiterbildung ein- gesetzt werden zur Fehleranalyse des Teils des Computerprogramms .The overall error description can be used in a further development for error analysis of the part of the computer program.
Diese Weiterbildung weist insbesondere den Vorteil auf, daß eine automatisierte, zuverlässige Fehleranalyse, bei Vorlie- gen der Fehlerbeschreibungen in Form von Fehlerbäumen sogar eine gemäß den Fehlerbaumanalyseverfahren "normierte" Analyse der Fehlerbeschreibung möglich wird.This further development has the particular advantage that an automated, reliable error analysis, and in the case of the error descriptions in the form of error trees, even an analysis of the error description "standardized" according to the error tree analysis method is possible.
In einer weiteren Ausgestaltung wird die Gesamtfehlerbe- Schreibung als Gesamtfehlerbaum ermittelt und der Gesamtfehlerbaum wird hinsichtlich vorgebbarer Rahmenbedingungen verändert. Die Veränderung kann durch Hinzufügen eines Ergänzungsfehlerbaums erfolgen.In a further embodiment, the overall error description is determined as an overall error tree and the overall error tree is changed with regard to predefinable framework conditions. The change can be made by adding a supplementary fault tree.
Ein Ausführungsbeispiel der Erfindung ist in den Figuren dargestellt und wird im weiteren näher erläutert:An embodiment of the invention is shown in the figures and is explained in more detail below:
Es zeigenShow it
Figur 1 einen Computer, mit dem das Verfahren gemäß dem Ausführungsbeispiel durchgeführt wird; Figur 2 ein Ablaufdiagramm, in dem die einzelnen Verfahrensschritte des Verfahrens gemäß dem Ausführungsbeispiel dargestellt sind; Figur 3 eine Darstellung eines allgemeinen Fehlerbaums, wie er für ein Referenzelement prinzipiell gebildet wird; Figuren 4a bis 4c einen Kontrollflußgraphen (Figur 4a) , einen Slice (Figur 4b) und einen Fehlerbaum (Figur 4c) für eine Anweisungssequenz als Referenzelement eines Com- puterprogramms;1 shows a computer with which the method according to the embodiment is carried out; FIG. 2 shows a flow chart in which the individual method steps of the method according to the exemplary embodiment are shown; FIG. 3 shows a general fault tree, as it is principally formed for a reference element; 4a to 4c a control flow graph (FIG. 4a), a slice (FIG. 4b) and a fault tree (FIG. 4c) for an instruction sequence as a reference element of a computer program;
Figuren 5a bis 5c einen Kontrollflußgraphen (Figur 5a), einen Slice (Figur 5b) und einen Fehlerbaum (Figur 5c) für eine Auswahlsequenz als Referenzelement eines Computerprogramms; Figur 6a bis 6c einen Kontrollflußgraphen (Figur 6a), einen Slice (Figur 6b) und einen Fehlerbaum (Figur 6c) für eine Schleife als Referenzelement eines Computerprogramms; Figur 7 ein Kontrollflußgraph mit Datenflußgraph zu einem Computerprogramm gemäß dem Ausführungsbeispiel;5a to 5c a control flow graph (FIG. 5a), a slice (FIG. 5b) and an error tree (FIG. 5c) for a selection sequence as a reference element of a computer program; 6a to 6c a control flow graph (FIG. 6a), a slice (FIG. 6b) and an error tree (FIG. 6c) for a loop as a reference element of a computer program; FIG. 7 shows a control flow graph with a data flow graph for a computer program according to the exemplary embodiment;
Figuren 8a und 8b einen Slice der Ausgabe der Variable maxFigures 8a and 8b a slice of the output of the variable max
(Figur 8a) bzw. einen Slice zu der Variable avr (Figur 8b) zu dem Programm gemäß dem Ausführungsbei- spiel; Figur 9 den Slice für die Variable avr, in dem eine Struktur der Schleife aus dem Programm des Ausführungsbei- spiels hervorgehoben ist; Figur 10 einen Fehlerbaum für die Annahme, daß die Variable avr fehlerhaft ist; Figur 11 den Gesamtfehlerbau gemäß Figur 10, wobei redundante Ereignisse aus dem Gesamtfehlerbaum gemäß Figur 10 zu einem Ereignis zusammengefaßt worden sind.(FIG. 8a) or a slice for the variable avr (FIG. 8b) for the program according to the exemplary embodiment; FIG. 9 shows the slice for the variable avr, in which a structure of the loop is highlighted from the program of the exemplary embodiment; FIG. 10 shows an error tree for the assumption that the variable avr is incorrect; FIG. 11 shows the overall fault construction according to FIG. 10, redundant events from the overall fault tree according to FIG. 10 having been combined into one event.
Fig.l zeigt einen Computer 100 mit dem das im weiteren beschriebene Verfahren durchgeführt wird.Fig.l shows a computer 100 with which the method described below is carried out.
Der Computer 100 weist einen Prozessor 101 auf, der über einen Bus 103 mit einem Speicher 102 verbunden ist. Mit dem Bus 103 ist ferner eine Eingangs-/Ausgangsschnittstelle 106 verbunden.The computer 100 has a processor 101 which is connected to a memory 102 via a bus 103. An input / output interface 106 is also connected to the bus 103.
In dem Speicher 102 ist ein Computerprogramm 104 gespeichert, für das auf die im folgenden beschriebene Weise eine Gesamtfehlerbeschreibung ermittelt wird. Ferner ist in dem Speicher 102 ein Programm 105 gespeichert, durch das das im weiteren beschriebene Verfahren realisiert ist. Ferner sind in dem Speicher Fehlerbeschreibungen 115 unterschiedlicherA computer program 104 is stored in the memory 102, for which an overall error description is determined in the manner described below. A program 105 is also stored in the memory 102, by means of which the method described below is implemented. Furthermore, error descriptions 115 are different in the memory
Referenzelemente eines Computerprogramms gespeichert. Mit einer Fehlerbeschreibung eines Referenzelements werden mögliche Fehler des jeweiligen Referenzelements beschrieben. Verschiedene Referenzelemente und den Referenzelementen zugeordnete Fehlerbeschreibungen werden im weiteren detailliert erläutert.Reference elements of a computer program saved. An error description of a reference element describes possible errors of the respective reference element. Various reference elements and error descriptions assigned to the reference elements are explained in detail below.
Mit der Eingangs-/Ausgangsschnittstelle 106 ist über eine erste Verbindung 107 eine Tastatur 108 verbunden. Über eine zweite Verbindung 109 ist die Eingangs-/Ausgangsschnittstelle 106 mit einer Computermaus 110 und über eine dritte Verbindung 111 ist die Eingangs-ΛAusgangsschnittstelle 106 mit einem Bildschirm 112 verbunden, auf dem die ermittelte Gesamtfehlerbeschreibung des Computerprogramms 104 dargestellt wird. Über eine vierte Verbindung 113 ist die Eingangs-A keyboard 108 is connected to the input / output interface 106 via a first connection 107. The input / output interface 106 is connected to a computer mouse 110 via a second connection 109, and the input / output interface 106 is connected to a screen 112 via a third connection 111, on which the determined overall error description of the computer program 104 is displayed. Via a fourth connection 113, the input
/Ausgangsschnittsteile 106 mit einem externen Speichermedium 114 verbunden. Fig.2 zeigt in einem Blockschaltbild die Vorgehensweise gemäß dem im weiteren beschriebenen Ausführungsbeispiel./ Output cut parts 106 connected to an external storage medium 114. 2 shows in a block diagram the procedure according to the exemplary embodiment described below.
Aus dem gespeicherten Computerprogramm 104 werden ein Kontrollflußgraph 201 und ein Datenflußgraph 202 für das Computerprogramm 104 ermittelt.A control flow graph 201 and a data flow graph 202 for the computer program 104 are determined from the stored computer program 104.
Aus dem Computerprogramm werden einzelne Programmelemente ausgewählt (Schritt 203) . Für jedes ausgewählte Programmelement wird unter Verwendung einer gespeicherten Fehlerbeschreibung, die einen zu dem ausgewählten Programmelement korrespondierenden Referenzelement zugeordnet ist, eine Elementenfehlerbeschreibung ermittelt (Schritt 204) . Mit der Elementenfehlerbeschreibung werden mögliche Fehler des jeweiligen ausgewählten Programmelements beschrieben.Individual program elements are selected from the computer program (step 203). For each selected program element, an element error description is determined using a stored error description that is assigned to a reference element corresponding to the selected program element (step 204). The element error description describes possible errors of the selected program element.
Ausgehend von einem von einem Benutzer vorgegebenen zu untersuchenden Fehlerereignis in dem Computerprogramm (unerwünsch- tes Ereignis) wird in einem letzten Schritt (Schritt 205) eine Gesamtfehlerbeschreibung des Computerprogrammes für den zu untersuchenden Fehlerfall ermittelt aus den Elementenfehlerbeschreibungen, wobei der Kontrollflußgraph und der Datenflußgraph berücksichtigt werden.Starting from an error event to be examined in the computer program (undesired event) specified by a user, in a last step (step 205) an overall error description of the computer program for the error case to be examined is determined from the element error descriptions, taking into account the control flow graph and the data flow graph .
Der ermittelte Gesamtfehlerbaum wird dem Benutzer auf dem Bildschirm 112 dargestellt.The determined overall fault tree is displayed to the user on the screen 112.
Fig.3 zeigt die grundlegende Vorgehensweise bei der Erstel- lung eines Fehlerbaums, wie sie im Rahmen des Ausgangsbeispiels verwendet worden ist zur Bildung der im weiteren beschriebenen Fehlerbäume zu den Referenzelementen.3 shows the basic procedure for creating an error tree, as was used in the context of the starting example, to form the error trees described below for the reference elements.
Zu einem von einem Benutzer ausgewählten Ereignis 301 ist zu ermitteln, wie das ausgewählte fehlerhafte Ereignis entstehen kann. Bei einem Computerprogramm kann eine fehlerhafte Ausgabe einer Variablen als ausgewähltes fehlerhaftes Ereignis (unerwünschtes Ereignis) 301 verursacht werden durch einen Kontrollflußfehler 303 und/oder einen Datenfehler 304 (INKLUSIV-ODER-Verknüpfung 302) .For an event 301 selected by a user, it is to be determined how the selected faulty event can arise. In a computer program, an erroneous output of a variable can be a selected erroneous event (undesirable event) 301 are caused by a control flow error 303 and / or a data error 304 (INCLUSIVE-OR link 302).
Unter einem Kontrollflußfehler 303 ist eine fehlerhafte An- steuerung der Verarbeitung der jeweiligen Variablen zu verstehen.A control flow error 303 is to be understood as an incorrect control of the processing of the respective variables.
Unter dem Datenflußfehler 304 ist ein Fehler zu verstehen, der durch fehlerhafte Daten bei der Verarbeitung entsteht.The data flow error 304 is to be understood as an error that arises from incorrect data during processing.
Der Datenflußfehler 304 kann in dem aktuell betrachteten Verarbeitungsschritt neu entstehen (Block 306) und/oder er kann schon vorhanden gewesen sein und lediglich durch Fehlerpropa- gation erhalten bleiben Block 307) (INKLUSIV-ODER-Verknüpfung 305) .The data flow error 304 can arise again in the processing step currently under consideration (block 306) and / or it can already have been present and can only be retained by error propagation (block 307) (INCLUSIVE-OR link 305).
Ausgehend von diesen Überlegungen werden im weiteren für folgende Elemente eines Computerprogrammes jeweils der entspre- chende Fehlerbaum, ein die Anweisung beschreibender Slice sowie ein Kontrollflußgraph dargelegt:Based on these considerations, the corresponding error tree, a slice describing the instruction and a control flow graph are presented for the following elements of a computer program:
- eine Anweisungssequenz,- a sequence of instructions,
- ein Auswahlelement,- a selection element,
- ein Schleifenelement.- a loop element.
AnweisungssequenzStatement sequence
Die Anweisungssequenz 401 weist die in Fig.4a dargestellten drei Anweisungen auf. In einer ersten Anweisung 402 wird einer ersten Variable j der Wert 3 zugewiesen (j := 3) . Durch eine zweite Anweisung 403 wird einer zweiten Variable k der Wert 2 zugeordnet (k := 2) . Durch eine dritte Anweisung 404 wird eine Summe über die erste Variable und die zweite Varia- ble gebildet (i := j + k) . Es wird gemäß der Vorgehensweise aus [2] zu dieser Anweisungssequenz 401 ein Slice 410 gebildet, wie er in Fig. b dargestellt ist. Die erste Anweisung 402 und die zweite Anweisung 403 haben beide Auswirkungen auf die dritte Anweisung 404, was durch zwei Pfeile 411, 412 in dem Slice 410 dargestellt ist.The instruction sequence 401 has the three instructions shown in FIG. In a first instruction 402, the value 3 is assigned to a first variable j (j: = 3). A second instruction 403 assigns the value 2 to a second variable k (k: = 2). A third instruction 404 forms a sum over the first variable and the second variable (i: = j + k). A slice 410 is formed for this instruction sequence 401 in accordance with the procedure from [2], as is shown in FIG. B. The first instruction 402 and the second instruction 403 both affect the third instruction 404, which is represented by two arrows 411, 412 in the slice 410.
Zu dem Kontrollflußgraph 401 ergibt sich der in Fig. c dargestellte Fehlerbaum 420 für folgendes vorgegebenes unerwünsch- tes Ereignis 421:For the control flow graph 401, the fault tree 420 shown in FIG. C results for the following predetermined undesired event 421:
"Variable i ist nach der dritten Anweisung fehlerhaft"."Variable i is incorrect after the third statement".
Das fehlerhafte Ereignis 421 kann durch einen Fehler bei der betrachteten dritten Anweisung 404 selbst bei bis zu diesem Anweisungsschritt korrekten Daten erzeugt worden sein (Element 422 in Fig.4c) . Das fehlerhafte Ereignis 421 kann jedoch auch durch verfälschte Eingabedaten der dritten Anweisung verursacht werden, d.h. durch INKLUSIV-ODER-Verknüpfung 424 der Ereignisse, daß die zweite Variable k nach der zweitenThe faulty event 421 may have been generated by an error in the considered third instruction 404 even with data correct up to this instruction step (element 422 in FIG. 4c). However, the erroneous event 421 can also be caused by corrupted input data of the third instruction, i.e. by INCLUSIVE-ORing 424 the events that the second variable k after the second
Anweisung fehlerhaft war (Element 425) und/oder daß die erste Variable j nach der ersten Anweisung 402 fehlerhaft war (Element 426) . Das Ergebnis der ersten INKLUSIV-ODER-Verknüpfung 424 wird inklusiv-oder verknüpft mit dem Ereignis, daß die dritte Anweisung fehlerhaft ist (INKLUSIV-ODER-Verknüpfung 423) .Instruction was incorrect (element 425) and / or that the first variable j was incorrect after the first instruction 402 (element 426). The result of the first INCLUSIVE-OR link 424 is included or linked to the event that the third instruction is faulty (INCLUSIVE-OR link 423).
AuswahlelementSelection element
Bei einem Auswahlelement als Referenzelement müssen Fehlermöglichkeiten der Datenflüsse und der Kontrollflüsse innerhalb des Computerprogramms beachtet werden.With a selection element as a reference element, the possibility of errors in the data flows and the control flows within the computer program must be taken into account.
In den Fig.5a bis Fig.5c ist ein Kontrollflußgraph 501 (vgl. Fig.5a), ein Slice 520 (vgl. Fig.5b) sowie ein Fehlerbaum 540 (vgl. Fig.5c) für eine If-Then-Else-Anweisung als Auswahlelement dargestellt.In FIGS. 5 a to 5 c there is a control flow graph 501 (see FIG. 5 a), a slice 520 (see FIG. 5 b) and an error tree 540 (see Fig. 5c) for an If-Then-Else statement as a selection element.
Der Kontrollflußgraph 501 umfaßt folgende sechs Anweisungen: - Eine erste Anweisung 502, mit der einer ersten Variable j der Wert 3 zugeordnet wird (j := 3),The control flow graph 501 comprises the following six instructions: a first instruction 502 with which the value 3 is assigned to a first variable j (j: = 3),
- eine zweite Anweisung 503, mit der einer zweiten Variable k ein vorgebbarer Wert zugeordnet wird (k := ...),a second instruction 503, with which a predeterminable value is assigned to a second variable k (k: = ...),
- eine dritte Anweisung 504, in der überprüft wird, ob die zweite Variable k einen Wert größer als 0 aufweist; ist der Wert der zweiten Variable größer 0, dann verzweigt die Anweisung zu einer vierten Anweisung 505, sonst zu einer fünften Anweisung 506,a third instruction 504, in which it is checked whether the second variable k has a value greater than 0; if the value of the second variable is greater than 0, the instruction branches to a fourth instruction 505, otherwise to a fifth instruction 506,
- die vierte Anweisung 505, in der einer dritten Variable i der Wert der zweiten Variable k zugeordnet wird (i := k) ,the fourth instruction 505, in which a third variable i is assigned the value of the second variable k (i: = k),
- eine fünfte Anweisung 506, in der der dritten Variable i der Wert der zweiten Variable k mit negativem Vorzeichen zugeordnet wird (i:=-k),a fifth instruction 506 in which the third variable i is assigned the value of the second variable k with a negative sign (i: = - k),
- eine sechste Anweisung 507, in der die dritte Variable i in beliebiger Weise weiterverarbeitet wird.a sixth instruction 507 in which the third variable i is processed in any way.
Zu dem in Fig.5a dargestellten Kontrollflußgraphen 501 ergibt sich für das Auswahlelement der in Fig.5b dargestellte Slice 520.The control flow graph 501 shown in FIG. 5 a results in the slice 520 shown in FIG. 5 b for the selection element.
Durchgezogene Kanten in dem Slice 520 stellen eine Datenabhängigkeit der unterschiedlichen Anweisungen voneinander dar.Solid edges in the slice 520 represent a data dependency of the different instructions from one another.
Mit gestrichelten Kanten werden Kontrollabhängigkeiten der entsprechenden Anweisungen voneinander angegeben.Control dependencies of the corresponding instructions from one another are indicated with dashed edges.
Für die beiden Kantentypen gelten die folgenden Definitionen:The following definitions apply to the two edge types:
- gestrichelte Kanten, im weiteren als Kontrollkanten bezeichnet, sind von Anweisungen, die eine prädikative Refe- renz enthalten (Ausfallkonstrukte, Schleifensteuerung) , auf die unmittelbar kontrollierten Anweisungen gerichtet, d.h. auf jene Anweisungen, die nur ausgeführt werden, wenn das Prädikat einen bestimmten Wert hat. Kontrollkanten werden nur zwischen der kontrollierenden Anweisung und unmittelbar eingeschachtelten Anweisungen gezogen. Ist in einem kontrollierten Block eine weitere Kontrollebene ein- geschachtelt, so werden keine Kontrollkanten gezogen, die mehr als eine Ebene überstreichen. Da eine Kontrollbeziehung transitiv ist, kann diese mittelbare Kontrolle aus dem Slice durch Ausnutzung der Transitivität geschlossen werden. - durchgezogene Kanten, im weiteren als Datenflußkanten bezeichnet, sind von Anweisungen, in denen eine Variable definiert wird, auf Anweisungen gerichtet, in denen diese Variable referenziert wird. Die betrachtete Variable darf zwischen der Definition und der Referenz nicht erneut de- finiert werden. Man bezeichnet dies als definitionsfreien Pfad bezüglich der betrachteten Variablen.- Dashed edges, hereinafter referred to as control edges, are directed from instructions which contain a predictive reference (failure constructs, loop control) to the instructions which are directly controlled, ie to those instructions which are only executed if the predicate has a certain value. Control edges are only drawn between the control instruction and immediately nested instructions. If another control level is nested in a controlled block, no control edges are drawn that cover more than one level. Since a control relationship is transitive, this indirect control can be inferred from the slice by using transitivity. - Solid edges, hereinafter referred to as data flow edges, are directed from instructions in which a variable is defined to instructions in which this variable is referenced. The considered variable must not be redefined between the definition and the reference. This is known as the path free of definition with regard to the variables under consideration.
Der Slice wird ermittelt, indem ausgehend von der Anweisung mit der betrachteten Variablen, für die das unerwünschte Er- eignis vorgegeben wird, der Kontrollflußgraph gegen die Kantenrichtung nach Definition der betrachteten Variablen durchsucht wird. Existieren zu der Definition berechnende Referenzen, so wird das Verfahren rekursiv fortgesetzt, bis keine zusätzlichen Knoten mehr gefunden werden. Die auf diese Weise gefundenen Abhängigkeiten zwischen Anweisungen sind Datenabhängigkeiten. Befindet sich ein betrachteter Knoten in einem Block, dessen Ausführung von einer Entscheidung direkt gesteuert wird, so stellt dies eine Kontrollabhängigkeit dar. Für die prädikativen Referenzen der in der Entscheidung be- teiligten Variablen werden Knoten mit entsprechenden Definitionen - also Datenflußabhängigkeiten - rekursiv gesucht, die weitere Kontrollabhängigkeiten besitzen.The slice is determined by searching the control flow graph against the edge direction for the definition of the variables under consideration, based on the instruction with the variables under consideration, for which the undesired event is specified. If there are computational references to the definition, the process continues recursively until no additional nodes are found. The dependencies between statements found in this way are data dependencies. If a node under consideration is in a block, the execution of which is directly controlled by a decision, this represents a control dependency. For the predictive references of the variables involved in the decision, nodes with corresponding definitions - that is, data flow dependencies - are recursively searched for have further control dependencies.
Fig.5b zeigt den zu dem Ausfallelement gehörenden Slice 520 mit entsprechenden Kontrollkanten und Datenflußkanten. Fig.5c zeigt den Fehlerbaum 540 für das vorgegebene Ereignis "die dritte Variable i ist vor der 6. Anweisung fehlerhaft" 541.5b shows the slice 520 belonging to the failure element with corresponding control edges and data flow edges. 5c shows the error tree 540 for the specified event "the third variable i is faulty before the 6th instruction" 541.
Folgende Ereignisse führen in INKLUSIV-ODER-Verknüpfung 542 zu dem fehlerhaften Ereignis 541:The following events lead to faulty event 541 in INCLUSIVE-OR operation 542:
- eine UND-Ver nüpfung 543 der Ereignisse, daß die Entscheidung gemäß der dritten Anweisung 504 wahr ist (Element 544) und einem Ergebnis einer INKLUSIV-ODER-Verknüpfung 545 der Ereignisse, daß die vierte Anweisung 505 fehlerhaft ist (Element 546) und/oder die erste Variable j nach der ersten Anweisung 502 fehlerhaft ist (Element 547);an AND operation 543 of the events that the decision according to the third instruction 504 is true (element 544) and a result of an INCLUSIVE-OR operation 545 of the events that the fourth instruction 505 is incorrect (element 546) and / or the first variable j is incorrect after the first instruction 502 (element 547);
- eine UND-Verknüpfung 550 der Ereignisse, daß die Entscheidung gemäß der dritten Anweisung 504 falsch ist (Element 551) mit einem Ergebnis einer INKLUSIV-ODER-Verknüpfung 552 der Ereignisse, daß die fünfte Anweisung fehlerhaft ist (Element 553) und/oder daß die erste Variable j nach der ersten Anweisung 502 fehlerhaft ist (Element 554);an AND operation 550 of the events that the decision according to the third instruction 504 is wrong (element 551) with a result of an INCLUSIVE-OR operation 552 of the events that the fifth instruction is faulty (element 553) and / or that the first variable j after the first instruction 502 is incorrect (element 554);
- eine INKLUSIV-ODER-Verknüpfung 560 der Ereignisse: Die Entscheidung gemäß der dritten Anweisung 504 ist fehlerhaft (Element 561) und/oder die zweite Variable k ist nach der zweiten Anweisung 503 fehlerhaft (Element 562) .an INCLUSIVE-OR link 560 of the events: the decision according to the third instruction 504 is incorrect (element 561) and / or the second variable k is incorrect after the second instruction 503 (element 562).
Mehrfach-AuswahlelementMultiple selection element
Ein Mehrfach-Auswahlelement als Referenzelement kann nach dem oben beschriebenen Schema durch Aufbrechen der Mehrfachauswahl in eine Kaskade von zweiseitigen Auswahlelementen, die gemäß dem oberen Vorgehen bearbeitet werden, behandelt werden, um somit einen Fehlerbaum für ein Mehrfach- Auswahlelement zu ermitteln.A multiple selection element as a reference element can be treated according to the above-described scheme by breaking the multiple selection into a cascade of two-sided selection elements which are processed in accordance with the above procedure, in order thus to determine an error tree for a multiple selection element.
Schleife Die Fig.6a bis Fig.6c zeigen für das Referenzelement einer Schleife einen Fehlerbaum 601 (vgl. Fig.6a), den entsprechenden Slice 620 (vgl. Fig.6b) sowie den zugehörigen Fehlerbaum 640 (vgl. Fig.6c) .loop FIGS. 6 a to 6 c show an error tree 601 (see FIG. 6 a), the corresponding slice 620 (see FIG. 6 b) and the associated error tree 640 (see FIG. 6 c) for the reference element of a loop.
Der Kontrollflußgraph 601 für ein Schleifenelement weist folgende sieben Anweisungen auf:The control flow graph 601 for a loop element has the following seven instructions:
- Eine erste Anweisung 602, mit der einer erste Variable i der Wert 0 zugeordnet wird (i := 0), - eine zweite Anweisung 603, mit der einer zweiten Variable j ein Wert frei zugeordnet wird (j := ...),- A first instruction 602, with which a value i is assigned to a first variable i (i: = 0), - a second instruction 603, with which a value is freely assigned to a second variable j (j: = ...),
- eine dritte Anweisung 604, durch die einer dritten Variable k ein weiterer Wert frei vorgegeben wird (k := ...),a third instruction 604, by means of which a third variable k is given a further value (k: = ...),
- eine vierte Anweisung 605, die als Schleifenanweisung eine Bedingung angibt, daß eine fünfte Anweisung sowie eine sechste Anweisung solange durchgeführt werden, solange der Wert der zweiten Variablen j > 0 ist (WHILE j > 0 DO) ,a fourth instruction 605, which specifies as a loop instruction a condition that a fifth instruction and a sixth instruction are carried out as long as the value of the second variable is j> 0 (WHILE j> 0 DO),
- eine fünfte Anweisung 606, in der der ersten Variable i ein Wert zugeordnet wird, der sich ergibt aus der Summe des bisherigen Werts der ersten Variable sowie dem Produkt aus der zweiten Variable und der dritten Variable (i := i + k * j),a fifth instruction 606, in which the first variable i is assigned a value which results from the sum of the previous value of the first variable and the product of the second variable and the third variable (i: = i + k * j) ,
- eine sechste Anweisung 607, durch die der zweiten Variable j ein Wert zugewiesen wird, der sich ergibt durch Vermin- derung des ursprünglichen Werts der zweiten Variable j um den Wert 1 (j := j - 1) ,a sixth instruction 607, by means of which the second variable j is assigned a value which is obtained by reducing the original value of the second variable j by the value 1 (j: = j − 1),
- eine siebte Anweisung 608, in der die erste Variable i in vorgebbarer Weise weiterbearbeitet wird (... := i ...).a seventh instruction 608, in which the first variable i is further processed in a predefinable manner (...: = i ...).
Fig.6b zeigt den entsprechenden Slice 620 zu dem in Fig.6a dargestellten Kontrollflußgraphen 601 mit zugehörigen Kontrollflußkanten und Datenflußkanten.FIG. 6b shows the corresponding slice 620 for the control flow graph 601 shown in FIG. 6a with associated control flow edges and data flow edges.
Der in Fig.6c dargestellte Fehlerbaum 640 wird gebildet für das vorgegebene Ereignis 641, daß die "erste Variable i vor der siebten Anweisung fehlerhaft" ist. Der Fehlerbaum 640 ergibt sich durch INKLUSIV-ODER- Verknüpfung 642 folgender vier Ereignisse:The fault tree 640 shown in FIG. 6c is formed for the predetermined event 641 that the "first variable i before the seventh instruction is faulty". The error tree 640 results from the INCLUSIVE-OR link 642 of the following four events:
- Ein erstes Ereignis 643, das beschreibt, daß die erste Variable i nach der ersten Anweisung 602 fehlerhaft ist, - eine UND-Verknüpfung 644 aus den Ereignissen, daß derA first event 643, which describes that the first variable i is incorrect after the first instruction 602, an AND operation 644 from the events that the
Schleifenrumpf der Schleife mindestens zweimal durchlaufen worden ist (Element 645) und dem Ereignis, daß die sechste Anweisung 607 fehlerhaft ist (646),Loop body has been run through at least twice (element 645) and the event that the sixth instruction 607 is incorrect (646),
- eine UND-Verknüpfung 650 des Ereignisses, daß der Schlei- fenrumpf mindestens einmal ausgeführt wurde (Element 651) und einer IΝKLUSIV-ODER-Verknüpfung 652 folgende vier Ereignisse: a) die fünfte Anweisung 606 ist fehlerhaft (Element 653), b) die erste Variable i ist nach der ersten Anweisung feh- lerhaft (Element 654) c) die zweite Variable j ist nach der zweiten Anweisung fehlerhaft (Element 655), d) die dritte Variable k ist nach der dritten Anweisung fehlerhaft (Element 656), - eine IΝKLUSIV-ODER-Verknüpfung 660 folgender drei Ereignisse: e) die Entscheidung gemäß der vierten Anweisung 605 ist fehlerhaft (Element 661), f) die zweite Variable j ist nach der zweiten Anweisung 603 fehlerhaft (Element 662), g) eine UND-Verknüpfung 663 der Ereignisse, daß die sechste Anweisung fehlerhaft ist (Element 664) mit dem Ereignis, daß der Schleifenrumpf mindestens einmal durchlaufen worden ist (Element 665) .- an AND operation 650 of the event that the loop body was executed at least once (element 651) and an IΝCLUSIVE-OR operation 652 following four events: a) the fifth instruction 606 is faulty (element 653), b) the first variable i is incorrect after the first instruction (element 654) c) the second variable j is incorrect after the second instruction (element 655), d) the third variable k is incorrect after the third instruction (element 656), an IΝCLUSIVE-OR operation 660 of the following three events: e) the decision according to the fourth instruction 605 is incorrect (element 661), f) the second variable j is incorrect after the second instruction 603 (element 662), g) an AND Link 663 of the events that the sixth instruction is incorrect (element 664) with the event that the loop body has been run through at least once (element 665).
Die oben beschriebenen Fehlerbäume, die den einzelnen Referenzelementen zugeordnet sind, sind in dem Speicher 102 als Fehlerbäume 115 gespeichert. Fig.7 zeigt einen Kontrollflußgraphen 700 zu folgendem Computerprogramm:The error trees described above, which are assigned to the individual reference elements, are stored in the memory 102 as error trees 115. 7 shows a control flow graph 700 for the following computer program:
input (n) ; input (a) ; max:=0; sum:=0; i : =2 ;input (n); input (a); max: = 0; sum: = 0; i: = 2;
WHILE i =n DO IF max < a[i]WHILE i = n DO IF max <a [i]
THEN max:= a[i] sum:= sum + a[i] i:= i + 1 avr:= sum/n; output (max) ; Output (avr) ;THEN max: = a [i] sum: = sum + a [i] i: = i + 1 avr: = sum / n; output (max); Output (avr);
Zu dem in Fig.7 dargestellten Kontrollflußgraphen 700 mit 13 Anweisungen (Bezugszeichen 1, 2, 3, ..., 13) zeigt Fig.8a den zugehörigen Slice 800 zu der Variablen max und Fig.8b den zugehörigen Slice 810 zu der Variablen avr. Die Numerierung der einzelnen Anweisungen in den Slices entspricht der Numerierung der einzelnen Anweisungen in dem Kontrollflußgraphen 700 aus Fig.7.For the control flow graph 700 shown in FIG. 7 with 13 instructions (reference numerals 1, 2, 3, ..., 13), FIG. 8a shows the associated slice 800 for the variable max and FIG. 8b shows the associated slice 810 for the variable avr . The numbering of the individual instructions in the slices corresponds to the numbering of the individual instructions in the control flow graph 700 from FIG. 7.
Fig.9 zeigt den Slice 900 für die Variable avr, wie er in Fig.8b dargestellt ist. Die Struktur des in dem oben dargestellten Programm enthaltenen Schleifenelements ist durch Fettdruck hervorgehoben. Diese Struktur entspricht dem in Fig.6b dargestellten Slice für ein Schleifenelement.FIG. 9 shows the slice 900 for the variable avr, as shown in FIG. 8b. The structure of the loop element contained in the program shown above is highlighted in bold. This structure corresponds to the slice shown in FIG. 6b for a loop element.
Ein Gesamtfehlerbaum 1000 für das oben dargestellte Computerprogramm ist in Fig.10 dargestellt. Der Gesamtfehlerbaum für das Computerprogramm wird durch Instantiieren des entspre- chenden Fehlerbaums, der dem Referenzelement zugeordnet ist, das dem ausgewählten Programmelement entspricht, erzeugt. Durch rückwärts gerichtetes Vorgehen ausgehend von dem vorgegebenen unerwünschten Ereignis wird somit unter Verwendung der den Referenzelementen zugeordneten Fehlerbäume der Gesamtfehlerbaum 1000 ermittelt.An overall fault tree 1000 for the computer program shown above is shown in FIG. The overall fault tree for the computer program is generated by instantiating the corresponding fault tree that is assigned to the reference element that corresponds to the selected program element. By proceeding backwards starting from the predetermined undesired event, the overall error tree 1000 is thus determined using the error trees assigned to the reference elements.
In Fig.10 ist der Fehlerbaum 1000 zu dem Ereignis, daß "die Variable avr vor der dreizehnten Anweisung fehlerhaft" ist (Element 1001) . Die Variable avr kann vor der dreizehnten Anweisung 13 fehlerhaft sein aufgrund mindestens eines der fol- genden drei Ereignisse, wie dies auch in dem in Fig.9 dargestellten Slice 900 für die Variable avr dargestellt ist (INKLUSIV-ODER-Verknüpfung 1002) :In Fig. 10, the fault tree 1000 is related to the event that "the variable avr is faulty before the thirteenth instruction" (element 1001). The variable avr may be incorrect before the thirteenth instruction 13 due to at least one of the following three events, as is also shown in the slice 900 for the variable avr shown in FIG. 9 (INCLUSIVE-OR operation 1002):
- Eine Eingangsvariable n ist nach der ersten Anweisung 1 fehlerhaft (Element 1003), - die elfte Anweisung 11 ist fehlerhaft (Element 1004),- An input variable n is incorrect after the first instruction 1 (element 1003), - The eleventh instruction 11 is incorrect (element 1004),
- der Wert der Variablen sum vor der elften Anweisung 11 ist fehlerhaft (Element 1005) .- The value of the variable sum before the eleventh instruction 11 is incorrect (element 1005).
Die Variable sum ist vor der elften Anweisung 11 fehlerhaft (Element 1005), wenn mindestens eines der folgenden Ereignisse erfüllt ist (INKLUSIV-ODER-Verknüpfung 1006) :The variable sum is faulty before the eleventh instruction 11 (element 1005) if at least one of the following events is fulfilled (INCLUSIVE-OR link 1006):
- Die Variable sum ist nach der vierten Anweisung 4 fehlerhaft (Element 1007) ,- The variable sum is incorrect after the fourth statement 4 (element 1007),
- eine UND-Verknüpfung 1008 des Ereignisses, daß mindestens zweimal der Schleifenrumpf ausgeführt worden ist (Elementan AND operation 1008 of the event that the loop body has been executed at least twice (element
1009) mit dem Ereignis, daß die zehnte Anweisung 10 fehlerhaft ist (Element 1010),1009) with the event that the tenth instruction 10 is incorrect (element 1010),
- eine UND-Verknüpfung 1011 des Ereignisses, daß mindestens einmal der Schleifenrumpf ausgeführt worden ist (Element 1012) mit dem Ergebnis einer INKLUSIV-ODER-Verknüpfung 1013 folgender vier Ereignisse: a) die neunte Anweisung 9 ist fehlerhaft (Element 1014), b) die Variable sum ist nach der vierten Anweisung 4 fehlerhaft (Element 1015) , c) die Variable i ist nach der fünften Anweisung 5 fehlerhaft (Element 1016) , d) die Variable a ist nach der zweiten Anweisung 2 fehlerhaft (Element 1017) ,an AND operation 1011 of the event that the loop body has been executed at least once (element 1012) with the result of an INCLUSIVE-OR operation 1013 of the following four events: a) the ninth instruction 9 is incorrect (element 1014), b) the variable sum is incorrect after the fourth instruction 4 (element 1015), c) the variable i is incorrect after the fifth instruction 5 (element 1016), d) the variable a is incorrect after the second instruction 2 (element 1017),
- eine INKLUSIV-ODER-Verknüpfung 1018 folgender Ereignisse: e) die Entscheidung gemäß der sechsten Anweisung ist feh- lerhaft (Element 1019), f) die Variable i ist nach der fünften Anweisung fehlerhaft (Element 1020) , g) die Variable n ist nach der ersten Anweisung fehlerhaft (Element 1021) , h) eine UND-Verknüpfung 1022 des Ereignisses, daß die 10. Anweisung fehlerhaft ist (Element 1023) mit dem Ereignis, daß mindestens einmal der Schleifenrumpf ausgeführt worden ist (Element 1024) .- An INCLUSIVE-OR operation 1018 of the following events: e) the decision according to the sixth instruction is incorrect (element 1019), f) the variable i is incorrect after the fifth instruction (element 1020), g) the variable is n after the first instruction is faulty (element 1021), h) an AND operation 1022 of the event that the 10th instruction is faulty (element 1023) with the event that the loop body has been executed at least once (element 1024).
Der Fehlerbaum 1000 aus Fig.10 wird zur anschaulicheren Darstellung dahingehend verändert, daß Ereignisse, die in dem Fehlerbaum 1000 mehrfach dargestellt sind, zu einem Knoten eines Ursache-Wirkungs-Graphen 1100 (vgl. Fig.11) zusammengefaßt werden.The error tree 1000 from FIG. 10 is changed so that events that are shown several times in the error tree 1000 are combined to form a node of a cause and effect graph 1100 (see FIG. 11).
Auf den in Fig.10 dargestellten Fehlerbaum 1000 wird ein Fehlerbaumanalyseverfahren, wie in [5] beschrieben, angewendet, wodurch eine Analyse des Computerprogramms hinsichtlich eines vorgegebenen unerwünschten Ereignisses analysiert wird.A fault tree analysis method as described in [5] is applied to the fault tree 1000 shown in FIG. 10, as a result of which an analysis of the computer program with regard to a predetermined undesired event is analyzed.
Im weiteren werden Alternativen und weitere Anwendungsmöglichkeiten des oben beschriebenen Ausführungsbeispiels dargestellt.Alternatives and further possible uses of the exemplary embodiment described above are shown below.
Der mit dem oben beschriebenen Verfahren erzeugte Gesamtfehlerbaum kann zu verschiedenen Zwecken eingesetzt werden:The overall fault tree generated with the method described above can be used for various purposes:
- Beschreibung der Fehlererzeugung bzw. Fehlverhaltenspropa- gation durch einen Teil eines Computerprogramms im Rahmen einer Sicherheitsanalyse oder eine Zuverlässigkeitsanalyse des Computerprogramms,- Description of the error generation or misbehavior propagation by part of a computer program as part of a security analysis or a reliability analysis of the computer program,
- Analyse von Softwarefehlermechanismen, beispielsweise im Rahmen einer Testfallgenerierung. Im weiteren ist ein Computerprogramm in der Programmiersprache C++ angegeben, mit dem das Verfahren gemäß dem Ausführungsbeispiel realisiert ist :- Analysis of software error mechanisms, for example in the context of test case generation. Furthermore, a computer program in the programming language C ++ is specified with which the method according to the exemplary embodiment is implemented:
#ιnclude "AS_GraphKante.h"# ιnclude "AS_GraphKante.h"
D dinclude <ιostream>D dinclude <ιostream>
DD
0 ostreamS Operator « ( ostreamS os, const GraphKanteC & Kante) 0 os « Kan e.KantenTyp; o return os;0 ostreamS Operator «(ostreamS os, const GraphKanteC & Kante) 0 os« Kan e.KantenTyp; o return os;
0 } π π/π/i/i π ππ/ππ/π/π/ππ/ππ/ππ/π/iπi/ππ/ii in/// /////////////////////0} π π / π / i / i π ππ / ππ / π / π / ππ / ππ / ππ / π / iπi / ππ / ii in /// ////////////// ///////
I / Klasse zur Erzeugung von Kanten im Slice-Graph. // Es gibt zwei Arten von Kanten: // 1. Kontroll luß-Kanten KFK // 2. Datenfluß-Kanten DFKI / class for creating edges in the slice graph. // There are two types of edges: // 1. Control flow edges KFK // 2. Data flow edges DFK
// Auch diese Klasse erfüllt die nice-Anforderungen für die STL.// This class also meets the nice requirements for the STL.
// //ππ/ππiππiππi/πiππ/π/π in π /ππi/π/πi/ππ///////// ///////// //////// // ππ / ππiππiππi / πiππ / π / π in π / ππi / π / πi / ππ ///////// ///////// //////
II 1997-09-12 Andreas Steinhorst ππmiiimmiπiππimmmiπimmmiiiiπm nimm m mπiiππiiiim Olfndef _GraphNodeHeader Kdefine _GraphNodeHeaderII 1997-09-12 Andreas Steinhorst ππmiiimmiπiππimmmiπimmmiiiiπm take m mπiiππiiiim Olfndef _GraphNodeHeader Kdefine _GraphNodeHeader
Kmclude <ιostream> «include "KFGListNode.h" usmg namespace std; class GraphNodeC : public KFGListNodeC { public:Kmclude <ιostream> «include" KFGListNode.h "usmg namespace std; class GraphNodeC: public KFGListNodeC {public:
//GraphNodeC! ) {); friend ostreamS Operator « ( ostreamS os, const GraphNodeCS Node); );// GraphNodeC! ) {); friend ostreamS Operator «(ostreamS os, const GraphNodeCS Node); );
#endιf /////////////////////// iπ/iπ/i/π in ππ/π/iimπ in // in π π ////////// /////////// o# endιf /////////////////////// iπ / iπ / i / π in ππ / π / iimπ in // in π π ////// //// //// / // //// o
// Klasse zur Erstellung eines Slice. Dieser Klasse wird ein leeres Objekt// Class for creating a slice. This class becomes an empty object
DD
// der Klasse Graph vererbt. o// inherited from the class graph. O
// Die Ecken des Graphen/Slice haben dieselbe Struktur wie die Listen im KFG. // Die Kanten sind von Typ KantenTypT; eine Klasse GraphKanteC ließ sich aus // für mich unersichtlichen Gründen nicht in die Klasse Graph einbinden. // // III l/ll 1/ 1/ 1/ 1/1 /Hl/// HIIIIH II 1997-09-12 Andreas Steinhorst ππmimπimπimmimmmmmmmπiπimimπim/mπimimiim flifdef _SlιceHeader #else #defιne _SlιceHeader// The corners of the graph / slice have the same structure as the lists in the KFG. // The edges are of type EdgeTypeT; A class GraphKanteC could not be integrated into the class Graph for reasons that are invisible to me. // // III l / ll 1/1/1/1/1 / HL / / / H H II IIII 1997-09-12 Andreas Horst stone ππmimπimπimmimmmmmmmπiπimimπim / mπimimiim flifdef _SlιceHeader #else # defιne _SlιceHeader
#ιnclude "graph.h" Kinclude "AS_GraphKante.h" //»lnclude "AS GraphNode.h" Hinclude "KFGListNode.h" (fmclude "KFGList.h"# ιnclude "graph.h" Kinclude "AS_GraphKante.h" // »lnclude" AS GraphNode.h "Hinclude" KFGListNode.h "(fmclude" KFGList.h "
//using namespace std;// using namespace std;
//typedef enum (DFK, KFK} KantenTypT; class SliceC : public Graph<KFGLιstNodeC,GraphKanteC> { public:// typedef enum (DFK, KFK} EdgesTypeT; class SliceC: public graph <KFGLιstNodeC, GraphKanteC> {public:
SliceC () {}; void sliceForLoops (KFGListC S L2, KFGListC: : iterator LOOPIT); KFGListC: : iterator defineVariableToSlice (KFGListC S L2);SliceC () {}; void sliceForLoops (KFGListC SL 2 , KFGListC:: iterator LOOPIT); KFGListC:: iterator defineVariableToSlice (KFGListC SL 2 );
//void buildTestGraph (KFGListC s L2); void fmdAllDefs (KFGListC S Ll, KFGListC: : iterator ITER);// void buildTestGraph (KFGListC s L2); void fmdAllDefs (KFGListC S Ll, KFGListC:: iterator ITER);
KFGListC: : iterator findUpperLimit (KFGListC s Ll, KFGListC: : iterator ITER, KFGP UseListC: : iterator PUSEIT);KFGListC:: iterator findUpperLimit (KFGListC s Ll, KFGListC:: iterator ITER, KFGP UseListC:: iterator PUSEIT);
KFGListC: : iterator fmdLowerLimit (KFGListC & Ll, KFGListC: : iterator ITER, KFGListC:: iterator UPPERLIMIT);KFGListC:: iterator fmdLowerLimit (KFGListC & Ll, KFGListC:: iterator ITER, KFGListC :: iterator UPPERLIMIT);
KFGListC: : iterator findLowerLimitFromCUse (KFGListC S Ll, KFGListC: -.iterator ITER, KFGListC: : iterator UPPERLIMIT); KFGListC: : iterator findUpperLimitFromCUse (KFGListC S Ll, KFGListC: : iterator ITER,KFGListC:: iterator findLowerLimitFromCUse (KFGListC S Ll, KFGListC: -.iterator ITER, KFGListC:: iterator UPPERLIMIT); KFGListC:: iterator findUpperLimitFromCUse (KFGListC S Ll, KFGListC:: iterator ITER,
KFGUseListC: : iterator USEIT); int checkForNodes (int NodeNumber); void KFKPUseToCUse (KFGListC: :ιterator PUSEIT, int SchleifenEnde) ; void fmdDefToCUse (KFGListC S Ll, KFGListC: : iterator ITER); void deflnLooplKFGListC S Ll, KFGListC: : iterator ITER); void startBuildSlice (KFGListC S Ll ) ; void sliceAusgebenl ) ; );KFGUseListC:: iterator USEIT); int checkForNodes (int NodeNumber); void KFKPUseToCUse (KFGListC:: ιterator PUSEIT, int LoopEnd); void fmdDefToCUse (KFGListC S Ll, KFGListC:: iterator ITER); void deflnLooplKFGListC S Ll, KFGListC:: iterator ITER); void startBuildSlice (KFGListC S Ll); void sliceExpendl); );
«endif πiiiimi miiπimiii mm im m mmmi/i/mi m um«Endif πiiiimi miiπimiii mm in m mmmi / i / mi um
II Mit einigen Änderungen übernommen aus "Die C++ Standard Template Library".II With some changes taken from "The C ++ Standard Template Library".
////
// Template-Klasse Graph zur Erstellung von gerichteten oder ungeπchteten// Template class graph for creating directed or non-aligned
// Graphen. Der Graph besteht aus einem Vektor E für alle Ecken. Jedes // Vektorelement besteht wiederum aus einem Paar: der Ecke und der Menge der// graph. The graph consists of a vector E for all corners. Each // vector element consists of a pair: the corner and the set of
// Nachfolger.// successor.
// Die Menge der Nachfolger wird durch den STL Datentyp map dargestellt; der// The set of successors is represented by the STL data type map; the
// Schlüssel zu einem Kantentyp/Kantenwert ist die Nummer einer nachfolgenden// Key to an edge type / edge value is the number of a subsequent one
// Ecke. // III// corner. // III
#ιfndef _graphHeader# ιfndef _graphHeader
#defιne _graphHeader# defιne _graphHeader
#ιnclude <assert.h> (tinclude <map> flinclude <stack># ιnclude <assert.h> (tinclude <map> flinclude <stack>
#ιnclude <vector> iinclude "checkvec.h"# ιnclude <vector> iinclude "checkvec.h"
(finclude <ιostream> «include "AS_GraphNode.h" using namespace std;(finclude <ιostream> «include" AS_GraphNode.h "using namespace std;
// Leere Parameterklasse mit Mindestsatz von Operationen, // falls keine Kantengewichte benötigt werden. struct Empty { public:// Empty parameter class with a minimum set of operations // if no edge weights are required. struct Empty {public:
Empty(mt=0) () bool operator< (const Empty ) const { return true; )Empty (mt = 0) () bool operator <(const Empty) const {return true; )
// Empty-Operationen, damit Ein-Ausgabe allgemein formuliert// Empty operations so that input / output is formulated in general
// werden kann// can be
//ostreamS operator«(ostreamS os, const Emptys) { return os; ) //istream Operator» (istream is, Emptys ) { return ιs;( template<class Eckentyp, class Kantentyp> class Graph ( public: typedef map<ιnt, Kantentyp, less<int> > Nachfolger; typedef paιr<Eckentyp, Nachfolger> Ecke; typedef checkedVector<Ecke> Graphtyp;// ostreamS operator «(ostreamS os, const Emptys) {return os; ) // istream Operator »(istream is, Emptys) {return ιs; (template <class corner type, class edge type> class Graph (public: typedef map <ιnt, edge type, less <int>>successor; typedef paιr <corner type, successor>Corner; typedef checkedVector <corner> graph type;
//typedef vector<Ecke> Graphtyp; typedef Graphtyp: : iterator iterator; typedef Graphtyp: :const_ιterator const_ιterator; Graph (bool g, ostreamS os = cerr)// typedef vector <corner> graph type; typedef graph type:: iterator iterator; typedef graph type:: const_ιterator const_ιterator; Graph (bool g, ostreamS os = cerr)
: gerichte (g) , pOut(Soε) {}: dishes (g), pOut (Soε) {}
Graph ( ) { } sιze_t sιze() const { return C.sιze(); } bool istGerichtet ( ) const { return gerichtet;} iterator beginl) { return C.beginf);} iterator end ( ) { return C.endO;} Eckes Operator [] (int l) { return C[ι);} sιze_t AnzahlKanten ( ) ; int ιnsert( const Eckentyps e); void ιnsert( const Eckentyps el, const Eckentyps e2, const Kantentyps Wert); void verbmdeEckendnt el, int e2, // über Eckennummern const Kantentyps Wert); void setgerichtet (bool wert); // neue Methode für gerichtete/ungerichtete Graphen,Graph () {} sιze_t sιze () const {return C.sιze (); } bool isDirected () const {return directed;} iterator beginl) {return C.beginf);} iterator end () {return C.endO;} Eckes Operator [] (int l) {return C [ι);} sιze_t Number of edges (); int ιnsert (const corner type e); void insert (const corner type el, const corner type e 2 , const edge type value); void verbmdeEckendnt el, int e 2 , // via corner numbers const edge type value); void set-oriented (bool value); // new method for directed / undirected graphs,
// die aber nicht ver- wendet wird. void check (ostreamS = cout); void ZyklusUndZusammenhang (ostreamS = cout); private: bool gerichtet;// which is not used. void check (ostreamS = cout); void cycle and context (ostreamS = cout); private: bool directed;
Graphtyp C; // Container ostream* pOut;Graph type C; // container ostream * pOut;
};};
//Funktion, die überprüft, ob es sich um einen gerichteten oder ungerichteten //Graphen handelt, und die Anzahl der Ecken und Kanten ausgibt. template<class Eckentyp, class Kantentyp> void Graph<Eckentyp,Kantentyp>: : check (ostream os) { os « "Der Graph ist "; //if (' istGerichtet () ) // os « "un"; os « "gerichtet und hat " « sιze() « " Knoten und "// Function that checks whether it is a directed or undirected // graph and outputs the number of corners and edges. template <class corner type, class edge type> void graph <corner type, edge type>:: check (ostream os) {os «" The graph is "; // if ('IsDirected ()) // os «" un "; os «" and "" sιze () «" knots and "
« AnzahlKanten () « " KantenNn"; //ZyklusUndZusammenhang ( os ) ;«Number of edges ()« "edgesNn"; // cycle and context (os);
//Methode, die einen Wert setzt, ob der Graph gerichtet oder ungerichtet ist. template<class Eckentyp, class Kantentyp> void Graph<Eckentyp,Kantentyp>: : setgerichtet (bool wert) gerichtet = wert;// method that sets a value whether the graph is directed or undirected. template <class corner type, class edge type> void graph <corner type, edge type>:: set-oriented (bool value) directed = value;
//Funktion berechnet die Anzahl der Kanten in Graph template<class Eckentyp, class Kantentyp> sιze_t Graph<Eckentyp,Kantentyp>: :AnzahlKanten ( ) { sιze_t Kanten = 0; iterator temp « begm(); whιle(temp '= end ( ) )// function calculates the number of edges in graph template <class corner type, class edge type> sιze_t graph <corner type, edge type>:: number of edges () {sιze_t edges = 0; iterator temp «begm (); whιle (temp '= end ())
Kanten += (*temp++) . second.size ( ) ; Hi t ('gerichtet) // Kanten /= 2; return Kanten; } //Einfügen einer Ecke in den Graphen, falls diese noch nicht vorhanden ist. template<class Eckentyp, class Kantentyp> int Graph<Eckentyp,Kantentyp>: :ιnsert( const Eckentyps e) f fordnt i = 0; l < sιze(); ++ι) if (e == C[ι) .first) return i;Edges + = (* temp ++). second.size (); Hi t ('directed) // edges / = 2; return edges; } // Insert a corner in the graph if it does not already exist. template <class corner type, class edge type> int graph <corner type, edge type>:: ιnsert (const corner type e) f fordnt i = 0; l <sιze (); ++ ι) if (e == C [ι) .first) return i;
// falls nicht gefunden, einfuegen: C.push_back(Ecke le, Nachfolger! ) ) ) ; return sιze()-l;// if not found, insert: C.push_back (corner le, successor!))); return sιze () - l;
//Einfügen einer Kante in den Graphen, indem zuerst die Ecken eingefügt werden. template<class Eckentyp, class Kantentyp> void Graph<Eckentyp,Kantentyp>: : insert (const Eckentyps el, const Eckentyp e2, const Kantentyps Wert)// Insert an edge in the graph by first inserting the corners. template <class corner type, class edge type> void graph <corner type, edge type>:: insert (const corner type el, const corner type e 2 , const edge type value)
{ int posl = insert (el); int pos2 = insert ( e2 ); verbmdeEckenlposl, pos2, Wert);{int posl = insert (el); int pos2 = insert (e2); verbmdeEckenlposl, pos2, value);
//Verbinden der beiden neu eingefügten Ecken durch eine Kante. template<class Eckentyp, class Kantentyp> void Graph<Eckentyp,Kantentyp>: : verbindeEcken ( int posl, int pos2, const Kantentyps Wert) (// Connect the two newly inserted corners with an edge. template <class corner type, class edge type> void graph <corner type, edge type>:: verbindeEcken (int posl, int pos2, const edge type value) (
(Clposl) .second) [pos2] « Wert;(Clposl) .second) [pos2] «value;
//if ( Igenchtet) // automatisch auch Gegenrichtung eintragen// if (Igenchtet) // automatically enter the opposite direction
// (C(pos2] .second) [posl] = Wert;// (C (pos2] .second) [posl] = value;
/* ZyklusUndZusammenhang!) arbeitet mit der Tiefensuche. Im Gegensatz zu CLR S. 47S wurde nicht mit der Rekursion gearbeitet, weil bei dieser Stack-Overflow bei großen Graphen (zB. MILES.DAT bei mehr als 40 Knoten) auftrat./ * Cycle and context!) Works with the depth search. In contrast to CLR p. 47S, recursion was not used because this stack overflow occurred with large graphs (e.g. MILES.DAT with more than 40 nodes).
Die Nachbildung der Rekursion durch eigenen Stack ermöglicht die Verarbeitung der gesamten DateiReplicating the recursion with its own stack enables processing of the entire file
MILES.DAT (128 Knoten). Die Stacktiefe entspricht der KantenanzahlMILES.DAT (128 knots). The stack depth corresponds to the number of edges
+ 1 bei ungerichteten Graphen. */ template-class Eckentyp, class Kantentyp> void Graph<Eckentyp, Kantentyp>: : ZyklusUndZusammenhang (ostreamS os) int Zyklen - 0; int Komponentenanzahl = 0; stack<ιnt, ector<ιnt> > EckenStack; // zu besuchende Ecken+ 1 for undirected graphs. * / template-class corner type, class edge type> void graph <corner type, edge type>:: Cycle and context (ostreamS os) int cycles - 0; int number of components = 0; stack <ιnt, ector <ιnt>> Cornerstack; // corners to visit
// allen Ecken den Zustand nichtBesucht zuordnen enum EckStatus (nichtBesucht, besucht, bearbeitet); vector<EckStatus> Eckenzustand (size () , nichtBesucht);// assign the status Not Visited to all corners enum EckStatus (not visited, visited, edited); vector <EckStatus> corner state (size (), not visited);
// alle Ecken besuchen fordnt l = 0; l < sιze(); ++i) if (Eckenzustand d] == nichtBesucht)// visit all corners fordnt l = 0; l <sιze (); ++ i) if (corner state d] == not visited)
<<
Komponentenanzahl++;Number of components ++;
// auf dem Stack zwecks Bearbeitung ablegen// put it on the stack for editing
EckenStack.pushd ) ;CornersStack.pushd);
// Stack abarbeiten while ( ' EckenStack. empty ( ) int dieEcke = EckenStack. top () ; EckenStack. pop( ) ; if (Eckenzustand [dieEcke] »= besucht)// Process stack while ('CornersStack. Empty () int dieEcke = CornersStack. Top (); CornersStack. Pop (); if (Corners state [DieEcke] »= visited)
Eckenzustand[dιeEcke] = bearbeitet; eise if (Eckenzustand[dιeEcke] == nichtBesucht)Corner condition [dιeEcke] = processed; ice if (corner state [dιeEcke] == not visited)
((
Eckenzustand [dieEcke] = besucht; // neue Ecke, für bearbeitet-Kennung vormerken EckenStack.push (dieEcke ) ;Corner condition [dieEcke] = visited; // new corner, mark for processed identifier cornersStack.push (dieEcke);
// Nachfolger vormerken:// reserve successor:
Graph<Eckentyp, Kantentyp>: :Nachfolger: -.iterator Start = Operator [) (dieEcke) .second.beginf ) , ende = Operator [] (dieEcke) .second. end () ; while (start != ende) ( int Nachf «= (*start) . first; if (Eckenzustand [Nachf] == besucht) (Graph <corner type, edge type>:: Successor: -.iterator start = operator [) (dieEcke) .second.beginf), end = operator [] (dieEcke) .second. end (); while (start! = end) (int Nachf «= (* start). first; if (EckausStand [Nachf] == visited) (
++Zyklen; // hier war schon jemand! (*pOut) « "mindestens Ecke " « Operator [] (Nachf ). first « " ist in einem ZyklusNn"; } if (Eckenzustand [Nachf] == nichtBesucht)++ cycles; // someone was already here! (* pOut) «" at least corner "« Operator [] (ref). first «" is in one cycleNn "; } if (corner state [ref] == not visited)
EckenStack.pus (Nachf) ; ++start; } }EckenStack.pus (ref); ++ start; }}
} // Stack Empty? } // for ( ) ... i (Eckenzustand... if (gerichtet) ( if (Komponentenanzahl == 1) os « "Der Graph ist stark zusammenhangend. \n"; eise os « "Der Graph ist nicht oder schwach " "zusammenhangend . \n" ; eise os « "Der Graph hat "} // Stack Empty? } // for () ... i (corner state ... if (directed) (if (number of components == 1) os «" The graph is strongly connected. \ n "; else os« "The graph is not or weak "" connected. \ n "; else os« "The graph has"
« Komponentenanzahl«Number of components
« " Komponente (n) . " « endl; os « "Der Graph hat "; if (Zyklen == 0) os « "keine "; os « "Zyklen." « endl;«" Component (s). "« Endl; os «" The graph has "; if (cycles == 0) os «" none "; os «" cycles. " «Final;
//Ausgabe des Graphen. template<class Eckentyp, class Kantentyp> ostream Operator« (ostreamS os,// Output the graph. template <class corner type, class edge type> ostream operator «(ostreamS os,
Graph<Eckentyp,Kantentyp>s G)Graph <corner type, edge type> s G)
< ofstream Ziel ("FaultTree.uwg" ) ; ostream_ιterator<uwgknotenC> POSIT(Zιel) ; ostream_ιterator<uwgknotenC> POSIT2 (Ziel ) ;<ofstream target ("FaultTree.uwg"); ostream_ιterator <uwgknotenC> POSIT (Zιel); ostream_ιterator <uwgknotenC> POSIT2 (target);
// Anzeige der Ecken mit Nachfolgern// Display the corners with successors
Ziel « "%%UWG" « endl « "\"V0. l\"~\"Fehlerbaum\"-\"A.Steιnhorst\"" « endl « "%%BEGIN" « endl; fordnt l = 0; l < G.sizeO; ++ι) (Target «" %% UWG "« endl «" \ "V0. l \ "~ \" error tree \ "- \" A.Steιnhorst \ "" «endl« "%% BEGIN" «endl; fordnt l = 0; l <G.sizeO; ++ ι) (
POΞIT++ = G[ι ]. first; /*os « G[ι]. first « " <"; Graph<Eckentyp,Kantentyp>: :Nachfolger: :ιterator startN = G[ι] .second.begin () , endeN = G[ι ] .second. end ( ) ; while (startN != endeN) ( os « G[ (*startN) .first) .first « ' ' // Ecke « (»startN) .second « ' '; // Kantenwert *POSIT2++ = G[ (*startN) .first] .first;POΞIT ++ = G [ι]. first; / * os «G [ι]. first «"<"; Graph <corner type, edge type>:: successor:: ιterator startN = G [ι] .second.begin (), endeN = G [ι] .second. end (); while (startN! = endN) (os «G [(* startN) .first) .first« '' // corner «( » startN) .second «''; // Edge value * POSIT2 ++ = G [(* startN) .first] .first;
//*KANTEIT++ = (*startN) .second; ++startN; } os « ">\n";*/ «POSIT++;// * EDGE ++ = (* startN) .second; ++ startN; } os «"> \ n "; * / « POSIT ++;
) fordnt u = 0; u < G.sizef); ++u) () requires u = 0; u <G.sizef); ++ u) (
Graph<Eckentyp,Kantentyp>: :Nachfolger: :ιterator startN = G[u] .second.begin! ) , endeN - G[u] .second. end( ) ; while (startN != endeN) (Graph <corner type, edge type>:: successor:: ιterator startN = G [u] .second.begin! ), endN - G [u] .second. end (); while (startN! = endN) (
Ziel « "%%EDGE:" « G[u] . fitst.getGatterldent ( ) « ","Target «" %% EDGE: "« G [u]. fitst.getGatterldent () «", "
« G[ (*startN) .first] .first.getGatterldent ( ) « "/0;" « endl;«G [(* startN) .first] .first.getGatterldent ()« "/ 0;" «Final;
++startN;++ startN;
Ziel « "%%PROBSLIST" « endl « "%%END" « endl; return os;Target «" %% PROBSLIST "« endl «" %% END "« endl; return os;
«endif«Endif
(dfdef _KFGDefHeader(dfdef _KFGDefHeader
GG
#else#else
OO
«define _KFGDefHeader«Define _KFGDefHeader
DD
„include <strιng> D"Include <strιng> D
#include <ιostream> D using namespace std;#include <ιostream> D using namespace std;
DD
D typedef char StringT [256]; 0 D class KFGDefC .( D private: O DD typedef char StringT [256]; 0 D class KFGDefC. (D private: O D
StringT Def; D int ScopeLevelD; public:StringT Def; D int ScopeLevelD; public:
KFGDefC ( ) strcpy (Def, "— unknown —"); ScopeLevelD = 0; } ;KFGDefC () strcpy (Def, "- unknown -"); ScopeLevelD = 0; };
KFGDefC(char _Def [], int _ScopeLevelD) strcpy (Def, _Def); ScopeLevelD =KFGDefC (char _Def [], int _ScopeLevelD) strcpy (Def, _Def); ScopeLevelD =
_ScopeLevelD; ) ; void setDeffchar _Def []) ( strcpy (Def, _Def); } char* getDefO ( return Def; } int getScopeLevelD( ) ( return ScopeLevelD; } bool Operator == (const KFGDefCS other) const_ScopeLevelD; ); void setDeffchar _Def []) (strcpy (Def, _Def);} char * getDefO (return Def;} int getScopeLevelD () (return ScopeLevelD;} bool Operator == (const KFGDefCS other) const
( return ( (strcmp(Def, other. Def) ~ 0) s (Scope-(return ((strcmp (Def, other. Def) ~ 0) s (Scope-
LevelD == other .ScopeLevelD) ) ; }; bool Operator '= (const KFGDefCS other) constLevelD == other .ScopeLevelD)); }; bool operator '= (const KFGDefCS other) const
( return ' (*thιs == other) ; }; bool Operator < (const KFGDefCS other) const(return '(* thιs == other);}; bool operator <(const KFGDefCS other) const
{ return (strcmp(Def, other. Def ) < 0) ; }; bool Operator > (const KFGDefCS other) const ( return (strcmpfDef, other.Def) > 0); ); friend ostreamS Operator « ( ostreamS os, const KFGDefCS Node); };{return (strcmp (Def, other. Def) <0);}; bool operator> (const KFGDefCS other) const (return (strcmpfDef, other.Def)>0);); friend ostreamS Operator «(ostreamS os, const KFGDefCS Node); };
„endi iπ/π/πiπ π iπ/π π ππ/i////////// //////////////////////////////// //////////////// o"Endi iπ / π / πiπ π iπ / π π ππ / i ////////// ///////////////////////// /////// //////////////// o
II Klasse für Hilfsliste, um daraus einen KFG zu erstellen.II class for help list to create a KFG from it.
// Diese Klasse erfüllt die nice-Anforderungen für die STL;// This class meets the nice requirements for the STL;
// d.h. für eine Klasse T gilt // 0. Sie unterstützt den Copy-Konstruktor T (const T ),// i.e. for a class T applies // 0. It supports the copy constructor T (const T),
// 1. den Zuweisungsoperator TS operator= (const TS),// 1. the assignment operator TS operator = (const TS),
// 2. den Vergleichsoperator bool operator== (const T, Sconst TS) und// 2. the comparison operator bool operator == (const T, Sconst TS) and
// 3. den Ungleichoperator !■=// 3. the unequal operator! ■ =
// in einer Weise so daß gilt: // (a) ( TRUE } T a(b) (a -= b}// in such a way that: // (a) (TRUE} T a (b) (a - = b}
// (b) ( TRUE } a = b (a — b}// (b) (TRUE} a = b (a - b}
// (c) { a == a}// (c) {a == a}
// (d) { a == b <==> b == a }// (d) {a == b <==> b == a}
// (e) ( (a == b) AND ( b == c ) ==> (a == c) } // (f) ( a != b <==> NOT ( a— b) };// (e) ((a == b) AND (b == c) ==> (a == c)} // (f) (a! = b <==> NOT (a— b)} ;
////
// Außerdem sind alle Funktionen, insbesondere getName equality preservmg, d.h.// In addition, all functions, especially getName equality preservmg, i.e.
// (g) { a == b == > a. getName () == b. getName () }// (g) {a == b ==> a. getName () == b. getName ()}
// // (C) 1997 Siemens AG// // (C) 1997 Siemens AG
////
// iimiii mmiπimiim m mπiimmimmimπimiimiπ// iimiii mmiπimiim m mπiimmimmimπimiimiπ
II 1997-08-25 Andreas Steinhorst mmπiiiiimmmmimπimiiiimi ππ /ii/imiiiiiiiiiii »lfdef _KFGLιneNodeHeaderII 1997-08-25 Andreas Steinhorst mmπiiiiimmmmimπimiiiimi ππ / ii / imiiiiiiiiiii »lfdef _KFGLιneNodeHeader
«eise «def ine _KFGLmeNodeHeader«Eise« def ine _KFGLmeNodeHeader
(f include <string> ftinclude <ιostream> using namespace std; typedef char StringL [ 1000] ; class KFGLmeNodeC private:(f include <string> ftinclude <ιostream> using namespace std; typedef char StringL [1000]; class KFGLmeNodeC private:
StringL Name; int LineNumber; publlc:StringL name; int LineNumber; publlc:
KFGLmeNodeC ( ) ( strcpy (Name, "— unknown —KFGLmeNodeC () (strcpy (name, "- unknown -
LineNumber = 0;LineNumber = 0;
KFGLmeNodeC (char _Name []) ( strcpy (Name, _Name); LineNumberKFGLmeNodeC (char _Name []) (strcpy (Name, _Name); LineNumber
0; } ;0; };
KFGLmeNodeC (char _Name [], int _LmeNumber)KFGLmeNodeC (char _Name [], int _LmeNumber)
( strcpy (Name, _Name); LineNumber =(strcpy (name, _Name); LineNumber =
LineNumber; void setName(char _Name []) ( strcpy (Name, _Name); }; char* getName() ( return Name; }; int getLineNumber ( ) ( return LineNumber; }; bool Operator == (const KFGLineNodeCS other) constLineNumber; void setName (char _Name []) (strcpy (Name, _Name);}; char * getName () (return Name;}; int getLineNumber () (return LineNumber;}; bool Operator == (const KFGLineNodeCS other) const
( return (strcmp (Name, other.Name) == 0) S (LineNumber == other.LineNumber)) ; }; bool Operator ' = (const KFGL eNodeCS other) const ( return ' (*thιs(return (strcmp (Name, other.Name) == 0) S (LineNumber == other.LineNumber)); }; bool operator '= (const KFGL eNodeCS other) const (return' (* thιs
== other) ; } ; bool Operator < (const KFGLmeNodeCS other) const== other); }; bool operator <(const KFGLmeNodeCS other) const
( return (strcmp(Name, other.Name) < 0); }; bool Operator > (const KFGLmeNodeCS other) const(return (strcmp (Name, other.Name) <0);}; bool Operator> (const KFGLmeNodeCS other) const
( return (strcmp(Name, other.Name) > 0); }; friend ostreamS Operator « ( ostreamS os, const KFGLmeNodeCS Node);(return (strcmp (Name, other.Name)> 0);}; friend ostreamS Operator «(ostreamS os, const KFGLmeNodeCS Node);
};};
#endif π/ππiππiπ/ππ/ππiππ/ππ/ππiππiππ/ππ/ππiπ/ππ/πi/ππi/π/ππ#endif π / ππiππiπ / ππ / ππiππ / ππ / ππiππiππ / ππ / ππiπ / ππ / πi / ππi / π / ππ
II Klasse für die Liste, die den KFG darstellt.II class for the list that represents the KFG.
// Diese Klasse erfüllt die nice-Anforderungen für die STL; // d.h. für eine Klasse T gilt// This class meets the nice requirements for the STL; // i.e. applies to a class T.
// 0. Sie unterstützt den Copy-Konstruktor T (const TS),// 0. It supports the copy constructor T (const TS),
// 1. den Zuweisungsoperator TS operator= (const TS),// 1. the assignment operator TS operator = (const TS),
// 2. den Vergleichsoperator bool operator== (const T, sconst T ) und// 2. the comparison operator bool operator == (const T, sconst T) and
// 3. den Ungleichoperator '= // in einer Weise so daß gilt:// 3. the unequal operator '= // in such a way that:
// (a) ( TRUE } T a(b) (a == b}// (a) (TRUE} T a (b) (a == b}
// (b) ( TRUE } a = b (a == b}// (b) (TRUE} a = b (a == b}
// (c) ( a == a}// (c) (a == a}
// (.d). (. a == b <==> b — a } // ((ee)) (( ((aa ==== bb)) AANNDD (( bb ==== cc )) ====>> (a == c)// (.d). (. a == b <==> b - a} // ((ee)) ((((aa ==== bb)) AANNDD ((bb ==== cc)) ==== >> (a == c)
// (f) { a '= b <==> NOT ( a-== b) };// (f) {a '= b <==> NOT (a - == b)};
////
// Außerdem sind alle Funktionen, insbesondere getStatement equality preservmg, d.// In addition, all functions, especially getStatement equality preservmg, d.
// (g) ( a == b == > a. getStatement ( ) == b. getStatement ( ) } //// (g) (a == b ==> a. getStatement () == b. getStatement ()} //
// im mimimii mim /nimm mm ιι ιι 11 ιι im ι im in ιι ι / in ι ιι ιι ι / ιι /// im mimimii mim / take mm ιι ιι 11 ιι im ι im in ιι ι / in ι ιι ιι ι / ιι /
II 1997-09-01 Andreas Steinhorst ππiπmimπiπimπimiπmiiii ιι min/im m im ιι in mmiiimπi ffifdef _KFGLιstHeader #elseII 1997-09-01 Andreas Steinhorst ππiπmimπiπimπimiπmiiii ιι min / im m im ιι in mmiiimπi ffifdef _KFGLιstHeader #else
(fdefine _KFGLιstHeader dinclude <strιng> tdnclude <ιostream> linclude <stdιo.h> ftinclude <list>(fdefine _KFGLιstHeader dinclude <strιng> tdnclude <ιostream> linclude <stdιo.h> ftinclude <list>
(linclude <fstream> ftinclude <ιterator> (fmclude "KFGListNode.h"(linclude <fstream> ftinclude <ιterator> (fmclude "KFGListNode.h"
„include "KFGTokenList.h""Include" KFGTokenList.h "
#ιnclude "KFGProgList.h" using namespace std; class KFGListC : public lιst<KFGLιstNodeC> ( int Anzahl_Defs, Anzahl_Uses, Anzahl_P_Uses, Anzahl Deklarationen; int Schleifenentscheidungen, Entscheidungen, Zaehlschleifenentscheidungen; int Anweisungen; publlc : KFGListC () (}; void TokenLιst2KFGLιst (KFGTokenListC S Ll ) ; void KnotenNummern ( ) ; void Knotenldentifizierer (KFGListC: : iterator KFG); void ListeAusgeben! ) ; void addLmelnToList ( ) ; void addLιneToKFG(KFGProgLιstC S LP); int zaehleDeklaratιonen(KFGTokenLιstC S TL); void basisgroessenlnDatei ( ) ;# ιnclude "KFGProgList.h" using namespace std; class KFGListC: public lιst <KFGLιstNodeC> (int number_defs, number_Uses, number_P_Uses, number of declarations; int loop decisions, decisions, counting loop decisions; int instructions; publlc: KFGListC () (}; void TokenLιst2KFn); node (S) void node identifier (KFGListC:: iterator KFG); void list output!); void addLmelnToList (); void addLιneToKFG (KFGProgLιstC S LP); int count declarations (KFGTokenLιstC S TL); void base size file ();
}; class KFGDefListC : public list<KFGDefC> (}; class KFGUseListC : public lιst<KFGUseC> (}; class KFGP_UseLιstC : public lιst<KFGUseC> (};}; class KFGDefListC: public list <KFGDefC> (}; class KFGUseListC: public reads <KFGUseC> (}; class KFGP_UseLιstC: public reads <KFGUseC> (};
#endιf ffinclude <stπng> D# endιf ffinclude <stπng> D
Oinclude <ιostream> «mclude <lιst> ffinclude "KFGNode.h" us g namespace std; typedef lιst<KFGNodeC> KFGListeT; extern void KFGListeAusgeben (KFGListeT ) ; /////////// ////ι iππ in ππ π/π n/n ι n/n // ιι / // in / ιι π // π // iπ/ππ /////////////Oinclude <ιostream> «mclude <lιst>ffinclude" KFGNode.h "us g namespace std; typedef reads <KFGNodeC>KFGListeT; extern void KFGListeAusgabe (KFGListeT); /////////// //// ι iππ in ππ π / π n / n ι n / n // ιι / // in / ιι π // π // iπ / ππ /// /////// / //
00
// Klasse für die Knoten im Kontrollflußgraph.// Class for the nodes in the control flow graph.
// Diese Klasse erfüllt die nice-Anforderungen für die STL;// This class meets the nice requirements for the STL;
// d.h. für eine Klasse T gilt 1/ 0. Sie unterstützt den Copy-Konstruktor T (const TS),// i.e. for a class T applies 1 / 0. It supports the copy constructor T (const TS),
// 1. den Zuweisungsoperator TS operator= (const TS),// 1. the assignment operator TS operator = (const TS),
// 2. den Vergleichsoperator bool operator== (const T, Sconst Ts ) und// 2. the comparison operator bool operator == (const T, Sconst Ts) and
// 3. den Ungleichoperator !=// 3. the unequal operator! =
// in einer Weise so daß gilt: // (a) ( TRUE } T a(b) (a == b}// in such a way that: // (a) (TRUE} T a (b) (a == b}
// (b) ( TRUE } a = b (a == b}// (b) (TRUE} a = b (a == b}
// (c) ( a == a}// (c) (a == a}
// (d) ( a == b <==> b == a }// (d) (a == b <==> b == a}
// (e) ( (a == b) AND ( b == c ) ==> (a == c) } // (f) ( a != b <==> NOT ( a== b) };// (e) ((a == b) AND (b == c) ==> (a == c)} // (f) (a! = b <==> NOT (a == b) };
////
// Außerdem sind alle Funktionen, insbesondere getStatement equality preservmg, d.h.// In addition, all functions, especially getStatement equality preservmg, i.e.
// (g) ( a == b == > a. getStatement ( ) == b. getStatement ( ) }// (g) (a == b ==> a. getStatement () == b. getStatement ()}
// // II llll/IIIIHIIII Hl// // II llll / IIIIHIIII St.
II 1997-08-25 Andreas Steinhorst iπ/π/π/π/π/iπ iππ IΠΠI/ΠΠ ι in / π ι // π/π/π///////////// ////// ////////////// difdef _KFGNodeLιstHeader „eise (fdefme _KFGNodeLιstHeader finclude <strιng> dinclude <ιostream>II 1997-08-25 Andreas Steinhorst iπ / π / π / π / π / iπ iππ IΠΠI / ΠΠ ι in / π ι // π / π / π ///////////// // //// ////// // // //// difdef _KFGNodeLιstHeader „eise (fdefme _KFGNodeLιstHeader finclude <strιng> dinclude <ιostream>
(finclude <list> (finclude "KFGUse.h" ftmclude "KFGDef.h" using namespace std; typedef char StringT [256]; typedef char CodeLineT [256] ; typedef enum (NO, LC,BL, EL, IFC,BTh,ETh, BEI, EE1, OP, DOWL, DOWLC, SWITCH, CASE, ENDCASE, BDEFA, ENDDEFA, RETURN, BRE AK) KFGNodeTypeT; typedef enum (LOOP, THEN, ELSE, NONE} KnotenldentT; class KFGListNodeC ( protected: //private: static int DummyNodeNr; int NodeNr; int Level; int KnotenNr; int LineNr; StringT Statement; CodeLineT CodeLine; KFGNodeTypeT KFGNodeType; KnotenldentT Knotenldent ; public: lιst<KFGUseC> Uses; lιst<KFGDefC> Defs; lιst<KFGUseC> P_Uses;(finclude <list> (finclude "KFGUse.h" ftmclude "KFGDef.h" using namespace std; typedef char StringT [256]; typedef char CodeLineT [256]; typedef enum (NO, LC, BL, EL, IFC, BTh , ETh, BEI, EE1, OP, DOWL, DOWLC, SWITCH, CASE, ENDCASE, BDEFA, ENDDEFA, RETURN, BRE AK) KFGNodeTypeT; typedef enum (LOOP, THEN, ELSE, NONE} node IDT; class KFGListNodeC ( protected: // private: static int DummyNodeNr; int NodeNr; int level; int node number; int LineNr; StringT Statement; CodeLineT CodeLine; KFGNodeTypeT KFGNodeType; Node identifierT node identifier; public: reads <KFGUseC>Uses; reads <KFGDefC>Defs; reads <KFGUseC>P_Uses;
KFGListNodeCO ( strcpy (Statement, "— unknown —" ) ;KFGListNodeCO (strcpy (Statement, "- unknown -");
Level = 0; KFGNodeType =Level = 0; KFGNodeType =
NO;NO;
NodeNr = Dum- myNodeNr++;NodeNr = Dummy myNodeNr ++;
KnotenNr = 0; Knotenldent =Node number = 0; Node identifier =
NONE;NONE;
LineNr ■= 0; strcpy (CodeLi- ne, "—unknown—"); };LineNr ■ = 0; strcpy (CodeLine, "—unknown—"); };
KFGLιstNodeC(char _Statement [ ] , KFGNodeTypeT _KFGNodeType ) strcpy (State- ment, _Statement);KFGLιstNodeC (char _Statement [], KFGNodeTypeT _KFGNodeType) strcpy (statement, _Statement);
Level = 0;Level = 0;
KFGNodeType =KFGNodeType =
_KFGNodeType;_KFGNodeType;
NodeNr = Dum- myNodeNr++;NodeNr = Dummy myNodeNr ++;
KnotenNr = 0; Knotenldent =Node number = 0; Node identifier =
NONE;NONE;
LineNr = 0; strcpy (CodeLi- ne, "—unknown—"); };LineNr = 0; strcpy (CodeLine, "—unknown—"); };
KFGLιstNodeC(char _Statement [], KFGNodeTypeT _KFGNodeType, int _Level )KFGLιstNodeC (char _Statement [], KFGNodeTypeT _KFGNodeType, int _Level)
( strcpy (State- ment, _Statement ) ; Level = _Level; KFGNodeType =(strcpy (statement, _statement); Level = _Level; KFGNodeType =
_KFGNodeType;_KFGNodeType;
NodeNr = Dum- myNodeNr++;NodeNr = Dummy myNodeNr ++;
KnotenNr = 0; Knotenldent - NONE;Node number = 0; Node identifier - NONE;
LineNr = 0; strcpy (CodeLi- ne, "—unknown—"); };LineNr = 0; strcpy (CodeLine, "—unknown—"); };
KFGListNodeCIchar _Statement KFGNodeTypeT _KFGNodeType, int _Level, int _LmeNr)KFGListNodeCIchar _Statement KFGNodeTypeT _KFGNodeType, int _Level, int _LmeNr)
( strcpy (State- ment, _Statement); Level = _Level; KFGNodeType =(strcpy (statement, _statement); Level = _Level; KFGNodeType =
_KFGNodeType;_KFGNodeType;
NodeNr = Dum- myNodeNr++;NodeNr = Dummy myNodeNr ++;
KnotenNr = 0; Knotenldent =Node number = 0; Node identifier =
NONE;NONE;
LineNr = LineNr; strcpy ( CodeLi- ne, "—unknown—"); }; vo d setStatement (char _Statement []) strcpy (State- ment, _Statement); }; void setCodeL e (char _CodeLιne []) strcpy (CodeLi- ne, _CodeLιne); }; void setKFGKnotenNummer (int _KnotenNr)LineNr = LineNr; strcpy (CodeLine, "—unknown—");}; from the setStatement (char _Statement []) strcpy (Statement, _Statement); }; void setCodeL e (char _CodeLιne []) strcpy (CodeLine, _CodeLιne); }; void setKFGKnotenNummer (int _KnotenNr)
( KnotenNr _KnotenNr; ) ; void setKnotenldent (KnotenldentT _KnotenIdent )(Node number _ node number;); void setKnotIdent
Knotenldent _KnotenIdent; }; int getKnotenNummer ( ) ( return KnotenNr; }; char* getStatement!) ( return Statement; }; char* getCodeL e ( ) ( return CodeLme; }; int getLevel ( ) ( return Level; }; int getNodeNrl) ( return NodeNr; }; int getLιneNr() ( return LineNr; };Node ID _ node ID; }; int getNodeNumber () (return NodeNumber;}; char * getStatement!) (return Statement;}; char * getCodeL e () (return CodeLme;}; int getLevel () (return Level;}; int getNodeNrl) (return NodeNr; }; int getLιneNr () (return LineNr;};
KnotenldentT getKnotenlden ( ) ( return Knotenldent; };NodeIdentT getNodeIdent () (return
KFGNodeTypeT getKFGNodeType ( ) ( return KFGNodeType; }; bool Operator == (const KFGListNodeCS other) constKFGNodeTypeT getKFGNodeType () (return KFGNodeType;}; bool Operator == (const KFGListNodeCS other) const
( return ( (strcm tStatement, other .Statement ) == 0)(return ((strcm tStatement, other .Statement) == 0)
S (Level — other. Level ) S (KFGNodeType == other. KFGNodeType) s (NodeNr == other. NodeNr) ); }; bool Operator '= (const KFGListNodeCS other) constS (Level - other. Level) S (KFGNodeType == other. KFGNodeType) s (NodeNr == other. NodeNr)); }; bool operator '= (const KFGListNodeCS other) const
( return ! (*thιs == other) ; } ; bool Operator < (const KFGListNodeCS other) const (strcm l Statement, other. Statement) < 0); }; bool Operator > (const KFGListNodeCS other) const return (strcmpIStatement, other. Statement ) > 0); }; friend ostreamS Operator « ( ostreamS os, const KFGListNodeCS Node);(return! (* thιs == other);}; bool Operator <(const KFGListNodeCS other) const (strcm l Statement, other. Statement) <0); }; bool Operator> (const KFGListNodeCS other) const return (strcmpIStatement, other. Statement)> 0); }; friend ostreamS Operator «(ostreamS os, const KFGListNodeCS Node);
jfendifjfendif
//ftinclude <strιng> //fl clude <ιostream> //«include "KFGList.h"// ftinclude <strιng> // fl clude <ιostream> // «include" KFGList.h "
//us g namespace std;// us g namespace std;
//class KFGListOpC : public KFGListeC (// class KFGListOpC: public KFGListeC (
//public:// public:
// void KFGListOut (KFGListeT S L)// void KFGListOut (KFGListeT S L)
// (// (
// KFGListeT: : iterator I = L.beginO;// KFGListeT:: iterator I = L.beginO;
// while (I '•= L.end! ) ) // cout « *I++ « ' ' ;// while (I '• = L.end!)) // cout «* I ++« '';
// cout « " sιze ( ) = " « L. size O « endl;// cout «" sιze () = "« L. size O «endl;
// } //); //} //);
IIII II IIII 111 Uli III I I Hill II lllll 1111 III I IIIIII II IIII 111 Uli III I I Hill II llllll 1111 III I II
DD
// Klasse für Hilfsliste, um daraus einen KFG zu erstellen. Q// Class for help list to create a KFG from it. Q
// Diese Klasse erfüllt die nice-Anforderungen für die STL;// This class meets the nice requirements for the STL;
// d.h. für eine Klasse T gilt// i.e. applies to a class T.
// 0. Sie unterstützt den Copy-Konstruktor T (const TS),// 0. It supports the copy constructor T (const TS),
// 1. den Zuweisungsoperator Ts operator= (const Ts), // 2. den Vergleichsoperator bool operator== (const T, Sconst T ) und// 1. the assignment operator Ts operator = (const Ts), // 2. the comparison operator bool operator == (const T, Sconst T) and
// 3. den Ungleichoperator !=// 3. the unequal operator! =
// in einer Weise so daß gilt:// in such a way that:
// (a) { TRUE } T a(b) (a — b)// (a) {TRUE} T a (b) (a - b)
// (b) ( TRUE } a = b (a == b} // (c) ( a — a}// (b) (TRUE} a = b (a == b} // (c) (a - a}
// (d) ( a == b <==> b == a }// (d) (a == b <==> b == a}
// (e) ( (a == b) AND ( b — c ) —> (a == c) }// (e) ((a == b) AND (b - c) -> (a == c)}
// (f) { a '= b <==> NOT ( a== b) };// (f) {a '= b <==> NOT (a == b)};
// // Außerdem sind alle Funktionen, insbesondere getName equality preservmg, d.h.// // In addition, all functions, especially getName equality preservmg, i.e.
// (g) ( a = b == > a.getName!) == b. getName!) }// (g) (a = b ==> a.getName!) == b. getName!)}
////
// (C) 1997 Siemens AG// (C) 1997 Siemens AG
// // II II llll III III II 1997-08-25 Andreas Steinhorst// // II II III III III II 1997-08-25 Andreas Steinhorst
HIHI 111 ιι m um um ιι ι in ι IIII 11 m 11 ιι ι ιι ι m IIII um m ffifdef _KFGNodeHeader «eise ffdef e _KFGNodeHeader ff clude <stπng> ffinclude <ιostream> using namespace std; typedef char StringT [256]; class KFGNodeC ( private:HIHI 111 ιι um um ιι ι in ι IIII 11 m 11 ιι ι ιι ι m IIII um m ffifdef _KFGNodeHeader «eise ffdef e _KFGNodeHeader ff clude <stπng> ffinclude <ιostream> using namespace std; typedef char StringT [256]; class KFGNodeC (private:
StringT Name; int ScopeLevel; public:StringT Name; int ScopeLevel; public:
KFGNodeCO ( strcpy (Name, "— unknown —"); ScopeLevel = 0;KFGNodeCO (strcpy (name, "- unknown -"); ScopeLevel = 0;
/* cout « "NodeC erzeugt" « endl ; */};/ * cout «" NodeC creates "« endl; * /};
KFGNodeCIchar _Name [] ) ( strcpy (Name, _Name);KFGNodeCIchar _Name []) (strcpy (Name, _Name);
ScopeLevel = 0; ); KFGNodeCIchar _Name [], int _ScopeLevel)ScopeLevel = 0; ); KFGNodeCIchar _Name [], int _ScopeLevel)
( strcpy (Name,(strcpy (name,
_Name ) ;_Surname ) ;
ScopeLevel = ScopeLevel; } ; void setName(char _Name []) ( strcpy (Name, _Name); }; char* getName!) { return Name; }; int getScopeLevel ( ) ( return ScopeLevel; }; bool Operator == (const KFGNodeCS other) constScopeLevel = ScopeLevel; }; void setName (char _Name []) (strcpy (Name, _Name);}; char * getName!) {return Name; }; int getScopeLevel () (return ScopeLevel;}; bool Operator == (const KFGNodeCS other) const
{ return ( (strcmplName, other. Name) == 0) S (ScopeLevel{return ((strcmplName, other. Name) == 0) S (ScopeLevel
== other. ScopeLevel) ) ; }; bool Operator '= (const KFGNodeCS other) const return ! (*thιs== other. ScopeLevel)); }; bool operator '= (const KFGNodeCS other) const return! (* thιs
== other) bool Operator < (const KFGNodeCS other) const { return (strcm lName, other.Name) < 0); }; bool Operator > (const KFGNodeCS other) const return (strcmplName, other.Name) > 0); }; friend ostreamS Operator « ( ostreamS os, const KFGNodeCS Node);== other) bool operator <(const KFGNodeCS other) const {return (strcm lName, other.Name) <0); }; bool operator> (const KFGNodeCS other) const return (strcmplName, other.Name)> 0); }; friend ostreamS Operator «(ostreamS os, const KFGNodeCS Node);
}; ftendif ff ifdef _KFGNodelHeader D ffelse}; ftendif ff ifdef _KFGNodelHeader D ffelse
D ππiππ/ππ/ππiππ/ππ/ππi/π/ππ/π/ππii/ππ/π/π/π π in// ////////////D ππiππ / ππ / ππiππ / ππ / ππi / π / ππ / π / ππii / ππ / π / π / π π in // ////////////
I I Klasse für Hilfsliste, um daraus einen KFG zu erstellen.I I class for help list to create a KFG from it.
// Diese Klasse erfüllt die nice-Anforderungen für die STL; // d.h. für eine Klasse T gilt// This class meets the nice requirements for the STL; // i.e. applies to a class T.
// 0. Sie unterstützt den Copy-Konstruktor T (const Ts),// 0. It supports the copy constructor T (const Ts),
// 1. den Zuweisungsoperator TS operator= (const TS),// 1. the assignment operator TS operator = (const TS),
// 2. den Vergleichsoperator bool operator== (const T, const TS) und// 2. the comparison operator bool operator == (const T, const TS) and
// 3. den Ungleichoperator '= // in einer Weise so daß gilt:// 3. the unequal operator '= // in such a way that:
// (a) < TRUE } T a(b) (a == b}// (a) <TRUE} T a (b) (a == b}
// (b) ( TRUE } a = b (a == b}// (b) (TRUE} a = b (a == b}
// (c) ( a == a}// (c) (a == a}
// (d) ( a == b <==> b == a ) // (e) ( (a == b) AND ( b == c ) ==> (a == c) }// (d) (a == b <==> b == a) // (e) ((a == b) AND (b == c) ==> (a == c)}
// (f) ( a != b <==> NOT ( a== b) };// (f) (a! = b <==> NOT (a == b)};
////
// Außerdem sind alle Funktionen, insbesondere getName equality preservmg, d.h.// In addition, all functions, especially getName equality preservmg, i.e.
// (g) ( a == b == > a. getName!) == b. getName!) } //// (g) (a == b ==> a. getName!) == b. getName!)} //
// (C) 1997 Siemens AG// (C) 1997 Siemens AG
////
// 1111111111111111111111111111 lll/1/llll / 1 Hill I um 111/ /// 1111111111111111111111111111 lll / 1 / llll / 1 Hill I at 111 / /
II 1997-08-25 Andreas Steinhorst ππππmmiπmiπmm mim// im/m IIII ιι m in ιι ff ifdef _KFGNodelHeader ffelse ftdefine _KFGNodelHeader ffinclude <stnng> ffinclude <ιostream> us g namespace std; typedef char StringT [256]; class KFGLlstNodeC ( private: StringT Name; int ScopeLevel; list <KFGUseC> Uses; list <KFGDefC> Defs; public:II 1997-08-25 Andreas Steinhorst ππππmmiπmiπmm mim // im / m IIII ιι m in ιι ff ifdef _KFGNodelHeader ffelse ftdefine _KFGNodelHeader ffinclude <stnng> ffinclude <ιostream> us g namespace std; typedef char StringT [256]; class KFGLlstNodeC (private: StringT Name; int ScopeLevel; list <KFGUseC> Uses; list <KFGDefC> Defs; public:
KFGLlstNodeC() ( strcpy (Name, "— unknown —"); ScopeLevel = 0;KFGLlstNodeC () (strcpy (name, "- unknown -"); ScopeLevel = 0;
/* cout « "NodeC erzeugt" « endl ; */};/ * cout «" NodeC creates "« endl; * /};
KFGLlstNodeC (char _Name [] ) ( strcpy (Name, _Name);KFGLlstNodeC (char _Name []) (strcpy (Name, _Name);
ScopeLevel = 0; }; KFGLlstNodeC (char _Name [], int _ScopeLevel)ScopeLevel = 0; }; KFGLlstNodeC (char _Name [], int _ScopeLevel)
( strcpy (Name, Name ) ; ScopeLevel ■(strcpy (name, name); ScopeLevel ■
ScopeLevel; } ; void setName(char _Name []) strcpy (Name, _Name); }; char* getName!) ( return Name; ) ; int getScopeLevel ( ) ( return ScopeLevel; }; bool Operator == (const KFGListNodeCS other) constScopeLevel; }; void setName (char _Name []) strcpy (name, _Name); }; char * getName!) (return Name;); int getScopeLevel () (return ScopeLevel;}; bool Operator == (const KFGListNodeCS other) const
( return ((strcmplName, other. ame) == 0)(return ((strcmplName, other. ame) == 0)
S (ScopeLevel =« other. ScopeLevel) ); }; bool Operator != (const KFGListNodeCS other) constS (ScopeLevel = «other. ScopeLevel)); }; bool Operator! = (const KFGListNodeCS other) const
( return ' (*thιs == other) ; } ; bool Operator < (const KFGListNodeCS other) const return (strcmplName, other.Name) < 0); }; bool Operator > (const KFGListNodeCS other) const return (strcmplName, other.Name) > 0); ); friend ostreamS Operator « ( ostreamS os, const KFGListNodeCS Node);(return '(* thιs == other);}; bool Operator <(const KFGListNodeCS other) const return (strcmplName, other.Name) <0); }; bool operator> (const KFGListNodeCS other) const return (strcmplName, other.Name)> 0); ); friend ostreamS Operator «(ostreamS os, const KFGListNodeCS Node);
ffendlf flifdef KFGNodelHeader 0ffendlf flifdef KFGNodelHeader 0
»eise»Ice
DD
III lllll III 11 lllll III II I II III 11 lllll 11 II I III 111 III I II I II IIII II II I IIIII lllll III 11 lllll III II I II III 11 lllll 11 II I III 111 III I II I II IIII II II I II
0 // Klasse für Hilfsliste, um daraus einen KFG zu erstellen.0 // class for help list to create a KFG from it.
DD
// Diese Klasse erfüllt die nice-Anforderungen für die STL;// This class meets the nice requirements for the STL;
// d.h. für eme Klasse T gilt// i.e. applies to a class T.
// 0. Sie unterstützt den Copy-Konstruktor T (const TS), II I . den Zuweisungsoperator Ts operator= (const TS),// 0. It supports the copy constructor T (const TS), II I. the assignment operator Ts operator = (const TS),
// 2. den Vergleichsoperator bool operator== (const T, Sconst TS) und// 2. the comparison operator bool operator == (const T, Sconst TS) and
// 3. den Ungleichoperator !=// 3. the unequal operator! =
// in einer Weise so daß gilt:// in such a way that:
// (a) ( TRUE ) T a(b) (a — b) // (b) ( TRUE } a = b (a == b}// (a) (TRUE) T a (b) (a - b) // (b) (TRUE} a = b (a == b}
// (c) { a — a)// (c) {a - a)
// (d) ( a == b <==> b == a }// (d) (a == b <==> b == a}
// (e) ( (a =- b) AND ( b == c ) ==> (a == c) }// (e) ((a = - b) AND (b == c) ==> (a == c)}
// (f) ( a '= b <==> NOT ( a— b) }; //// (f) (a '= b <==> NOT (ab - b)}; //
// Außerdem sind alle Funktionen, insbesondere getName equality preservmg, d.h.// In addition, all functions, especially getName equality preservmg, i.e.
// (g) ( a ~ b — > a. getName () == b. getName!) }// (g) (a ~ b -> a. getName () == b. getName!)}
////
// (C) 1997 Siemens AG //// (C) 1997 Siemens AG //
// ππiππ/ππiππiππiππiiπ/π/iiiiπ IIII π/π iiiiππ ////// ////////// ππiππ / ππiππiππiππiiπ / π / iiiiπ IIII π / π iiiiππ ////// ////////
II 1997-08-25 Andreas Steinhorst mimiiiπmiiπiiππmimiiiii πimmm ππ m ////////////im im ff ifdef _KFGNodelHeader »eise ffdefine KFGNodelHeader ffinclude <strmg> ffinclude <ιostream> using namespace std; typedef char StringT [256]; class KFGLlstNodeC { private:II 1997-08-25 Andreas Steinhorst mimiiiπmiiπiiππmimiiiii πimmm ππ m //////////// im im ff ifdef _KFGNodelHeader »eise ffdefine KFGNodelHeader ffinclude <strmg> ffinclude <ιostream> using namespace std; typedef char StringT [256]; class KFGLlstNodeC {private:
StringT Name; int ScopeLevel; list <KFGUseC> Uses; list <KFGDefC> Defs; public:StringT Name; int ScopeLevel; list <KFGUseC>Uses; list <KFGDefC>Defs; public:
KFGLlstNodeC! ) ( strcpy (Name, known ScopeLevel = 0;KFGLlstNodeC! ) (strcpy (Name, known ScopeLevel = 0;
/* cout « "NodeC erzeugt" « endl ; */};/ * cout «" NodeC creates "« endl; * /};
KFGLlstNodeC (char _Name [) ) ( strcpy (Name, _Name);KFGLlstNodeC (char _Name [)) (strcpy (Name, _Name);
ScopeLevel = 0; ) ; KFGLlstNodeC (char _Name [], int _ScopeLevel)ScopeLevel = 0; ); KFGLlstNodeC (char _Name [], int _ScopeLevel)
( strcpy (Name, _Name ) ;(strcpy (name, _Name);
ScopeLevel = ScopeLevel; ); - void setNamelchar _Name []) ( strcpy (Name, _Name); }; char* getName!) ( return Name; ) ,- int getScopeLevel ( ) ( return ScopeLevel; ); bool Operator == (const KFGListNodeCS other) constScopeLevel = ScopeLevel; ); - void setNamelchar _Name []) (strcpy (Name, _Name);}; char * getName!) (return Name;), - int getScopeLevel () (return ScopeLevel;); bool operator == (const KFGListNodeCS other) const
( return ((strcmplName, other.Name) == 0) S (ScopeLevel(return ((strcmplName, other.Name) == 0) S (ScopeLevel
== other. ScopeLevel) ) ; }; bool Operator != (const KFGListNodeCS other) const== other. ScopeLevel)); }; bool Operator! = (const KFGListNodeCS other) const
( return ! (*thιs == other); ); bool Operator < (const KFGListNodeCS other) const(return! (* thιs == other);); bool operator <(const KFGListNodeCS other) const
( return (strcmplName, other.Name) < 0); }; bool Operator > (const KFGListNodeCS other) const(return (strcmplName, other.Name) <0); }; bool Operator> (const KFGListNodeCS other) const
{ return (strcmp(Name, other.Name) > 0); ); friend ostreamS Operator « ( ostreamS os, const KFGListNodeCS Node);{return (strcmp (Name, other.Name)> 0); ); friend ostreamS Operator «(ostreamS os, const KFGListNodeCS Node);
); ffendif); ffendif
//Klasse für eine Liste aus STL. KFGListeC erbt dabei alle Eigenschaften //von der mit STL erstellten Liste lιst<KFGNodeC>. «lfdef _KFGProgLιstHeader (leise «define _KFGProgListHeader ffinclude <strιng> ffinclude <ιostream> ffinclude <stdιo.h> flinclude <lιst> ffinclude <fstream> ffinclude <ιterator> ffinclude "KFGLineNode.h" using namespace std; class KFGProgListC : public lιst<KFGLιneNodeC> ( public:// class for a list from STL. KFGListeC inherits all properties // from the list created with STL <KFGNodeC>. «Lfdef _KFGProgLιstHeader (quietly« define _KFGProgListHeader ffinclude <strιng> ffinclude <ιostream> ffinclude <stdιo.h> flinclude <lιst> ffinclude <fstream> ffinclude <ιterator> namfinespodehsting using KFNclodGlist using the class; using the FinNodeGlist; KFNclingGlist using the name; using the FinNodeGlead; KFNclodGlist using the "; KFGLιneNodeC> (public:
KFGProgListC!) (); //void KFGListeAusgebenl ) ;KFGProgListC!) (); // void KFGListeAusgabel);
//void KFGTokenListToKFGList (); ) ; ffendif// void KFGTokenListToKFGList (); ); ffendif
//Klasse für eine Liste aus STL. KFGListeC erbt dabei alle Eigenschaften D// class for a list from STL. KFGListeC inherits all properties D
//von der mit STL erstellten Liste lιst<KFGNodeC>. D difdef _KFGTokenListHeader D// from the list created with STL, <KFGNodeC>. D difdef _KFGTokenListHeader D
»eise D ffdefine KFGTokenListHeader ü»Else D ffdefine KFGTokenListHeader ü
DD
D ffinclude <stnng>D ffinclude <stnng>
D ffinclude <ιostream>D ffinclude <ιostream>
O ffinclude <stdιo.h> ffinclude <lιst> ffinclude <fstream> ffinclude <ιterator>O ffinclude <stdιo.h> ffinclude <lιst> ffinclude <fstream> ffinclude <ιterator>
#ιnclude "KFGTokenNode.h" usmg namespace std; class KFGTokenListC : public lιst<KFGTokenNodeC> ( public:# ιnclude "KFGTokenNode.h" usmg namespace std; class KFGTokenListC: public reads <KFGTokenNodeC> (public:
KFGTokenListC!) (}; void KFGListeAusgebenl ) ;KFGTokenListC!) (}; Void KFGListeAusgabel);
//void KFGTokenListToKFGList ();// void KFGTokenListToKFGList ();
}; ffendif}; ffendif
III 11 III IIII II 111 II IIII III II II III 11111 II II 11 III 1111111111 II III III I III I lllll IIIIIII 11 III IIII II 111 II IIII III II II III 11111 II II 11 III 1111111111 II III III I III I III III
D // Klasse für Hilfsliste, um daraus einen KFG zu erstellen.D // Class for help list to create a KFG from it.
DD
// Diese Klasse erfüllt die nice-Anforderungen für die STL;// This class meets the nice requirements for the STL;
DD
// d.h. für eine Klasse T gilt // 0. Sie unterstützt den Copy-Konstruktor T (const T ) ,// i.e. for a class T applies // 0. It supports the copy constructor T (const T),
// 1. den Zuweisungsoperator TS operator= (const Ts),// 1. the assignment operator TS operator = (const Ts),
// 2. den Vergleichsoperator bool operator== (const T, Sconst TS) und// 2. the comparison operator bool operator == (const T, Sconst TS) and
// 3. den Ungleichoperator '=// 3. the unequal operator '=
// in einer Weise so daß gilt: // (a) ( TRUE } T a(b) (a -= b)// in such a way that: // (a) (TRUE} T a (b) (a - = b)
// (b) < TRUE } a = b (a == b)// (b) <TRUE} a = b (a == b)
// (c) ( a == a)// (c) (a == a)
// (d) { a == b <==> b == a }// (d) {a == b <==> b == a}
// (e) ( (a == b) AND ( b == c ) ==> (a == c) ) // (f) ( a '= b <==> NOT ( a== b) };// (e) ((a == b) AND (b == c) ==> (a == c)) // (f) (a '= b <==> NOT (a == b) };
////
// Außerdem sind alle Funktionen, insbesondere getName equality preservmg, d.h.// In addition, all functions, especially getName equality preservmg, i.e.
// (g) ( a == b == > a.getNameO == b. getName!) )// (g) (a == b ==> a.getNameO == b. getName!))
// // (C) 1997 Siemens AG// // (C) 1997 Siemens AG
////
// lllll I I II II II II I I II II II II II I I I I I III I I I I I I I I I I I I I I II I I I I I I III I II II I I I III I /// lllll I I II II II II I I II II II II II I I I I I III I I I I I I I I I I I I I II II I I I I I III I II II I I I III I /
II 1997-08-25 Andreas StemhorstII 1997-08-25 Andreas Stemhorst
/ / ιι ιι IIIII im m mπiπiimπm mm/1 ii / 11 m ι ιι 11 mπimiiim ffifdef _KFGTokenNodeHeader ffelse (fdefme KFGTokenNodeHeader ffinclude <strιng> ffinclude <ιostream> usmg namespace std; typedef char StringT [256); typedef enum (N,PL,IF,BT,ET,BE,EE,FOR,BF,EF,WHILE,BW,EW,SW,CA,ECA,BRK,RET,DEFA,EDEFA, DO, BDOW, DOWS,NL, DEF , BFUNC, EFUNC, TD, OUT, FOR_D, PF) TokenNodeTypeT; class KFGTokenNodeC ( private:/ / ιι ιι IIIII in m mπiπiimπm mm / 1 ii / 11 m ι ιι 11 mπimiiim ffifdef _KFGTokenNodeHeader ffelse (fdefme KFGTokenNodeHeader ffinclude <strιng> ffinclude <ιostream> usmg namespace std; typedef char StringT [256); typedef enum (N, PL, IF, BT, ET, BE, EE, FOR, BF, EF, WHILE, BW, EW, SW, CA, ECA, BRK, RET, DEFA, EDEFA, DO, BDOW, DOWS, NL , DEF, BFUNC, EFUNC, TD, OUT, FOR_D, PF) TokenNodeTypeT; class KFGTokenNodeC (private:
StringT Name;StringT Name;
TokenNodeTypeT TokenNodeType; int ScopeLevel; int LineNumber; public:TokenNodeTypeT TokenNodeType; int ScopeLevel; int LineNumber; public:
KFGTokenNodeC ( ) { strcpy (Name, "— un- known —" )KFGTokenNodeC () {strcpy (name, "- un- known -")
ScopeLevel = 0; TokenNodeType =ScopeLevel = 0; TokenNodeType =
N;N;
LineNumber = 0; );LineNumber = 0; );
KFGTokenNodeC (char _Name [], TokenNodeTypeT _TokenNodeType )KFGTokenNodeC (char _Name [], TokenNodeTypeT _TokenNodeType)
( strcpy (Name,(strcpy (name,
_Name ) ;_Surname ) ;
ScopeLevel - 0; TokenNodeTypeScopeLevel - 0; TokenNodeType
_TokenNodeType;_TokenNodeType;
LineNumber = 0;);LineNumber = 0;);
KFGTokenNodeC (char _Name [], int _ScopeLevel, TokenNodeTypeT TokenNodeType)KFGTokenNodeC (char _Name [], int _ScopeLevel, TokenNodeTypeT TokenNodeType)
( strcpy (Name,(strcpy (name,
_Name) ; ScopeLevel = _ScopeLevel;_Surname) ; ScopeLevel = _ScopeLevel;
TokenNodeType = TokenNodeType; LineNumber = 0;TokenNodeType = TokenNodeType; LineNumber = 0;
KFGTokenNodeC (char _Name [], t _ScopeLevel, TokenNodeTypeT _TokenNodeType, int LineNumber)KFGTokenNodeC (char _Name [], t _ScopeLevel, TokenNodeTypeT _TokenNodeType, int LineNumber)
( strcpy (Name,(strcpy (name,
_Name ) ; ScopeLevel = _ScopeLevel;_Surname ) ; ScopeLevel = _ScopeLevel;
TokenNodeType _TokenNodeType; LineNumber = LineNumber; ); void setNamelchar _Name []) ( strcpy (Name, _Name); ); char* getName ( ) ( return Name; }; int getScopeLevel ( ) ( return ScopeLevel; ); mt getLineNumber ( ) ( return LineNumber; ); TokenNodeTypeT getTokenNodeType ( ) ( return TokenNodeType; }; bool Operator == (const KFGTokenNodeCS other) const return ((strcmplName, other. Name) == 0)TokenNodeType _TokenNodeType; LineNumber = LineNumber; ); void setNamelchar _Name []) (strcpy (Name, _Name);); char * getName () (return Name;}; int getScopeLevel () (return ScopeLevel;); mt getLineNumber () (return LineNumber;); TokenNodeTypeT getTokenNodeType () (return TokenNodeType;}; bool Operator == (const KFGTokenNodeCS other) const return ((strcmplName, other. Name) == 0)
S (ScopeLevel == other. ScopeLevel )S (ScopeLevel == other. ScopeLevel)
S (TokenNode- Type == other. TokenNodeType) ) ; }; bool Operator '= (const KFGTokenNodeCS other) const ( return ' (*thιs -= other); ); bool Operator < (const KFGTokenNodeCS other) const ( returnS (TokenNodeType == other. TokenNodeType)); }; bool operator '= (const KFGTokenNodeCS other) const (return '(* thιs - = other);); bool Operator <(const KFGTokenNodeCS other) const (return
(strcmplName, other.Name) < 0); }; bool Operator > (const KFGTokenNodeCS other) const(strcmplName, other.Name) <0); }; bool operator> (const KFGTokenNodeCS other) const
( return (strcmplName, other.Name) > 0); ); friend ostreamS Operator « ( ostreamS os, const KFGTokenNodeCS Node); ); ffendif ff ifdef _KFGUseHeader D »eise(return (strcmplName, other.Name)> 0); ); friend ostreamS Operator «(ostreamS os, const KFGTokenNodeCS Node); ); ffendif ff ifdef _KFGUseHeader D »eise
DD
»define _KFGUseHeader D D»Define _KFGUseHeader D D
»include <stπng>»Include <stπng>
DD
»include <ιostream>»Include <ιostream>
O o usmg namespace std; DO o usmg namespace std; D
G typedef char StringT [256]; DG typedef char StringT [256]; D
D class KFGUseC ( α private:D class KFGUseC (α private:
D DD D
StringT Use;StringT Use;
D int ScopeLevelU; DD int ScopeLevelU; D
D public: DD public: D
KFGUseC () ( strcpy (Use, "— unknown --" ) ;KFGUseC () (strcpy (Use, "- unknown -");
ScopeLevelU = 0; );ScopeLevelU = 0; );
KFGUseC(char _Use [], int _ScopeLevelU) ( strcpy (Use, _Use);KFGUseC (char _Use [], int _ScopeLevelU) (strcpy (Use, _Use);
ScopeLevelU = _ScopeLevelU; } ; void setUse(char _Use []) ( strcpy (Use, _Use); ) char* getUse I ) ( return Use; ) int getScopeLevelU ( ) ( return ScopeLevelU; } bool Operator == (const KFGUseCS other) constScopeLevelU = _ScopeLevelU; }; void setUse (char _Use []) (strcpy (Use, _Use);) char * getUse I) (return Use;) int getScopeLevelU () (return ScopeLevelU;} bool Operator == (const KFGUseCS other) const
( return ( (strcmp (Use, other. Use) — 0) s (ScopeLevelU == other. ScopeLevelU) ) ; ); bool Operator '= (const KFGUseCS other) const(return ((strcmp (Use, other. Use) - 0) s (ScopeLevelU == other. ScopeLevelU));); bool operator '= (const KFGUseCS other) const
( return ' (*thιs == other) ; }; bool Operator < (const KFGUseCS other) const(return '(* thιs == other);}; bool operator <(const KFGUseCS other) const
( return (strcmplUse, other.Use) < 0); ); bool Operator > (const KFGUseCS other) const f return (strcmplUse, other.Use) > 0); ); friend ostreamS Operator « I ostreamS os, const KFGUseCS Node);(return (strcmplUse, other.Use) <0); ); bool operator> (const KFGUseCS other) const f return (strcmplUse, other.Use)> 0); ); friend ostreamS Operator «I ostreamS os, const KFGUseCS Node);
};};
»endif»Endif
»ifndef _uwggraphC D»Ifndef _uwggraphC D
»def e uwggraphC D»Def e uwggraphC D
00
»mclude <Graph. h> D »include "uwgknoten . h" D»Mclude <graph. h> D »include" uwgknoten. h "D
»include "uwgkante . h" 0 »include "AS Slice . h" using namespace std; class uwggraphC : public Graph < uwgknotenC, uwgkanteC > ( public:»Include" uwgkante. H "0» include "AS Slice. H" using namespace std; class uwggraphC: public graph <uwgknotenC, uwgkanteC> (public:
Short mt eingefaltet; uwggraphC! ) { } ; SliceC: : iterator findOutputNode (SliceC s Sl ) ;Short mt folded; uwggraphC! ) {}; SliceC:: iterator findOutputNode (SliceC s Sl);
SliceC: : iterator definelterator (SliceC S Sl, mt SliceNr); void addFirstNodesToFTISliceC s Sl, int KnotenNr, int Posl);SliceC:: iterator definelterator (SliceC S Sl, mt SliceNr); void addFirstNodesToFTISliceC s Sl, int NodeNo, int Posl);
SliceC: : iterator returnCondNode (SliceC S Sl, mt SliceNr); mt checkUWGNode(ιnt SliceNr); void SliceAusgeben! SliceC S Sl ) t void startBuildFT (SliceC S Sl ) ; void buildInLoopTree (SliceC S Sl, int Posl, SliceC: : iterator SLPUSE, Sli- ceC: : iterator SLNODE); void buιldIn_Dl_Part (SliceC S Sl, int posOR_Dl, SliceC: : iterator SLPUSE, SliceC: : iterator SLNODE, int D2_RefNr); SliceC: :ιterator f dOutmostPUse (SliceC S Sl, SliceC: : iterator SLPUSE); int checkPUsesl (SliceC S Sl, SliceC: : iterator SLPUSE, SliceC: : iterator SLPUSEREF) ; mt checkPUses2 (SliceC S Sl, SliceC: :ιterator SLPUSE, SliceC: :ιteratorSliceC:: iterator returnCondNode (SliceC S Sl, mt SliceNr); mt checkUWGNode (ιnt SliceNr); void Slice SliceC S Sl) t void startBuildFT (SliceC S Sl); void buildInLoopTree (SliceC S Sl, int Posl, SliceC:: iterator SLPUSE, SliceC:: iterator SLNODE); void buιldIn_Dl_Part (SliceC S Sl, int posOR_Dl, SliceC:: iterator SLPUSE, SliceC:: iterator SLNODE, int D2_RefNr); SliceC:: ιterator f dOutmostPUse (SliceC S Sl, SliceC:: iterator SLPUSE); int checkPUsesl (SliceC S Sl, SliceC:: iterator SLPUSE, SliceC:: iterator SLPUSEREF); mt checkPUses2 (SliceC S Sl, SliceC:: ιterator SLPUSE, SliceC:: ιterator
SLPUSEREF) ;SLPUSEREF);
SliceC: : iterator fιnd_Dl_Node (SliceC S Sl, SliceC: : iterator SLPUSE, SliceC: :ιterator SLNODE); void addAllDlNodes (SliceC S Sl, SliceC: : iterator SLNODE, int posGatter, int D2_RefNr);SliceC:: iterator fιnd_Dl_Node (SliceC S Sl, SliceC:: iterator SLPUSE, SliceC:: ιterator SLNODE); void addAllDlNodes (SliceC S Sl, SliceC:: iterator SLNODE, int posGatter, int D2_RefNr);
SliceC: :ιterator findLastPUse (SliceC S Sl, int SliceNr);SliceC:: ιterator findLastPUse (SliceC S Sl, int SliceNr);
SliceC: : iterator fmdLastPUse2 (SliceC S Sl, int SliceNr, mt RefNr); void checkLoopOrCondl SliceC S Sl, SliceC: :ιterator SLl, SliceC: :ιterator SLORIG, int Posil ) ; void buildIn_D2_Part (SliceC S Sl, int posOR_D2, SliceC: : iterator SLl, SliceC: : iterator SLPUSE, int KnotenNrD2); int fιndD2Node(SliceC S Sl, SliceC: : iterator PUSE); t buildlnlfTree (SliceC s Sl, SliceC: :ιterator SLIF, SliceC: : iterator SLORIG, int posl ) ;SliceC:: iterator fmdLastPUse2 (SliceC S Sl, int SliceNr, mt RefNr); void checkLoopOrCondl SliceC S Sl, SliceC:: ιterator SLl, SliceC:: ιterator SLORIG, int Posil); void buildIn_D2_Part (SliceC S Sl, int posOR_D2, SliceC:: iterator SLl, SliceC:: iterator SLPUSE, int nodeNoD2); int fιndD2Node (SliceC S Sl, SliceC:: iterator PUSE); t buildlnlfTree (SliceC s Sl, SliceC:: ιterator SLIF, SliceC:: iterator SLORIG, int posl);
SliceC: : iterator lookForNextPUse (SliceC S Sl, SliceC: :ιterator SNODE, SliceC: : iterator SLPUSE); void buιld_IFKF_Part( SliceC S Sl, t posKFOR, SliceC: : iterator SLPUSE); void build_Al_Part (SliceC S Sl, int posIFDFOR, SliceC: :iterator SLIF, SliceC: : iterator SLORIG); void buιldD2_IFKF_Part (SliceC S Sl, int posKFOR, SliceC: : iterator SLPUSE); void buιldD2_Al_Part (SliceC S Sl, int posIFDFOR, SliceC: : iterator SLIF, SliceC: :ιterator SLNODE) ; int buιldD2InIfTree (SliceC S Sl, SliceC: :ιterator SLIF, SliceC: : iterator SLORIG, int posl); void buιldLoopKF_Part (SliceC S Sl, mt posAND_KF, int posLOOP_KF, int posD2, SliceC: : iterator SLOOP); mt buιldIn_LoopKF_ANDPart (SliceC S Sl, int posAND_KF, SliceC: :ιteratorSliceC:: iterator lookForNextPUse (SliceC S Sl, SliceC:: ιterator SNODE, SliceC:: iterator SLPUSE); void buιld_IFKF_Part (SliceC S Sl, t posKFOR, SliceC:: iterator SLPUSE); void build_Al_Part (SliceC S Sl, int posIFDFOR, SliceC:: iterator SLIF, SliceC:: iterator SLORIG); void buιldD2_IFKF_Part (SliceC S Sl, int posKFOR, SliceC:: iterator SLPUSE); void buιldD2_Al_Part (SliceC S Sl, int posIFDFOR, SliceC:: iterator SLIF, SliceC:: ιterator SLNODE); int buιldD2InIfTree (SliceC S Sl, SliceC:: ιterator SLIF, SliceC:: iterator SLORIG, int posl); void buιldLoopKF_Part (SliceC S Sl, mt posAND_KF, int posLOOP_KF, int posD2, SliceC:: iterator SLOOP); mt buιldIn_LoopKF_ANDPart (SliceC S Sl, int posAND_KF, SliceC:: ιterator
SLPUSE ) ; void buildIn_LoopKF_ORPart (SliceC S Sl, int posAND_KF, SliceC: : iterator SLl, int KnotenNrD2);SLPUSE); void buildIn_LoopKF_ORPart (SliceC S Sl, int posAND_KF, SliceC:: iterator SLl, int nodeNoD2);
};};
»endi»Endi
»lfndef _uwgkanteC »def e _uwgkanteC»Lfndef _uwgkanteC» def e _uwgkanteC
»include <ιostream using namespace std; class uwgkanteC ( public:»Include <ιostream using namespace std; class uwgkanteC (public:
Short int eingefaltet; int Number; uwgkanteC () {}; uwgkanteC (mt _Number) { Number = _Number; bool Operator == (const uwgkanteCS other) constShort int folded; int Number; uwgkanteC () {}; uwgkanteC (mt _Number) {Number = _Number; bool operator == (const uwgkanteCS other) const
( return (Number — other. Number ) ; }; bool Operator '= (const uwgkanteCS other) const(return (Number - other. Number);}; bool Operator '= (const uwgkanteCS other) const
( return ' (*thιs == other); ); bool Operator < (const uwgkanteCS other) const(return '(* thιs == other);); bool operator <(const uwgkanteCS other) const
( return (Number == other. umber ) ; }; bool Operator > (const uwgkanteCS other) const(return (Number == other. umber);}; bool Operator> (const uwgkanteCS other) const
( return (Number == other.Number ) ; ); friend ostreamS Operator « ( ostreamS os, const uwgkanteCS Node);(return (Number == other.Number);); friend ostreamS Operator «(ostreamS os, const uwgkanteCS Node);
»endif »lfndef _uwgknotenC»Endif »Lfndef _uwgknotenC
DD
»define _uwgknotenC»Define _uwgknotenC
DD
D ffinclude <iostream> const int maxKnotentextLength=128; const mt maxBemerkLength=1000; const mt maxWahrVarLength=16; typedef struct ww (D ffinclude <iostream> const int maxKnotentextLength = 128; const mt maxBemerkLength = 1000; const mt maxWahrVarLength = 16; typedef struct ww (
Short mt Wert; struct ww *next; } TMCSWert; typedef struct el ( struct ftgatter* unabElement; struct ww *next; struct el *nextel; ) TMinSet; typedef enum (AND, OR, CAUSE, EFFECT, NOT] NodeldentT; usmg namespace std; class uwgknotenC ( public: static int DummyNr; t Gatterldent; t outof; int CauseNr; char gattertext [maxKnotentextLength] ; char gatterbemerkung [maxBemerkLength] ; double wahrseh; char wahrvar [maxWahrVarLength] ;Short mt value; struct ww * next; } TMCSValue; typedef struct el (struct ftgatter * unabElement; struct ww * next; struct el * nextel;) TMinSet; typedef enum (AND, OR, CAUSE, EFFECT, NOT] NodeldentT; usmg namespace std; class uwgknotenC (public: static int DummyNr; t Gatterldent; t outof; int CauseNr; char gattertext [maxKnotentextLength]; char Gatternemerkung [maxBemerkLength]; double char; var true [maxWahrVarLength];
NodeldentT Nodeldent; uwgknotenC () ( Nodeldent = EFFECT;NodeldentT Nodeldent; uwgknotenC () (Nodeldent = EFFECT;
CauseNr = 0; strcpy (gattertext, "— unknown —"); strcpy (gatterbemerkung, "—keine—");CauseNr = 0; strcpy (gate text, "- unknown -"); strcpy (gate remark, "—none" ");
Gatterldent = DummyNr++; }; uwgknotenC (NodeldentT _NodeIdent )Gatterldent = DummyNr ++; }; uwgknotenC (NodeldentT _NodeIdent)
( Nodeldent = _NodeIdent;(Nodeldent = _NodeIdent;
CauseNr = 0; strepylgattertext, "— unknown —"); strepylgatterbemerkung, "—keine—");CauseNr = 0; strepyl gate text, "- unknown -"); strepyl gate remark, "—none—");
Gatterldent = DummyNr++; ); uwgknotenC (NodeldentT _NodeIdent, t _CauseNr/*, char _gattertext [ ] */ ) Gatterldent = DummyNr ++; ); uwgknotenC (NodeldentT _NodeIdent, t _CauseNr / *, char _gattertext [] * / )
( Nodeldent = _NodeIdent;(Nodeldent = _NodeIdent;
CauseNr = CauseNr; strepylgattertext, "— unknown —"); strepylgatterbemerkung, "—keine—") ; /*strcpy(gattertext, _gattertext ) ;*/CauseNr = CauseNr; strepyl gate text, "- unknown -"); strepyl gate remark, "—none—"); / * strcpy (gattertext, _gattertext); * /
GatterldentGatterldent
DummyNr++; }; uwgknotenC (NodeldentT _NodeIdent, t _CauseNr, char _gattertex [ ] , char _gatterbemerkung[ ] )DummyNr ++; }; uwgknotenC (NodeldentT _NodeIdent, t _CauseNr, char _gattertex [], char _gatterbemerkung [])
( Nodeldent = _NodeIdent; CauseNr =(Nodeldent = _NodeIdent; CauseNr =
_CauseNr; strepylgattertext, "— unknown —"); strepylgattertext, _gattertext ) ; strepylgatterbemerkung, _gatterbemerkung) ;_CauseNr; strepyl gate text, "- unknown -"); strepylgattertext, _gattertext); strepyl gate remark, _gate remark);
Gatterldent DummyNr++; }; uwgknotenC(NodeldentT _NodeIdent, int _CauseNr, char _gattertext ( ] )Gatterldent DummyNr ++; }; uwgknotenC (NodeldentT _NodeIdent, int _CauseNr, char _gattertext (])
( Nodeldent = _NodeIdent;(Nodeldent = _NodeIdent;
CauseNr = _CauseNr;CauseNr = _CauseNr;
/*strcpy (gattertext, "— unknown —");*/ strepylgattertext, _gattertext) ; strepylgatterbemerkung, "—keine—" ) ;/ * strcpy (gattertext, "- unknown -"); * / strepylgattertext, _gattertext); strepyl gate remark, "—none—");
Gatterldent DummyNr++; ); uwgknotenC (NodeldentT _NodeIdent, ehar _gattertext [ ] , charGatterldent DummyNr ++; ); uwgknotenC (NodeldentT _NodeIdent, ehar _gattertext [], char
_gatterbemerkung[] )_gatter remark [])
( Nodeldent =(Nodeldent =
Nodeldent; CauseNr = 0; strepylgattertext, _gattertext) ; strepylgatterbemerkung, _gatterbemerkung) ;Nodeldent; CauseNr = 0; strepylgattertext, _gattertext); strepyl gate remark, _gate remark);
Gatterldent DummyNr++; ) ; uwgknotenC (NodeldentT _NodeIdent, char _gattertext [ ] )Gatterldent DummyNr ++; ); uwgknotenC (NodeldentT _NodeIdent, char _gattertext [])
( Nodeldent = _NodeIdent; CauseNr = 0; strepylgattertext, _gattertext) ; strepylgatterbemerkung, "—keine—" ) ; Gatterldent «(Nodeldent = _NodeIdent; CauseNr = 0; strepylgattertext, _gattertext); strepyl gate remark, "—none—"); Gatterldent «
DummyNr++; }; int getCauseNrl) ( return CauseNr; }; mt getGatterldent ( ) ( return Gatterldent; );DummyNr ++; }; int getCauseNrl) (return CauseNr;}; mt getGatterldent () (return Gatterldent;);
NodeldentT getNodeldent I ) const ( return Nodeldent; ); bool Operator == (const uwgknotenCS other) eonstNodeldentT getNodeldent I) const (return Nodeldent;); bool operator == (const uwgknotenCS other) eonst
( return ( (Cau- seNr == other. CauseNr) S (Nodeldent == other . Nodeldent ) s(return ((CauseNr == other. CauseNr) S (Nodeldent == other. Nodeldent) s
(strcmplgattertext, other. gattertext) == 0) /*S (Gatterl- dent == other.Gatterldent)*/) ; ); bool Operator '= (const uwgknotenCS other) const(strcmplgattertext, other. gattertext) == 0) / * S (Gatterl- dent == other.Gatterldent) * /); ); bool operator '= (const uwgknotenCS other) const
( return ! (*thιs(return! (* thιs
== other) ; ); bool Operator < (const uwgknotenCS other) const ( return (Gatterldent < other.Gatterldent); ); bool Operator > (const uwgknotenCS other) const ( return (Gatterldent > other.Gatterldent); }; friend ostreamS Operator « ( ostreamS os, const uwgknotenCS Node);== other); ); bool Operator <(const uwgknotenCS other) const (return (Gatterldent <other.Gatterldent);); bool operator> (const uwgknotenCS other) const (return (Gatterldent>other.Gatterldent);}; friend ostreamS Operator «(ostreamS os, const uwgknotenCS Node);
»endif»Endif
»include "AS_GraphKante.h"»Include" AS_GraphKante.h "
DD
»include <ιostream> ostreamS Operator « ( ostreamS os, const GraphKanteC S Kante)) os « Kante. KantenTyp; return os; }"Include <ιostream> ostreamS Operator" (ostreamS os, const GraphKanteC S edge)) os "edge. Edge type; return os; }
»include "AS_GraphNode.h"»Include" AS_GraphNode.h "
DD
»include <ιostream>»Include <ιostream>
00
D ostreamS Operator « ( ostreamS os, const GraphNodeCS Node)( 0 os « endl « Node.NodeNr; return os;D ostreamS Operator «(ostreamS os, const GraphNodeCS Node) (0 os« endl «Node.NodeNr; return os;
}}
»include "AS Slice. h" D»Include" AS Slice. H "D
»include <ιostream>»Include <ιostream>
00
»include <ιterator>»Include <ιterator>
0 »include <algoπthm>0 »include <algoπthm>
DD
»include "uwggraph.h"»Include" uwggraph.h "
D o using namespace std; DDo using namespace std; D
DD
DD
IIFO : Funktion zur Auswahl der Variable, für die ein Fehlerbaum erstellt werden soll. DIIFO: Function for selecting the variable for which an error tree is to be created. D
// Zurückgegeben wird em Zeiger auf den ausgewählten Knoten. KFGListC: : iterator SliceC: :defιneVarιableToSlιce (KFGListC S L2 ) ( int Number = 0;// A pointer to the selected node is returned. KFGListC:: iterator SliceC:: defιneVarιableToSlιce (KFGListC S L2) (int Number = 0;
KFGListC: : iterator KFGI = L2.begin(); KFGListC: : iterator VARDEFI = L2.begιn(); KFGUseListC: : iterator USEIT; while ( KFGI != L2.end()) (KFGListC:: iterator KFGI = L2.begin (); KFGListC:: iterator VARDEFI = L2.begιn (); KFGUseListC:: iterator USEIT; while (KFGI! = L2.end ()) (
USEIT = KFGI->Uses.begιn(); if ( KFGI->getKFGNodeType ( ) == OP ) ( cout « KFGI->getKnotenNummer ( ) « ": " « USEIT->getUse( ) « endl ; ; )USEIT = KFGI-> Uses.begιn (); if (KFGI-> getKFGNodeType () == OP) (cout «KFGI-> getKnotNumber ()« ":" «USEIT-> getUse ()« endl;;)
KFGI++; } cout « "Geben Sie die Knotennummer em und drücken Sie RETURN: "; cm » Number; while ( KFGI '= L2.begιn()) ( if (KFGI->getKnotenNummer ( ) == Number) (KFGI ++; } cout «" Enter the node number em and press RETURN: "; cm »Number; while (KFGI '= L2.begιn ()) (if (KFGI-> getKnotenNummer () == Number) (
VARDEFI = KFGI, } KFGI--; if (VARDEFI->getKFGNodeType() == OP) ( cout « "Ausgewählt wurde Knoten Nr.: " « VARDEFI->getKnotenNummer ( ) « endl ; return VARDEFI; eiseVARDEFI = KFGI,} KFGI--; if (VARDEFI-> getKFGNodeType () == OP) (cout «" Node No .: "« VARDEFI-> getKnotNumber () «was selected endl; return VARDEFI; ice
VARDEFI = L2.beginl); eout « "Dieser Knoten ist kein Ausgabeknoten, das Programm wird beendet."VARDEFI = L2.beginl); eout «" This node is not an output node, the program is terminated. "
« endl; exιt(l); return VARDEFI; )«Final; exιt (l); return VARDEFI; )
//Fl: Sucht P-Use Knoten, fügt ihn dem Slice hinzu und zieht eine KFK. // input: Iterator auf den C-Use oder D-Use, KFG-Liste; void SliceC: :slιceForLoops (KFGListC S L2, KFGListC: : iterator LOOPIT) ( int HLevel; int check = 0; int KnotenNummer = 0; KFGListC: : iterator HELPIT = LOOPIT; while ( ( LOOPIT->getKFGNodeType ( ) != LC SS LOOPIT->getKFGNodeType ( ) != IFC) ||// Fl: Find P-Use node, add it to the slice and pull a KFK. // input: iterator on the C-Use or D-Use, KFG list; void SliceC:: slιceForLoops (KFGListC S L2, KFGListC:: iterator LOOPIT) (int HLevel; int check = 0; int node number = 0; KFGListC:: iterator HELPIT = LOOPIT; while ((LOOPIT-> getKFGNodeType ()! = LC SS LOOPIT-> getKFGNodeType ()! = IFC) ||
(LOOPIT->getLevel( ) != HELPIT->getLevel ( ) ) ) { LOOPIT—;(LOOPIT-> getLevel ()! = HELPIT-> getLevel ())) {LOOPIT—;
}}
KnotenNummer = LOOPIT->getNodeNr ( ) ; check = checkForNodes (KnotenNummer ) ;NodeNumber = LOOPIT-> getNodeNr (); check = checkForNodes (node number);
//insert (*LOOPIT,*HELPIT, KFK); insert («HELPIT, *LOOPIT, KFK); //umgekehrte Richtung der Kante, damit ]eder Knoten seine Vorgänger kennt.// insert (* LOOPIT, * HELPIT, KFK); insert («HELPIT, * LOOPIT, KFK); // reverse direction of the edge so that each node knows its predecessors.
//cout « "eingefügterKnotenFla: " « LOOPIT->getNodeNr ( ) « endl; //cout « "eingefügterKnotenFla: " « HELPIT->getNodeNr ( ) « endl « endl; if (check == 0) { fιndAHDefs ( L2 , LOOPIT ) ;// cout «" insertedNodeFla: "« LOOPIT-> getNodeNr () «endl; // cout «" insertedNodeFla: "« HELPIT-> getNodeNr () «endl« endl; if (check == 0) {fιndAHDefs (L2, LOOPIT);
}}
HLevel = LOOPIT->getLevel ( ) ; while (LOOPIT->getLevel() > 2) ( check = 0;HLevel = LOOPIT-> getLevel (); while (LOOPIT-> getLevel ()> 2) (check = 0;
HELPIT = LOOPIT; whil e ( ( LOOPIT->getKFGNodeType ( ) ' = LC S S LOOPIT->getKFGNodeType ( ) ' = IFC ) I I ( LOOPIT->getLevel ( ) >= HELPIT->getLevel ( ) ) ) ( LOOPIT—;HELPIT = LOOPIT; whil e ((LOOPIT-> getKFGNodeType () '= LC S S LOOPIT-> getKFGNodeType ()' = IFC) I I (LOOPIT-> getLevel ()> = HELPIT-> getLevel ())) (LOOPIT—;
}}
KnotenNummer = LOOPIT->getNodeNr ( ) ; check = checkForNodes (KnotenNummer) ;NodeNumber = LOOPIT-> getNodeNr (); check = checkForNodes (node number);
//insert (*LOOPIT, *HELPIT,KFK) ; insert (»HELPIT, »LOOPIT, KFK) ; //umgekehrte Richtung der Kante, damit 3eder// insert (* LOOPIT, * HELPIT, KFK); insert ( » HELPIT, » LOOPIT, KFK); // reverse direction of the edge, so 3 eder
Knoten seine Vorgänger kennt.Knot knows its predecessor.
//cout « "eingefügterKnotenFlb: " « LOOPIT->getNodeNr ( ) « endl;// cout «" insertedNodeFlb: "« LOOPIT-> getNodeNr () «endl;
//cout « "eingefügterKnotenFlb: " « HELPIT->getNodeNr ( ) « endl « endl; if (check == 0) ( fmdAHDefs(L2, LOOPIT);// cout «" insertedNodeFlb: "« HELPIT-> getNodeNr () «endl« endl; if (check == 0) (fmdAHDefs (L2, LOOPIT);
}}
HLevel = LOOPIT->getLevel ( ) ;HLevel = LOOPIT-> getLevel ();
//F2: Sucht alle D-Uses zu einem P-Use, fügt diese dem Slice hinzu und zieht DFK. // input: Iterator auf den Knoten mit der P-Use Liste, KFG-Liste; void SliceC: : findAHDefs (KFGListC S Ll, KFGListC: : iterator ITER) { int AktLevel; int dummylf = 0; int KnotenNummerEnde = 0; AktLevel = ITER->getLevel ( ) ; KFGListC: : iterator HELPIT = ITER; KFGListC: : iterator HELPIF = ITER;// F2: Find all D-Uses for a P-Use, add them to the slice and pull DFK. // input: iterator on the node with the P-use list, KFG list; void SliceC:: findAHDefs (KFGListC S Ll, KFGListC:: iterator ITER) {int AktLevel; int dummylf = 0; int NodeNumberEnd = 0; AktLevel = ITER-> getLevel (); KFGListC:: iterator HELPIT = ITER; KFGListC:: iterator HELPIF = ITER;
KFGListC: : iterator HELPLOOP = ITER; KFGListC: : iterator UPPERLIMIT = ITER; KFGPJJseListC: : iterator PUSEIT; PUSEIT = ITER->P_Uses.begιn( ); KFGDefListC: : iterator DEFIT1; if (ITER->getKFGNodeType() == LC) < while ( (HELPLOOP->getKFGNodeType( ) >= EL) || (HELPLOOP->getLevel { ) != Akt- Level ) ) {KFGListC:: iterator HELPLOOP = ITER; KFGListC:: iterator UPPERLIMIT = ITER; KFGPJJseListC:: iterator PUSEIT; PUSEIT = ITER-> P_Uses.begιn (); KFGDefListC:: iterator DEFIT1; if (ITER-> getKFGNodeType () == LC) <while ((HELPLOOP-> getKFGNodeType ()> = EL) || (HELPLOOP-> getLevel {)! = Akt- Level)) {
HELPLOOP++; }HELPLOOP ++; }
HELPIT = HELPLOOP;HELPIT = HELPLOOP;
KnotenNummerEnde = HELPLOOP->getNodeNr ( ) ; while (PUSEIT '= ITER->P_Uses.end( ) ) (NodeNumberEnd = HELPLOOP-> getNodeNr (); while (PUSEIT '= ITER-> P_Uses.end ()) (
UPPERLIMIT = fmdUpperLimit (Ll, ITER, PUSEIT); HELPLOOP = fιndLowerLιmit(Ll, ITER, UPPERLIMIT); //insert (»UPPERLIMIT, *ITER, DFK) ; insert (»ITER, »UPPERLIMIT, DFK) ; //umgekehrte Richtung der Kante, damit 3ederUPPERLIMIT = fmdUpperLimit (Ll, ITER, PUSEIT); HELPLOOP = fιndLowerLιmit (Ll, ITER, UPPERLIMIT); // insert ( » UPPERLIMIT, * ITER, DFK); insert ( » ITER, » UPPERLIMIT, DFK); // reverse direction of the edge, so 3 eder
Knoten seine Vorgänger kennt.Knot knows its predecessor.
//cout « "eιngefügterKnotenF2a: " « UPPERLIMIT->getNodeNr ( ) « endl; //cout « "eιngefügterKnotenF2a: " « ITER->getNodeNr ( ) « endl; while (HELPLOOP ι= UPPERLIMIT) ( HELPLOOP--; if (HELPLOOP->getKFGNodeType( ) — EE1 ) { dummylf = 1; } if ( (HELPLOOP->getKFGNodeType( ) == ETh) SS (HELPLOOP->getLevel I ) < ITER->getLevel I ) ) SS Idummylf == 0)) (// cout «" added nodeF2a: "« UPPERLIMIT-> getNodeNr () «endl; // cout «" added node F2a: "« ITER-> getNodeNr () «endl; while (HELPLOOP ι = UPPERLIMIT) (HELPLOOP--; if (HELPLOOP-> getKFGNodeType () - EE1) {dummylf = 1;} if ((HELPLOOP-> getKFGNodeType () == ETh) SS (HELPLOOP-> getLevel I) <ITER-> getLevel I)) SS Idummylf == 0)) (
HELPIF = HELPLOOP; while ( (HELPLOOP->getKFGNodeType() != IFC) || (HELPLOOP- >getLevel() '= HELPIF->getLevel ( ) ) ) (HELPIF = HELPLOOP; while ((HELPLOOP-> getKFGNodeType ()! = IFC) || (HELPLOOP-> getLevel () '= HELPIF-> getLevel ())) (
HELPLOOP--; } dummylf = 0; } if (HELPLOOP->getKFGNodeType( ) == NO) ( DEFIT1 = HELPLOOP->Defs.begιn(); while (DEFIT1 '= HELPLOOP->Defs.end ( ) ) { if (strcmp(PUSEIT->getUse( ) , DEFITl->getDef ( ) ) == 0) ( //insert ( »HELPLOOP, *ITER, DFK) ; msert(*ITER,*HELPLOOP,DFK); //umgekehrte Richtung der Kante, damit jeder Knoten seine Vorgänger kennt. defInLoopILl, HELPLOOP);HELPLOOP--; } dummylf = 0; } if (HELPLOOP-> getKFGNodeType () == NO) (DEFIT1 = HELPLOOP-> Defs.begιn (); while (DEFIT1 '= HELPLOOP-> Defs.end ()) {if (strcmp (PUSEIT-> getUse () , DEFITl-> getDef ()) == 0) (// insert ( » HELPLOOP, * ITER, DFK); msert (* ITER, * HELPLOOP, DFK); // reverse direction of the edge so that each node knows its predecessors . defInLoopILl, HELPLOOP);
//cout « "eιngefügterKnotenF2b: " « HELPLOOP- >getNodeNr() « endl;// cout «" added nodeF2b: "« HELPLOOP-> getNodeNr () «endl;
//cout « "eιngefügterKnotenF2b: " « ITER-// cout «" added nodeF2b: "« ITER-
>getNodeNr() « endl « endl; if CHEL JPPLLOOOOPP-->>UUsseess.. eemmppttyy II )) )) (( fmdDefToCUselLl, HELPLOOP);> getNodeNr () «endl« endl; if CHEL J PPLLOOOOPP - >> UUsseess .. eemmppttyy II)))) ((fmdDefToCUselLl, HELPLOOP);
} }}}
DEFIT1++;DEFIT1 ++;
}}
PUSEIT++; } KFKPUseToCUse (ITER, KnotenNummerEnde ) ;PUSEIT ++; } KFKPUseToCUse (ITER, node number end);
//F5: Funktion sucht den ersten def oberhalb eines p-uses oder c-uses und// F5: function searches for the first def above a p-use or c-uses and
// liefert einen Iterator auf diese obere Grenze bei der Suche aller defs // zurück.// returns an iterator to this upper limit when searching all defs //.
KFGListC: : iterator SliceC: : findUpperLimit (KFGListC S Ll, KFGListC: : iterator ITER, KFGP_UseLιstC: : iterator PUSEIT) ( int dummy = 0; mt dummyl = 0; mt dummylf = 0; int AktLevel = 0;KFGListC:: iterator SliceC:: findUpperLimit (KFGListC S Ll, KFGListC:: iterator ITER, KFGP_UseLιstC:: iterator PUSEIT) (int dummy = 0; mt dummyl = 0; mt dummylf = 0; int AktLevel = 0;
KFGListC:: iterator HELPDEF = ITER; KFGListC:: iterator HELPLOOP = ITER;KFGListC :: iterator HELPDEF = ITER; KFGListC :: iterator HELPLOOP = ITER;
KFGListC:: iterator HELPIF = ITER; KFGListC:: iterator HELPIT = ITER; KFGListC:: iterator HELPDEFRETURN = ITER; KFGDefListC: : iterator DEFIT; AktLevel = ITER->getLevel ( ) ;KFGListC :: iterator HELPIF = ITER; KFGListC :: iterator HELPIT = ITER; KFGListC :: iterator HELPDEFRETURN = ITER; KFGDefListC:: iterator DEFIT; AktLevel = ITER-> getLevel ();
//finden des ersten defs oberhalb des p-use. while ((HELPDEF != Ll.beginO) SS (dummy '= 1)) ( HELPDEF--; if (HELPLOOP->getKFGNodeType( ) == EE1) ( dummyl f = 1 ;// find the first defs above the p-use. while ((HELPDEF! = Ll.beginO) SS (dummy '= 1)) (HELPDEF--; if (HELPLOOP-> getKFGNodeType () == EE1) (dummyl f = 1;
) if I (HELPDEF->getKFGNodeType( ) == ETh) S (HELPDEF->getLevel ( ) < ITER- >getLevel()) SS (dummylf == 0)) () if I (HELPDEF-> getKFGNodeType () == ETh) S (HELPDEF-> getLevel () <ITER-> getLevel ()) SS (dummylf == 0)) (
HELPIF = HELPDEF; while ( (HELPDEF->getKFGNodeType( ) '= IFC) II (HELPDEF->getLevel ( ) ' =HELPIF = HELPDEF; while ((HELPDEF-> getKFGNodeType () '= IFC) II (HELPDEF-> getLevel ()' =
HELPIF->getLevel( ) ) ) (HELPIF-> getLevel ())) (
HELPDEF—; dummylf = 0;HELPDEF—; dummylf = 0;
} if (HELPDEF->getKFGNodeType( ) == NO) ( DEFIT = HELPDEF->Defs.begιn(); if (strcmp(DEFIT->getDef ( ) , PUSEIT->getUse ( ) ) == 0) (} if (HELPDEF-> getKFGNodeType () == NO) (DEFIT = HELPDEF-> Defs.begιn (); if (strcmp (DEFIT-> getDef (), PUSEIT-> getUse ()) == 0) (
HELPDEFRETURN = HELPDEF; dummy = 1; ) } } if ((HELPDEF == Ll.begmO) SS (HELPDEF->getKFGNodeType ( ) == NO)) ( DEFIT = HELPDEF->Defs.begm(); if (strcmp(DEFIT->getDef ( ) , PUSEIT->getUse ( ) ) ~ 0) ( HELPDEFRETURN = HELPDEF; dummy = 1;HELPDEFRETURN = HELPDEF; dummy = 1; )}} if ((HELPDEF == Ll.begmO) SS (HELPDEF-> getKFGNodeType () == NO)) (DEFIT = HELPDEF-> Defs.begm (); if (strcmp (DEFIT-> getDef (), PUSEIT -> getUse ()) ~ 0) (HELPDEFRETURN = HELPDEF; dummy = 1;
} }}}
//finden der äußersten Schleife, falls diese überhaupt existiert, if (ITER->getLevel() > 2) ( while ((HELPIT '= Ll.endO) SS (dummyl '= 1)) {// find the outermost loop, if it exists at all, if (ITER-> getLevel ()> 2) (while ((HELPIT '= Ll.endO) SS (dummyl' = 1)) {
HELPIT++; if ( (HELPIT->getKFGNodeType( ) == EL) SS (HELPIT->getLevel ( ) < Akt- Level ) ) (HELPIT ++; if ((HELPIT-> getKFGNodeType () == EL) SS (HELPIT-> getLevel () <Akt- Level)) (
HELPLOOP = HELPIT; if (HELPIT->getLevel() > 2) (HELPLOOP = HELPIT; if (HELPIT-> getLevel ()> 2) (
AktLevel = HELPIT->getLevel ( ]AktLevel = HELPIT-> getLevel (]
} eise dummyl = 1; }} else dummyl = 1; }
) })}
HELPIT ■= HELPLOOP;HELPIT ■ = HELPLOOP;
//gehe zum Anfang der äußersten Schleife: while I (HELPIT->getKFGNodeType() '= LC) II (HELPIT->getLevel ( ) '= HELPLOOP-// go to the beginning of the outermost loop: while I (HELPIT-> getKFGNodeType () '= LC) II (HELPIT-> getLevel ()' = HELPLOOP-
>getLevel I ) ) ) (> getLevel I))) (
HELPIT—; )HELPIT—; )
//wenn der gefundene def-Koten außerhalb der äußersten Schleife liegt, und //sein ScopeLevel großer ist als das der äußersten Schleife, suche, ob es// if the def node found is outside the outermost loop and // its ScopeLevel is greater than that of the outermost loop, look for it
//noch einen weiteren def-Knoten weiter oben gibt, if (HELPDEF->getNodeNr( ) > HELPIT->getNodeNr ( ) ) ( if (HELPDEF->getLevel( ) >= HELPIT->getLevel ( ) ) ( dummy = 0; while ((HELPDEF '= Ll.begmO) SS (dummy '= 1)) (// there is another def node above, if (HELPDEF-> getNodeNr ()> HELPIT-> getNodeNr ()) (if (HELPDEF-> getLevel ()> = HELPIT-> getLevel ()) (dummy = 0 ; while ((HELPDEF '= Ll.begmO) SS (dummy' = 1)) (
HELPDEF—;HELPDEF—;
DEFIT = HELPDEF->Defs.begιn( ); if (strcmplDEFIT->getDe (),PUSEIT->getUse( ) ) == 0) ( HELPDEFRETURN = HELPDEF; dummy = 1;DEFIT = HELPDEF-> Defs.begιn (); if (strcmplDEFIT-> getDe (), PUSEIT-> getUse ()) == 0) (HELPDEFRETURN = HELPDEF; dummy = 1;
) ) } ) } return HELPDEFRETURN;))})} return HELPDEFRETURN;
//F6: Funktion sucht, abhängig vom oberen Ende, das untere Ende des Bereichs, indem // die defs gesucht werden müssen.// F6: Function searches, depending on the upper end, the lower end of the range by // looking for the defs.
// Zurückgeliefert wird ein Iterator auf die untere Grenze.// An iterator is returned to the lower limit.
KFGListC: : iterator SliceC: : findLowerLimit (KFGListC S Ll, KFGListC: : iterator ITER, KFGListC: :ιterator UPPERLIMIT) ( int dummyl = 0; int AktLevel « 0;KFGListC:: iterator SliceC:: findLowerLimit (KFGListC S Ll, KFGListC:: iterator ITER, KFGListC:: ιterator UPPERLIMIT) (int dummyl = 0; int AktLevel «0;
KFGListC: : iterator HELPIT = ITER; KFGListC: : iterator HELPLOOP = ITER; KFGListC: : iterator LOWERLIMIT = ITER;KFGListC:: iterator HELPIT = ITER; KFGListC:: iterator HELPLOOP = ITER; KFGListC:: iterator LOWERLIMIT = ITER;
AktLevel = ITER->getLevel I ) ; if (ITER->getKFGNodeType( ) == LC) ( while ( (HELPLOOP->getKFGNodeType( ) >= EL) || (HELPLOOP->getLevel ( ) ^ Akt- Level)) ( HELPLOOP++;AktLevel = ITER-> getLevel I); if (ITER-> getKFGNodeType () == LC) (while ((HELPLOOP-> getKFGNodeType ()> = EL) || (HELPLOOP-> getLevel () ^ Akt- Level)) (HELPLOOP ++;
} } //finden des Endes der äußersten Schleife. if (ITER->getLevel() > 2) ( while I (HELPIT != Ll.end(l) SS (dummyl != 1)) ( HELPIT++; if ( (HELPIT->getKFGNodeType() == EL) SS (HELPIT->getLevel ( ) < Akt- Level)) {}} // find the end of the outermost loop. if (ITER-> getLevel ()> 2) (while I (HELPIT! = Ll.end (l) SS (dummyl! = 1)) (HELPIT ++; if ((HELPIT-> getKFGNodeType () == EL) SS ( HELPIT-> getLevel () <Akt- Level)) {
HELPLOOP = HELPIT; if (HELPIT->getLevel() > 2) (HELPLOOP = HELPIT; if (HELPIT-> getLevel ()> 2) (
AktLevel = HELPIT->getLevel ( ) ; ) eise < dummyl = 1; } } } HELPIT = HELPLOOP; //HELPLOOP zeigt auf das Ende der äußersten Schleife, ansonsten auf den p-use. while ( (HELPIT->getKFGNodeType() >= LC) || (HELPIT->getLevel ( ) != HELPLOOP- >getLevel ( ) ) ) (AktLevel = HELPIT-> getLevel (); ) ice <dummyl = 1; }}} HELPIT = HELPLOOP; // HELPLOOP points to the end of the outermost loop, otherwise to the p-use. while ((HELPIT-> getKFGNodeType ()> = LC) || (HELPIT-> getLevel ()! = HELPLOOP-> getLevel ())) (
HELPIT—; } //HELPIT zeigt auf denHELPIT—; } // HELPIT points to the
Anfang der äußersten Schleife. if (HELPIT->getNodeNr() < UPPERLIMIT->getNodeNr ( ) ) (Beginning of the outermost loop. if (HELPIT-> getNodeNr () <UPPERLIMIT-> getNodeNr ()) (
LOWERLIMIT = HELPLOOP; //falls die obere Grenze außerhalb der Schlei- fen liegt. eiseLOWERLIMIT = HELPLOOP; // if the upper limit is outside the loops. else
AktLevel = UPPERLIMIT->getLevel ( ) ; while | (HELPLOOP->getKFGNodeType() ι= EL) II (HELPLOOP->getLevel ( ) <=AktLevel = UPPERLIMIT-> getLevel (); while | (HELPLOOP-> getKFGNodeType () ι = EL) II (HELPLOOP-> getLevel () <=
AktLevel ) ) ( HELPLOOP—;AktLevel)) (HELPLOOP—;
LOWERLIMIT = HELPLOOP; //falls die obere Grenze innerhalb der Schleife liegt. eise (LOWERLIMIT = HELPLOOP; // if the upper limit is within the loop. ice (
LOWERLIMIT = HELPLOOP; } return LOWERLIMIT;LOWERLIMIT = HELPLOOP; } return LOWERLIMIT;
//F3: Funktion zieht eine KFK vom P-Use zu allen C-Uses, die sich in derselben // Schleifen- bzw. Verzweigungsebene befinden. // input: Iterator auf P-Use Knoten. void SliceC: :KFKPUseToCUse (KFGListC: : iterator PUSEIT, t SchielfenEnde) ( SliceC: : iterator SLl = begιn(); SliceC: : iterator SLHELP = beginl); KFGListC:: iterator ITER = PUSEIT;// F3: Function pulls a KFK from P-Use to all C-Uses that are in the same // loop or branching level. // input: iterator on P-Use node. void SliceC:: KFKPUseToCUse (KFGListC:: iterator PUSEIT, t SchielfenEnde) (SliceC:: iterator SLl = begιn (); SliceC:: iterator SLHELP = beginl); KFGListC :: iterator ITER = PUSEIT;
KFGUseLiεtC: : iterator USEIT; KFGPJJseListC: : iterator PUSEIT2; KFGUseListC:: iterator CUSEIT2; int KnotenLevel; int KnotenNummer;KFGUseLiεtC:: iterator USEIT; KFGPJJseListC:: iterator PUSEIT2; KFGUseListC :: iterator CUSEIT2; int node level; int node number;
KnotenNummer = PUSEIT->getNodeNr ( ) ; KnotenLevel = PUSEIT->getLevel ( ) ; while I (*SL1) . first. getNodeNr ( ) != KnotenNummer) SL1++; SLHELP - SLl;NodeNumber = PUSEIT-> getNodeNr (); NodeLevel = PUSEIT-> getLevel (); while I (* SL1). first. getNodeNr ()! = node number) SL1 ++; SLHELP - SLl;
SLl - begin ( ) ; while (SLl '= end() ) { if ((KnotenNummer > (*SL1 ). first. getNodeNr () ) SS (SchleifenEnde < (*SL1) .first. getNodeNr!) ) ) ( if (( (*SL1) .first. getKFGNodeType! ) == NO) SS ( (*SL1 ). first. getLevel ( )SLl - begin (); while (SLl '= end ()) {if ((node number> (* SL1). first. getNodeNr ()) SS (loop end <(* SL1) .first. getNodeNr!))) (if (((* SL1) .first. getKFGNodeType!) == NO) SS ((* SL1). first. getLevel ()
== KnotenLevel ) ) (== node level)) (
//insert ( («SLHELP) .first, (*SL1) .first, KFK) ; insert ! ( *SL1 ) . first, ( *SLHELP) . first, KFK) ; //umgekehrte Richtung der Kante, damit j eder Knoten seine Vorgänger kennt . //cout « "emgefügterKnotenF3 : " «// insert (( « SLHELP) .first, (* SL1) .first, KFK); insert! (* SL1). first, (* SLHELP). first, KFK); // reverse direction of the edge so that each node knows its predecessors. // cout «" addednodeF3: "«
( *SL1 ) . first . getNodeNr ! ) « endl ;(* SL1). first. getNodeNr! ) «Endl;
//cout « "eιngefügterKnotenF3 : " « ( *SLHELP ) . first . getNodeNr ! ) « endl ; , '// cout «" added node F3: "« (* SLHELP). first. getNodeNr! ) «Endl; , '
SL1++;SL1 ++;
) } //F4: Funktion sucht, wenn der Knoten neben den defs noch c-uses enthält, zu diesen // c-uses alle defs und zieht DFK vom gefundenem def zum c-use. void SliceC: : indDefToCUse (KFGListC S Ll, KFGListC: : iterator ITER) { t HLevel; mt check = 0; t dummy = 0; int dummylf = 0; int KnotenNummer = 0;)} // F4: seeking function when the node next to the defs not c-uses including to this / / c-uses all defs and pulls DFK from the found def for c-use. void SliceC:: indDefToCUse (KFGListC S Ll, KFGListC:: iterator ITER) {t HLevel; mt check = 0; t dummy = 0; int dummylf = 0; int node number = 0;
KFGListC: : iterator HELPIT «= ITER; KFGListC: : Iterator HELPLOOP = ITER; KFGListC: : iterator HELPIF = ITER; KFGListC: : iterator LOWERLIMIT = ITER; KFGListC: : iterator UPPERLIMIT = ITER;KFGListC:: iterator HELPIT «= ITER; KFGListC:: iterator HELPLOOP = ITER; KFGListC:: iterator HELPIF = ITER; KFGListC:: iterator LOWERLIMIT = ITER; KFGListC:: iterator UPPERLIMIT = ITER;
KFGDefListC: : iterator DEFIT1; KFGUseListC: : iterator USEIT1; USEIT1 = ITER->Uses.begin(); HLevel = ITER->getLevel ( ) ; while (USEIT1 != ITER->Uses.end ( ) ) (KFGDefListC:: iterator DEFIT1; KFGUseListC:: iterator USEIT1; USEIT1 = ITER-> Uses.begin (); HLevel = ITER-> getLevel (); while (USEIT1! = ITER-> Uses.end ()) (
UPPERLIMIT = findUpperLimitFromCUse (Ll, ITER, USEIT1 ) ; HELPIT - findLowerLimitFromCUse (Ll, ITER, UPPERLIMIT); UPPERLIMIT—;UPPERLIMIT = findUpperLimitFromCUse (Ll, ITER, USEIT1); HELPIT - findLowerLimitFromCUse (Ll, ITER, UPPERLIMIT); UPPERLIMIT—;
//cout « "eιngefügterKnotenF4a: " « UPPERLIMIT->getNodeNr ( ) « endl; //cout « "eιngefügterKnotenF4a: " « ITER->getNodeNr ( ) « endl; while (HELPIT != UPPERLIMIT) ( if (HELPLOOP->getKFGNodeType() == EE1) ( dummylf = 1; } lf ( (HELPIT->getKFGNodeType( ) == ETh) SS (HELPIT->getLevel ( ) <= ITER-// cout «" added node F4a: "« UPPERLIMIT-> getNodeNr () «endl; // cout «" added node F4a: "« ITER-> getNodeNr () «endl; while (HELPIT! = UPPERLIMIT) (if (HELPLOOP-> getKFGNodeType () == EE1) (dummylf = 1;} lf ((HELPIT-> getKFGNodeType () == ETh) SS (HELPIT-> getLevel () <= ITER -
>getLevel()) SS (dummylf == 0)) (> getLevel ()) SS (dummylf == 0)) (
HELPIF = HELPIT; while ( (HELPIT->getKFGNodeType() '= IFC) II (HELPIT- >getLevel() != HELPIF->getLevel ( ) ) ) ( HELPIT—;HELPIF = HELPIT; while ((HELPIT-> getKFGNodeType () '= IFC) II (HELPIT-> getLevel ()! = HELPIF-> getLevel ())) (HELPIT—;
) dummylf » 0;) dummylf »0;
} lf (HELPIT->getKFGNodeType( ) == NO) ( DEFIT1 = HELPIT->Defs.beginl ); lf (strcmp(DEFITl->getDef I ) ,USEITl->getUse ( ) ) == 0) ( lf (!HELPIT->Uses. emptyI) ) (} lf (HELPIT-> getKFGNodeType () == NO) (DEFIT1 = HELPIT-> Defs.beginl); lf (strcmp (DEFITl-> getDef I), USEITl-> getUse ()) == 0) (lf (! HELPIT-> Uses. emptyI)) (
KnotenNummer = HELPIT->getNodeNr I ) ; check = checkForNodes (KnotenNummer) ; }Node number = HELPIT-> getNodeNr I); check = checkForNodes (node number); }
//insert ( *HELPIT, *ITER, DFK) ; insert (»ITER, «HELPIT, DFK); //umgekehrte Richtung der Kante, damit jeder Knoten seine Vorgänger kennt. defInLoop ( Ll , HELPIT ) ; //cout « "emgefügterKnotenF4b: " « HELPIT-// insert (* HELPIT, * ITER, DFK); insert ( " ITER, " HELPIT, DFK); // reverse direction of the edge so that each node knows its predecessors. defInLoop (Ll, HELPIT); // cout «" addednodeF4b: "« HELPIT-
>getNodeNr() « endl;> getNodeNr () «endl;
//cout « "eingefügterKnotenF b: " « ITER- >getNodeNr() « endl « endl; if (check == 0) ( findDefToCUse |L1, HELPIT);// cout «" insertedNodeF b: "« ITER-> getNodeNr () «endl« endl; if (check == 0) (findDefToCUse | L1, HELPIT);
) } } HELPIT—; })}} HELPIT—; }
USEIT1++;USEIT1 ++;
}}
//F8: Funktion sucht die untere Grenze, von der an die defs zu einem c-use gesucht // werden dürfen.// F8: Function searches for the lower limit from which the defs can be searched for a c-use.
KFGListC: : iterator SliceC: : findLowerLimitFromCUse (KFGListC S Ll, KFGListC: : iterator ITER, KFGListC: :ιterator UPPERLIMIT) ( int HLevel; int dummy = 0;KFGListC:: iterator SliceC:: findLowerLimitFromCUse (KFGListC S Ll, KFGListC:: iterator ITER, KFGListC:: ιterator UPPERLIMIT) (int HLevel; int dummy = 0;
KFGListC:: iterator HELPIT = ITER; KFGListC:: iterator HELPLOOP = ITER; KFGListC: : iterator LOWERLIMIT = ITER;KFGListC :: iterator HELPIT = ITER; KFGListC :: iterator HELPLOOP = ITER; KFGListC:: iterator LOWERLIMIT = ITER;
KFGDefListC: : iterator DEFIT1; KFGUseListC: : iterator USEIT1; USEIT1 = ITER->Uses. beginl ) ; HLevel = ITER->getLevel ( ) ;KFGDefListC:: iterator DEFIT1; KFGUseListC:: iterator USEIT1; USEIT1 = ITER-> Uses. beginl); HLevel = ITER-> getLevel ();
/ /Ist der c-use Knoten in einer Schleife? if ( ITER->getLevel ( ) >= 2 ) ( while ((HELPIT != Ll.endO) SS (dummy !«= 1)) ( HELPIT++; if ( (HELPIT->getKFGNodeType() == EL) SS (HELPIT->getLevel ( ) <- HLevel)) {// Is the c-use node in a loop? if (ITER-> getLevel ()> = 2) (while ((HELPIT! = Ll.endO) SS (dummy! «= 1)) (HELPIT ++; if ((HELPIT-> getKFGNodeType () == EL) SS ( HELPIT-> getLevel () <- HLevel)) {
HELPLOOP = HELPIT; lf IHELPIT->getLevel( ) > 2) ( HLevel—; eise ( dummy = 1; ) } }HELPLOOP = HELPIT; lf IHELPIT-> getLevel ()> 2) (HLevel—; eise (dummy = 1;)}}
}}
//Der Iterator HELPLOOP zeigt jetzt auf das Ende der äußersten, den Knoten umgebenden //Schleife, falls es diese gibt, ansonsten zeigt der Iterator auf den c-use-Knoten selbst. lf (HELPLOOP '= ITER) {// The iterator HELPLOOP now points to the end of the outermost // loop surrounding the node, if there is one, otherwise the iterator points to the c-use node itself. L f (HELPLOOP '= ITER) {
HELPIT = HELPLOOP; //Iterator zeigt auf das Ende der äußerstenHELPIT = HELPLOOP; // iterator points to the end of the outermost
Schleife. while ( (HELPIT->getKFGNodeType() != LC) || (HELPIT->getLevel ( ) != HELPLOOP-Loop. while ((HELPIT-> getKFGNodeType ()! = LC) || (HELPIT-> getLevel ()! = HELPLOOP-
>getLevel ( ) ) ) (> getLevel ())) (
HELPIT—; } if (HELPIT->getNodeNr( ) < UPPERLIMIT->getNodeNr ( ) ) ( LOWERLIMIT = HELPLOOP; //obere Grenze außerhalb der äußersten Schleife;HELPIT—; } if (HELPIT-> getNodeNr () <UPPERLIMIT-> getNodeNr ()) (LOWERLIMIT = HELPLOOP; // upper limit outside the outermost loop;
} eise if (ITER->getLevel( ) == UPPERLIMIT->getLevel ( ) ) (} else if (ITER-> getLevel () == UPPERLIMIT-> getLevel ()) (
LOWERLIMIT = ITER; //obere Grenze mit dem c-use in dersel- ben Schleife;LOWERLIMIT = ITER; // upper limit with the c-use in the same loop;
) eise lf (ITER->getLevel( ) < UPPERLIMIT->getLevel ( ) ) () else lf (ITER-> getLevel () <UPPERLIMIT-> getLevel ()) (
LOWERLIMIT = HELPLOOP; //obere Grenze in derselben äußeren Schleife, aber } //innerhalb in einer anderen, vor dem c-use liegenden Schleife; eise (LOWERLIMIT = HELPLOOP; // upper limit in the same outer loop, but} // inside a different loop before the c-use; ice (
HLevel = UPPERLIMIT->getLevel ( ) ; while ( (HELPLOOP->getKFGNodeType( ) !- EL) II (HELPLOOP->getLevel ( ) <= HLevel)) (HLevel = UPPERLIMIT-> getLevel (); while ((HELPLOOP-> getKFGNodeType ()! - EL) II (HELPLOOP-> getLevel () <= HLevel)) (
HELPLOOP—; }HELPLOOP—; }
LOWERLIMIT = HELPLOOP; //obere Grenze in einer niedrigeren Schleife als der c-use; }LOWERLIMIT = HELPLOOP; // upper limit in a lower loop than the c-use; }
} eise {} ice {
LOWERLIMIT = ITER; //keine äußere Schleife vorhanden.LOWERLIMIT = ITER; // there is no outer loop.
} return LOWERLIMIT;} return LOWERLIMIT;
))
//F7: Funktion sucht die obere Grenze, bis zu der defs zu einem c-use gesucht werden // dürfen. Die Funktionsweise ist ähnlich entsprechenden Funktion für p-uses.// F7: Function searches for the upper limit up to which defs can be searched for a c-use //. The mode of operation is similar to the corresponding function for p-uses.
KFGListC: : iterator SliceC: : findUpperLimitFromCUse (KFGListC S Ll, KFGListC: : iterator ITERl, KFGUseListC:: iterator USEIT) ( int dummy = 0; t dummyl = 0; int dummylf = 0; int AktLevel = 0;KFGListC:: iterator SliceC:: findUpperLimitFromCUse (KFGListC S Ll, KFGListC:: iterator ITERl, KFGUseListC :: iterator USEIT) (int dummy = 0; t dummyl = 0; int dummylf = 0; int AktLevel = 0;
KFGListC: : iterator HELPDEF = ITERl; KFGListC: : iterator HELPLOOP = ITERl; KFGListC: : iterator HELPIT = ITERl; KFGListC: : iterator HELPIF = ITERl;KFGListC:: iterator HELPDEF = ITERl; KFGListC:: iterator HELPLOOP = ITERl; KFGListC:: iterator HELPIT = ITERl; KFGListC:: iterator HELPIF = ITERl;
KFGListC: : iterator HELPDEFRETURN = ITER1; KFGDefListC: : iterator DEFIT; AktLevel = ITERl->getLevel () ;KFGListC:: iterator HELPDEFRETURN = ITER1; KFGDefListC:: iterator DEFIT; AktLevel = ITERl-> getLevel ();
//cout « "bearbeitender Knoten: " « ITERl->getNodeNr ( ) « endl; //finden des ersten defs oberhalb des use. do ( lf (HELPLOOP->getKFGNodeType() -= EE1 ) ( dummylf = 1; } lf ( (HELPDEF->getKFGNodeType() == ETh) SS (HELPDEF->getLevel ( ) <= ITERl- >getLevel ( ) ) &S (dummylf == 0)) f// cout «" processing node: "« ITERl-> getNodeNr () «endl; // find the first defs above the use. do (lf (HELPLOOP-> getKFGNodeType () - = EE1) (dummylf = 1; } l f ((HELPDEF-> getKFGNodeType () == ETh) SS (HELPDEF-> getLevel () <= ITERl-> getLevel ()) & S (dummylf == 0)) f
HELPIF = HELPDEF; while ( (HELPDEF->getKFGNodeType() != IFC) II (HELPDEF->getLevel I ) !=HELPIF = HELPDEF; while ((HELPDEF-> getKFGNodeType ()! = IFC) II (HELPDEF-> getLevel I)! =
HELPIF->getLevel I ) ) ) {HELPIF-> getLevel I))) {
HELPDEF—; } dummylf = 0; l)f (HELPDEF->getKFGNodeType() -= NO) ( DEFIT = HELPDEF->Defs.beginl ); lf (strcmp(DEFIT->getDef ( ) ,USEIT->getUse I ) ) == 0) ( HELPDEFRETURN = HELPDEF; if (HELPDEF != ITERl) ( dummy = 1; } ) } HELPDEF—;HELPDEF—; } dummylf = 0; l ) f (HELPDEF-> getKFGNodeType () - = NO) (DEFIT = HELPDEF->Defs.beginl); lf (strcmp (DEFIT-> getDef (), USEIT-> getUse I)) == 0) (HELPDEFRETURN = HELPDEF; if (HELPDEF! = ITERl) (dummy = 1;})} HELPDEF—;
) while ((HELPDEF != Ll.begmO) SS (dummy != 1 ) ) ; if ( (HELPDEF == Ll.beginl ) ) SS (HELPDEF->getKFGNodeType ( ) == NO) ) ( DEFIT = HELPDEF->Defs.begin ( ) ; lf (stremp(DEFIT->getDef (),USEIT->getUse() ) == 0) { HELPDEFRETURN = HELPDEF;) while ((HELPDEF! = Ll.begmO) SS (dummy! = 1)); if ((HELPDEF == Ll.beginl)) SS (HELPDEF-> getKFGNodeType () == NO)) (DEFIT = HELPDEF-> Defs.begin (); l f (stremp (DEFIT-> getDef (), USEIT- > getUse ()) == 0) {HELPDEFRETURN = HELPDEF;
}}
}}
HELPDEF = HELPDEFRETURN;HELPDEF = HELPDEFRETURN;
//cout « "erster def: " « HELPDEFRETURN->getNodeNr ( ) « endl; //finden der äußersten Schleife, falls diese überhaupt existiert, if (ITERl->getLevel() >= 2) ( while ((HELPIT != Ll . end ( ) ) SS (dummyl != 1)) ( HELPIT++; lf ( (HELPIT->getKFGNodeType() == EL) SS (HELPIT->getLevel ( ) <= Akt- Level))// cout «" first def: "« HELPDEFRETURN-> getNodeNr () «endl; // find the outermost loop, if it exists at all, if (ITERl-> getLevel ()> = 2) (while ((HELPIT! = Ll. end ()) SS (dummyl! = 1)) (HELPIT ++; lf ( (HELPIT-> getKFGNodeType () == EL) SS (HELPIT-> getLevel () <= Akt-Level))
HELPLOOP = HELPIT; lf (HELPIT->getLevel( ) > 2) ( AktLevel—; eise { dummyl = 1; ) } ) HELPIT - HELPLOOP;HELPLOOP = HELPIT; lf (HELPIT-> getLevel ()> 2) (AktLevel—; eise {dummyl = 1;)}) HELPIT - HELPLOOP;
//cout « "Ende der äußersten Schleife: " « HELPIT->getNodeNr ( ) « endl; //gehe zum Anfang der äußersten Schleife, wenn es diese gibt; if (HELPLOOP->getKFGNodeType( ) == EL) { while ( (HELPIT->getKFGNodeType() != LC) || (HELPIT->getLevel ( ) != HELPLOOP->getLevel ( ) ) ) (// cout «" End of the outermost loop: "« HELPIT-> getNodeNr () «endl; // go to the beginning of the outermost loop, if there is one; if (HELPLOOP-> getKFGNodeType () == EL) {while ((HELPIT-> getKFGNodeType ()! = LC) || (HELPIT-> getLevel ()! = HELPLOOP-> getLevel ())) (
HELPIT—; )HELPIT—; )
//cout « "Anfang der äußeren Schleife: " « HELPIT->getNodeNr ( ) « endl; //wenn der gefundene def-Koten außerhalb der äußersten Schleife liegt, und// cout «" Start of the outer loop: "« HELPIT-> getNodeNr () «endl; // if the def node found is outside the outermost loop, and
//sein ScopeLevel größer ist als das der äußersten Schleife, suche. ob es// its scope level is greater than that of the outermost loop, search. whether it
//noch einen weiteren def-Knoten weiter oben gibt. lf (HELPDEF->getNodeNr() > HELPIT->getNodeNr I ) ) ( lf (HELPDEF->getLevel( 1 >= HELPIT->getLevel ( ) ) ( dummy = 0; while ((HELPDEF != Ll.begmO) SS (dummy != 1)) ( HELPDEF—; DEFIT = HELPDEF->Defs.begιn(); if (strcmp(DEFIT->getDe () ,USEIT->getUse ( ) )// there is another def node above. lf (HELPDEF-> getNodeNr ()> HELPIT-> getNodeNr I)) (lf (HELPDEF-> getLevel (1> = HELPIT-> getLevel ()) (dummy = 0; while ((HELPDEF! = Ll.begmO) SS (dummy! = 1)) (HELPDEF—; DEFIT = HELPDEF-> Defs.begιn (); if (strcmp (DEFIT-> getDe (), USEIT-> getUse ())
0)0)
HELPDEFRETURN = HELPDEF; dummy = 1;HELPDEFRETURN = HELPDEF; dummy = 1;
//c-use innerhalb der äußersten Schleife; eise ( if (HELPDEF->getLevel( ) > ITERl->getLevel ( ) ) ( dummy = 0; while IHELPDEF >= HELPIT) ( HELPDEF—;// c-use within the outermost loop; else (if (HELPDEF-> getLevel ()>ITERl-> getLevel ()) (dummy = 0; while IHELPDEF> = HELPIT) ( HELPDEF—;
DEFIT = HELPDEF->Def s . egin l ) ; l f | strcmp ( DEFIT->getDef ( ) , USEIT->getUse ( ) ]DEFIT = HELPDEF-> Def s. egin l); l f | strcmp (DEFIT-> getDef (), USEIT-> getUse ()]
0 ) <0) <
HELPDEFRETURN = HELPDEF;HELPDEFRETURN = HELPDEF;
} } )}})
//c-use in keiner Schleife, aber in einer Verzweigung; eise ( lf (HELPDEF->getLevel|) > ITERl->getLevel () ) ( dummy = 0; while ((HELPDEF '= Ll.beginO) SS (dummy '= 1)) {// c-use in no loop, but in a branch; else (lf (HELPDEF-> getLevel |)> ITERl-> getLevel ()) (dummy = 0; while ((HELPDEF '= Ll.beginO) SS (dummy' = 1)) {
HELPDEF—;HELPDEF—;
DEFIT = HELPDEF->Defs.beginl ); lf (strcmp(DEFIT->getDef () ,USEIT->getUse( ) ) == 0) { HELPDEFRETURN = HELPDEF; dummy = 1;DEFIT = HELPDEF-> Defs.beginl); lf (strcmp (DEFIT-> getDef (), USEIT-> getUse ()) == 0) {HELPDEFRETURN = HELPDEF; dummy = 1;
}}
) })}
//c-use in keiner Schleife; eise ( lf (HELPDEF->getLevel( ) > ITERl->getLevel () ) ( dummy = 0; while ((HELPDEF '= Ll.begmO) SS (dummy '= 1)) (// c-use in no loop; else (lf (HELPDEF-> getLevel ()> ITERl-> getLevel ()) (dummy = 0; while ((HELPDEF '= Ll.begmO) SS (dummy' = 1)) (
HELPDEF—;HELPDEF—;
DEFIT = HELPDEF->Defs.beginl ); if (strcmp(DEFIT->getDef ( ) ,UΞEIT->getUse ( ) ) == 0) ( HELPDEFRETURN = HELPDEF; dummy = 1;DEFIT = HELPDEF-> Defs.beginl); if (strcmp (DEFIT-> getDef (), UΞEIT-> getUse ()) == 0) (HELPDEFRETURN = HELPDEF; dummy = 1;
) } } //cout « "UpperLimitFunktion: " « HELPDEFRETURN->getNodeNr ( ) « endl; return HELPDEFRETURN;)}} // cout «" UpperLimitFunction: "« HELPDEFRETURN-> getNodeNr () «endl; return HELPDEFRETURN;
//F9: Funktion überprüft, ob ein Knoten bereits im Slice vorhanden ist. Wenn ja, // wird eine eins zurückgeliefert, andernfalls eine null. // input: Knotennummer des gesuchten Knotens; // Output: Integerwert 0 oder 1; int SliceC: : checkForNodes (int NodeNumber) ( mt dummy = 0;// F9: Function checks whether a node already exists in the slice. If so, // a one is returned, otherwise a zero. // input: node number of the searched node; // Output: Integer 0 or 1; int SliceC:: checkForNodes (int NodeNumber) (mt dummy = 0;
SliceC: : iterator SLl = beginl); while ((SLl '= end()) SS (dummy '= 1)) ( lf ( (*SL1) .first. getNodeNrO == NodeNumber) ( dummy = 1;SliceC:: iterator SLl = beginl); while ((SLl '= end ()) SS (dummy' = 1)) (lf ((* SL1) .first. getNodeNrO == NodeNumber) (dummy = 1;
SL1++;SL1 ++;
) lf (dummy == 1 ) ( return 1; } eise ( return 0; }) lf (dummy == 1) (return 1;} ice (return 0;}
//FlO: Funktion untersucht, ob em def in einer Schleife ist; wenn ja, wird die // Funktion Fl, die den p-use sucht, aufgerufen. Dort wird als erstes nach- // gesehen, ob der gefundene p-use bereits im Slice vorhanden ist. void SliceC: :defInLoop (KFGListC S Ll, KFGListC: : iterator ITER) ( int dummyLoop = 0; KFGListC:: iterator HELPIT = ITER; while ((HELPIT '= Ll.beginO) SS (dummyLoop '= 1)) { HELPIT—; lf ( ( (HELPIT->getKFGNodeType() == LC) II (HELPIT->getKFGNodeType ( ) == IFC)) SS (HELPIT->getLevel() == ITER->getLevel ( ) ) ) ( sliceForLoops (Ll, ITER) ; dummyLoop = 1;// FlO: function examines whether em def is in a loop; if so, the // function Fl, which is looking for the p-use, is called. The first thing to do there is // to see whether the p-use found is already present in the slice. void SliceC:: defInLoop (KFGListC S Ll, KFGListC:: iterator ITER) (int dummyLoop = 0; KFGListC :: iterator HELPIT = ITER; while ((HELPIT '= Ll.beginO) SS (dummyLoop' = 1)) {HELPIT -; lf (((HELPIT-> getKFGNodeType () == LC) II (HELPIT-> getKFGNodeType () == IFC)) SS (HELPIT-> getLevel () == ITER-> getLevel ())) (sliceForLoops ( Ll, ITER); dummyLoop = 1;
//Fll: Funktion bekommt den ausgewählten Startknoten für den Slice übermmittelt, // untersucht, ob dieser Knoten in einer Schleife ist; wenn ja, wird zuerst // die Funktion "sliceForLoops" aufgerufen, ansonsten sofort "findDefToCUse"'. void SliceC: :startBuιldSlιce (KFGListC S Ll/*, KFGListC: : iterator OUTPUTIT*/) ( mt dummyNode = 0;// Fll: function receives the selected start node for the slice, // examines whether this node is in a loop; if yes, // the function "sliceForLoops" is called first, otherwise immediately "findDefToCUse" '. void SliceC:: startBuιldSlιce (KFGListC S Ll / *, KFGListC:: iterator OUTPUTIT * /) (mt dummyNode = 0;
KFGListC: : iterator STARTVARI = defineVariableToSlice (Ll ) ; KFGListC:: iterator HELPOUT = STARTVARI; while ((HELPOUT '= Ll.beginO) SS (dummyNode != 1)) (KFGListC:: iterator STARTVARI = defineVariableToSlice (Ll); KFGListC :: iterator HELPOUT = STARTVARI; while ((HELPOUT '= Ll.beginO) SS (dummyNode! = 1)) (
HELPOUT--; lf ( I (HELPOUT->getKFGNodeType() == LC) II (HELPOUT->getKFGNodeType | ) IFC)) SS (HELPOUT->getLevel() == STARTVARI->getLevel I) ) ) ( SliceForLoops ( Ll , STARTVARI ) ; dummyNode = 1 ;HELPOUT--; lf (I (HELPOUT-> getKFGNodeType () == LC) II (HELPOUT-> getKFGNodeType |) IFC)) SS (HELPOUT-> getLevel () == STARTVARI-> getLevel I))) (SliceForLoops (Ll, STARTVARI) ; dummyNode = 1;
} )})
//cout « "Fll" « OUTPUTIT->getNodeNr ( ) « endl; findDefToCUse ( Ll , STARTVARI ) ; }// cout «" Fll "« OUTPUTIT-> getNodeNr () «endl; findDefToCUse (Ll, STARTVARI); }
void SliceC: :slιceAusgeben( ) ( ofstream Ziel ("Slιce2. sie" ) ; ostream_lterator<KFGLιstNodeC> POSITIZiel, "\n"); //ostream_ιterator<KFGLιstNodeC> POSIT2(Zιel, "\n"); SliceC: : iterator SLC = beginl); while (SLC !-= end() ) ( *POSIT++ = (*SLC) .first;void SliceC:: slιceExpend () (ofstream target ("Slιce2. sie"); ostream_lterator <KFGLιstNodeC> POSITIZiel, "\ n"); // ostream_ιterator <KFGLιstNodeC> POSIT2 (Zιel, "\ n"); SliceC:: iterator SLC = beginl); while (SLC! - = end ()) (* POSIT ++ = (* SLC) .first;
SliceC: :Nachfolger: :ιterator IT = («SLC) .second. begm( ) ; SliceC: :Nachfolger: :ιterator ITEND = (*SLC) .second. end( ) ; while (IT != ITEND) (SliceC:: Successor:: ιterator IT = ( « SLC) .second. begm (); SliceC:: Successor:: ιterator ITEND = (* SLC) .second. end (); while (IT! = ITEND) (
//a = (*IT) .first; »POSIT++ = SLC[ («IT) .first] .first;// a = (* IT) .first; " POSIT ++ = SLC [( « IT) .first] .first;
»IT++; ) ++SLC; » IT ++; ) ++ SLC;
«include "KFGDef.h"«Include" KFGDef.h "
DD
»include <ιostream>»Include <ιostream>
DD
G ostreamS Operator « ( ostreamS os, const KFGDefCS Node)( G os « "DEF: " « Node. Def « " " « Node. ScopeLevelD; α return os; αG ostreamS Operator «(ostreamS os, const KFGDefCS Node) (G os« "DEF:" «Node. Def« "" «Node. ScopeLevelD; α return os; α
»include "KFGLineNode.h"»Include" KFGLineNode.h "
GG
»include <ιostream> ostreamS Operator « ( ostreamS os, const KFGLmeNodeCS Node)( os « Node.Name « " " « Node. LineNumber « endl; return os; }»Include <ιostream> ostreamS Operator« (ostreamS os, const KFGLmeNodeCS Node) (os «Node.Name« "" «Node. LineNumber« endl; return os;}
//Funktion, die aus KFGTokenList einen KFG baut. D »include <ιoεtream>// Function that builds a KFG from KFGTokenList. D »Include <ιoεtream>
DD
»include "KFGList.h"»Include" KFGList.h "
DD
»include "KFGTokenList.h"»Include" KFGTokenList.h "
»include "KFGUse.h"»Include" KFGUse.h "
»include "KFGDef.h"»Include" KFGDef.h "
»include "KFGProgList.h"»Include" KFGProgList.h "
»include <algoπthm> void KFGListC: :TokenLιst2KFGLιst (KFGTokenListC S Ll ) ( int dummy;»Include <algoπthm> void KFGListC:: TokenLιst2KFGLιst (KFGTokenListC S Ll) (int dummy;
KFGTokenListC: : iterator TLI = Ll.endO; KFGP_UseLιstC: : iterator P_USEI;KFGTokenListC:: iterator TLI = Ll.endO; KFGP_UseLιstC:: iterator P_USEI;
KFGUseListC: : iterator USEI; dummy = 0;KFGUseListC:: iterator USEI; dummy = 0;
//while (strcmp(TLI->getName( ) , "main") '= 0) { while ((TLI != Ll.beginO) SS (dummy != 1)) ( l (TLI->getTokenNodeType( ) -= N) { lf (strcmp(TLI->getName(),"maιn") == 0) { dummy = 1; ) } //TLI++; switch (TLI->getTokenNodeType( ) ) ( case PL: (// while (strcmp (TLI-> getName (), "main") '= 0) {while ((TLI! = Ll.beginO) SS (dummy! = 1)) (l (TLI-> getTokenNodeType () - = N) {lf (strcmp (TLI-> getName (), "maιn") == 0) {dummy = 1;)} // TLI ++; switch (TLI-> getTokenNodeType ()) (case PL: (
TLI--; KFGLlstNodeC hNl ("NORMAL", NO, TLI->getScopeLevel ( ) ,TLI-TLI--; KFGLlstNodeC hNl ("NORMAL", NO, TLI-> getScopeLevel (), TLI-
>getLιneNumber () ) ; hNl . Defs .push_bac (KFGDefC (TLI->getName ( ) , TLI- >getScopeLevel ( ) ) ) ; push_front (hNl ) ; TLI—;> getLιneNumber ()); hNl. Defs .push_bac (KFGDefC (TLI-> getName (), TLI-> getScopeLevel ())); push_front (hNl); TLI—;
} break; /«case IF: push_front ( KFGLιstNodeC ( "IF" , IFC, TLI->getScopeLevel ( ) ) ) ; TLI--; break; */ case BT :} break; / « Case IF: push_front (KFGLιstNodeC (" IF ", IFC, TLI-> getScopeLevel ())); TLI--; break; * / case BT:
//push_front (KFGLlstNodeC ("BT",BTh,TLI->getScopeLevel ( ) ) ) ; ( TLI—;// push_front (KFGLlstNodeC ("BT", BTh, TLI-> getScopeLevel ())); (TLI—;
//KFGP_UseLιstC: : iterator P_USEI;// KFGP_UseLιstC:: iterator P_USEI;
KFGLlstNodeC hNl ("IFCOND", IFC, TLI->getScopeLevel ( ) ,TLI- >getLιneNumber ( ) ) ; while (TLI->getTokenNodeType( ) '= IF) ( KFGUseC hUsel (TLI->getName( ) ,TLI->getScopeLevel () ) ;KFGLlstNodeC hNl ("IFCOND", IFC, TLI-> getScopeLevel (), TLI-> getLιneNumber ()); while (TLI-> getTokenNodeType () '= IF) (KFGUseC hUsel ( TLI-> getName () , TLI-> getScopeLevel ());
P JSEI = f dlhNl. P_Uses.beginl ) ,hNl . P_Uses.end( ) ,hUsel) ; if I P_USEI == hNl . P_Uses . end () ) { hNl.P_Uses.push_back(hUsel) ; Anzahl_P_Uses++;P JSEI = f dlhNl. P_Uses.beginl), hNl. P_Uses.end (), hUsel); if I P_USEI == hNl. P_Uses. end ()) {hNl.P_Uses.push_back (hUsel); Number_P_Uses ++;
))
//hNl . P_Uses .push_back (KFGUseC (TLI ->getName ( ) ,TLI- >getScopeLevel ( ) ) ) ;// HNl. P_Uses .push_back (KFGUseC (TLI -> getName (), TLI-> getScopeLevel ()));
TLI — ; } push_front (hNl ) ; Entscheιdungen++; } break; case ET: push_front (KFGLlstNodeC ("ENDTHEN",ETh,TLI->getScopeLevel ( ) ) ) ; TLI--; break; case BE: push_front (KFGLlstNodeC ("BEGINELSE", BEI, TLI->getScopeLevel( ) ) ) ;TLI -; } push_front (hNl); Decisions ++; } break; case ET: push_front (KFGLlstNodeC ("ENDTHEN", ETh, TLI-> getScopeLevel ())); TLI--; break; case BE: push_front (KFGLlstNodeC ("BEGINELSE", BEI, TLI-> getScopeLevel ()));
TLI--; break; case EE: push_front (KFGLlstNodeC ( "ENDELSE", EE1, TLI->getScopeLevel () ) ) ; TLI—; break; /•case WHILE: push_front (KFGLlstNodeC ("WHILE", LC, TLI->getScopeLevel ( ) ) ); TLI--; break;*/ case BW:TLI--; break; case EE: push_front (KFGLlstNodeC ("ENDELSE", EE1, TLI-> getScopeLevel ())); TLI—; break; / • case WHILE: push_front (KFGLlstNodeC ("WHILE", LC, TLI-> getScopeLevel ())); TLI--; break; * / case BW:
//push front(KFGLιstNodeC("BW",BL,TLI->getScopeLevel() ) ); { // push front (KFGLιstNodeC ("BW", BL, TLI-> getScopeLevel ())); {
TLI—;TLI—;
//KFGP_UseLιstC: :ιterator PJJSEI;// KFGP_UseLιstC:: ιterator PJJSEI;
KFGLlstNodeC hNl ("LOOPCOND",LC,TLI->getSeopeLevel ( ) ,TLI- >getLιneNumber ( ) ) ; while (TLI->getTokenNodeType() '= WHILE) (KFGLlstNodeC hNl ("LOOPCOND", LC, TLI-> getSeopeLevel (), TLI-> getLιneNumber ()); while (TLI-> getTokenNodeType () '= WHILE) (
KFGUseC hUsel (TLI->getName ( ) ,TLI->getScopeLevel ( ) ) ; PJJSEI = find (hNl.P Uses. beginl ) , hNl . P_Uses . end ( ) ,hUsel) ; if (P_USEI == hNl.P_Uses.end() ) { hNl.P_Uses.push_back(hUsel);KFGUseC hUsel (TLI-> getName (), TLI-> getScopeLevel ()); PJJSEI = find (hNl.P Uses. Beginl), hNl. P_Uses. end (), hUsel); if (P_USEI == hNl.P_Uses.end ()) {hNl.P_Uses.push_back (hUsel);
Anzahl_P_Uses++; }Number_P_Uses ++; }
//hNl. P_Uses.push_back(KFGUseC (TLI->getName () ,TLI- >getScopeLevel ( ) ) ) ; TLI--;// HNl. P_Uses.push_back (KFGUseC (TLI-> getName (), TLI-> getScopeLevel ())); TLI--;
} push_front (hNl) ; Schieifenentscheιdungen++; } break; case EW: push_front (KFGLlstNodeC ("ENDLOOP", EL, TLI->getScopeLevel () ) ); TLI—; break; case BDOW:} push_front (hNl); Schieifenentscheidungen ++; } break; case EW: push_front (KFGLlstNodeC ("ENDLOOP", EL, TLI-> getScopeLevel ())); TLI—; break; case BDOW:
((
TLI—;TLI—;
KFGLlstNodeC hNl ("DOWHILELOOPCOND", DOWLC.TLI- >getScopeLevel ( ) ,TLI->getLιneNumber ( ) ) ; while (TLI->getTokenNodeType() '= DOWS) (KFGLlstNodeC hNl ("DOWHILELOOPCOND", DOWLC.TLI-> getScopeLevel (), TLI-> getLιneNumber ()); while (TLI-> getTokenNodeType () '= DOWS) (
KFGUseC hUsel (TLI->getName ( ) , TLI->getScopeLevel ( ) ) ; P_USEI = fιnd( hNl. P_Uses.beginl ) ,hNl. P_Uses.end( ) ,hUsel) ; lf (PJJSEI == hNl.P_Uses.end()) ( hNl. PJJses.pushJ>ack!hUsel);KFGUseC hUsel (TLI-> getName (), TLI-> getScopeLevel ()); P_USEI = fιnd (HNl. P_Uses.beginl), hNl. P_Uses.end (), hUsel); lf (PJJSEI == hNl.P_Uses.end ()) (hNl. PJJses.pushJ> ack! hUsel);
Anzahl_P_Uses++; } hNl. PJJses.pushJ-ack(KFGUseC (TLI->getName ( ),TLI- >getScopeLevel I ) ) ) ; TLI—;Number_P_Uses ++; } hNl. PJJses.pushJ-ack (KFGUseC (TLI-> getName (), TLI-> getScopeLevel I))); TLI—;
) push_front(hNl) ; } break; case DO: push_front (KFGLιstNodeC("DOWHILELOOP",DOWL,TLI->getScopeLevel ( ) ) ) ; TLI — ;) push_front (hNl); } break; case DO: push_front (KFGLιstNodeC ("DOWHILELOOP", DOWL, TLI-> getScopeLevel ())); TLI -;
Schle f enentscheιdungen++ ; break; case EF:Loop decisions ++; break; case EF:
((
//TLI—; int HLevel;// TLI—; int HLevel;
HLevel = TLI->getScopeLevel ( ) ; push_front (KFGLlstNodeC ("ENDLOOP", EL, LI->getScopeLevel() ) );HLevel = TLI-> getScopeLevel (); push_front (KFGLlstNodeC ("ENDLOOP", EL, LI-> getScopeLevel ()));
//while (TLI->getTokenNodeType() != BF) ( while ( (TLI->getTokenNodeType() >= BF) II (TLI- >getScopeLevel I ) != HLevel)) (// while (TLI-> getTokenNodeType ()! = BF) (while ((TLI-> getTokenNodeType ()> = BF) II (TLI-> getScopeLevel I)! = HLevel)) (
TLI—; }TLI—; }
TLI—; if (TLI->getTokenNodeType( ) == PF)TLI—; if (TLI-> getTokenNodeType () == PF)
TLI--; KFGLlstNodeC hNl ( "NORMAL",NO,TLI->getScopeLevel ( ) ,TLI- >getLmeNumber () ) ; hNl.Defs.push_back(KFGDefC(TLI->getName( ),TLI- >getScopeLevel () ) ) ;TLI--; KFGLlstNodeC hNl ("NORMAL", NO, TLI-> getScopeLevel (), TLI-> getLmeNumber ()); hNl.Defs.push_back (KFGDefC (TLI-> getName (), TLI-> getScopeLevel ()));
AnzahlJ3efs++; hNl.Uses.push_back( KFGUseC (TLI->getName ( ) , TLI- >getScopeLevel I ) ) ) ;Number of J3efs ++; hNl.Uses.push_back (KFGUseC (TLI-> getName (), TLI-> getScopeLevel I)));
Anzahl_Uses++; push_front(hNl);Number_use ++; push_front (hNl);
//while (TLI->getTokenNodeType() '= EF) ( while ( (TLI->getTokenNodeType() != EF) II (TLI-// while (TLI-> getTokenNodeType () '= EF) ( while ((TLI-> getTokenNodeType ()! = EF) II (TLI-
>getScopeLevel( ) '= HLevel)) {> getScopeLevel () '= HLevel)) {
TLI++;TLI ++;
}}
TLI—;TLI—;
Zaehlschleιfenentscheιdungen++; Schleifenentscheιdungen++; break; case FOR_D: (Counting loop decisions ++; Loop decisions ++; break; case FOR_D: (
TLI—;TLI—;
KFGLlstNodeC hNl ( "LOOPCOND", LC,TLI->getScopeLevel ( ) ,TLI- >getLιneNumber ( ) ) ; while (TLI->getTokenNodeType() != DEF) {KFGLlstNodeC hNl ("LOOPCOND", LC, TLI-> getScopeLevel (), TLI-> getLιneNumber ()); while (TLI-> getTokenNodeType ()! = DEF) {
KFGUseC hUsel (TLI->getName ( ) ,TLI->getScopeLevel () ) ; PJJSEI -= find (hNl. PJJses.beginl ) , hNl . PJJses. endl ) ,hUsel) ; lf (PJJSEI — hNl.P_Uses.end()) ( hNl . PJJses .push_back (hUsel ) ; Anzahl_P_Uses++; } //hNl . PJJses.push_back (KFGUseC (TLI->getName ( ) ,TLI-KFGUseC hUsel (TLI-> getName (), TLI-> getScopeLevel ()); PJJSEI - = find (HNl. PJJses.beginl), hNl. PJJses. endl), hUsel); lf (PJJSEI - hNl.P_Uses.end ()) (hNl. PJJses .push_back (hUsel); number_P_Uses ++;} // hNl. PJJses.push_back (KFGUseC (TLI-> getName (), TLI-
>getScopeLevel ( ) ) ) ;> getScopeLevel ()));
TLI—; } push_front (hNl) ;TLI—; } push_front (hNl);
TLI--;TLI--;
KFGLlstNodeC hN2 ( "NORMAL", NO, (TLI->getScopeLevel ( ) -1 ) ,TLI-KFGLlstNodeC hN2 ("NORMAL", NO, (TLI-> getScopeLevel () -1), TLI-
>getLιneNumber ( ) ) ; hN2.Defs.push_back(KFGDefC(TLI->getName( ) , (TLI- >getScopeLevel ()-!)));> getLιneNumber ()); hN2.Defs.push_back (KFGDefC (TLI-> getName (), (TLI-> getScopeLevel () -!)));
Anzahl_Defs++; push_front (hN2) ; TLI--; break; case RET:Number_defs ++; push_front (hN2); TLI--; break; case RET:
//Nur eine vorläufige Implementierung; muß noch erweitert werden// Just a preliminary implementation; still needs to be expanded
//für den Fall, daß nach dem RETURN eine Ausgabe folgt. push_front( KFGLlstNodeC ("RETURN", RETURN, LI->getScopeLevel ( ) ) ) ;// in case there is an output after the RETURN. push_front (KFGLlstNodeC ("RETURN", RETURN, LI-> getScopeLevel ()));
TLI—; break; case NL:TLI—; break; case NL:
TLI--;TLI--;
//Knoten erzeugen, der Defs und Uses enthält; lf (TLI->getTokenNodeType() —= N) (// create nodes that contain defs and uses; lf (TLI-> getTokenNodeType () - = N) (
KFGLlstNodeC helpNodel ( "NORMAL", NO, TLI->getScopeLevel ( ) ,TLI- >getLιneNumber ( ) ) ;KFGLlstNodeC helpNodel ("NORMAL", NO, TLI-> getScopeLevel (), TLI-> getLιneNumber ());
TLI--; lf (TLI->getTokenNodeType() == NL) (TLI--; lf (TLI-> getTokenNodeType () == NL) (
TLI++; helpNodel. Defs.push_back(KFGDefC (TLI->getName ( ) ,TLI-TLI ++; helpNodel. Defs.push_back (KFGDefC (TLI-> getName (), TLI-
>getScopeLevel ( ) ) I ;> getScopeLevel ()) I;
Anzahl_Defs++; helpNodel .Uses .pushjoack (KFGUseC (TLI->getName ( ) ,TLI- >getScopeLevel ( ) ) ) ;Number_defs ++; helpNodel .Uses .pushjoack (KFGUseC (TLI-> getName (), TLI-> getScopeLevel ()));
Anzahl_Uses++; TLI—;Number_use ++; TLI—;
} eise (} ice (
TLI++; while (TLI->getTokenNodeType( ) ' = DEF) { KFGUseC hUsel (TLI->getName ( ) ,TLI- >getScopeLevel ( ) ) ;TLI ++; while (TLI-> getTokenNodeType () '= DEF) {KFGUseC hUsel (TLI-> getName (), TLI-> getScopeLevel ());
USEI = find (helpNodel.Uses. beginl ) , helpNodel .Uses. end ( ) ,hUsel ) ; lf (USEI == helpNodel. Uses. endl ) ) { helpNodel .Uses.push_back (hUsel ) ; Anzahl_Uses++ ; }USEI = find (helpNodel.Uses. Beginl), helpNodel .Uses. end (), hUsel); lf (USEI == helpNodel. Uses. endl)) {helpNodel .Uses.push_back (hUsel); Number_use ++; }
//helpNodel. Uses.push_back(KFGUseC (TLI-// helpNodel. Uses.push_back (KFGUseC (TLI-
>getName( ) ,TLI->getScopeLevel O ) ) ; TLI—; } TLI--; helpNodel. Defs.push_bac (KFGDefC (TLI->getName ( ) ,TLI- >getScopeLevel ( ) ) ) ;> getName (), TLI-> getScopeLevel O)); TLI—; } TLI--; helpNodel. Defs.push_bac (KFGDefC (TLI-> getName (), TLI-> getScopeLevel ()));
TLI—;TLI—;
Anzahl_Defs++; if (TLI->getTokenNodeType() — N) ( helpNodel.Defs.pop_front ( ) ; Anzahl_Defs—; //in diesem Fall handelt es sich um ein Array undNumber_defs ++; if (TLI-> getTokenNodeType () - N) (helpNodel.Defs.pop_front (); number_defs—; // in this case it is an array and
//daher muß der letzte Knoten wieder gelöscht werden.// therefore the last node must be deleted.
TLI++; //Dafür muß der gelöschte Knoten in die Use-Liste eingetragen werden.TLI ++; // To do this, the deleted node must be entered in the use list.
KFGUseC hUse2 (TLI->getName ( ) ,TLI- >getScopeLevel ( ) ) ;KFGUseC hUse2 (TLI-> getName (), TLI-> getScopeLevel ());
USEI - find (helpNodel.Uses. begm( ) , helpNodel. Uses. end ( ) ,hUse2) ; lf (USEI == helpNodel.Uses. en () ) ( helpNodel.Uses. ush_back(hUse2) ; Anzahl Uses++;USEI - find (helpNodel.Uses. Begm (), helpNodel. Uses. End (), hUse2); lf (USEI == helpNodel.Uses. en ()) (helpNodel.Uses. ush_back (hUse2); Number of Uses ++;
TLI--; helpNodel.Defs.pushJ-ack (KFGDefC(TLI-TLI--; helpNodel.Defs.pushJ-ack (KFGDefC (TLI-
>getName ( ) , TLI->getScopeLevel ( ) ) ) ; helpNodel.Uses.push_bac (KFGUseC (TLI- >getName ( ) , TLI->getScopeLevel () ) ) ;> getName (), TLI-> getScopeLevel ())); helpNodel.Uses.push_bac (KFGUseC (TLI-> getName (), TLI-> getScopeLevel ()));
Anzahl_Defs++; AnzahlJJses++; TLI--;Number_defs ++; NumberJJses ++; TLI--;
} push fron (helpNodel) ; }} push fron (helpNodel); }
//Knoten erzeugen, der nur Defs enthält; eise if (TLI->getTokenNodeType() == DEF) (// create nodes that only contain defs; else if (TLI-> getTokenNodeType () == DEF) (
TLI—;TLI—;
KFGLlstNodeC helpNodel ("NORMAL",NO, TLI->getScopeLevel ( ) ,TLI-KFGLlstNodeC helpNodel ("NORMAL", NO, TLI-> getScopeLevel (), TLI-
>getLιneNumber ( ) ) ; helpNodel . Defs .push_back (KFGDefC (TLI->getName ( ) , TLI- >getScopeLevel ( ) ) ) ; push_front (helpNodel ) ;> getLιneNumber ()); helpNodel. Defs .push_back (KFGDefC (TLI-> getName (), TLI-> getScopeLevel ())); push_front (helpNodel);
Anzahl_Defs++;Number_defs ++;
TLI--; ) eise if (TLI->getTokenNodeType( ) == PF) (TLI--; ) else if (TLI-> getTokenNodeType () == PF) (
TLI—;TLI—;
KFGLlstNodeC hNl ( "NORMAL", NO, TLI->getScopeLevel ( ) ,TLI-KFGLlstNodeC hNl ("NORMAL", NO, TLI-> getScopeLevel (), TLI-
>getLιneNumber ( ) ) ; hNl.Defs.push_back(KFGDefC(TLI->getName( ) ,TLI- >getScopeLevel ( ) ) ) ; hNl.Uses.push_back(KFGUseC(TLI->getName( ) ,TLI- >getScopeLevel ( ) ) ) ; push_front(hNl);> getLιneNumber ()); hNl.Defs.push_back (KFGDefC (TLI-> getName (), TLI-> getScopeLevel ())); hNl.Uses.push_back (KFGUseC (TLI-> getName (), TLI-> getScopeLevel ())); push_front (hNl);
Anzahl_Defs++;Number_defs ++;
Anzahl_Uses++; }Number_use ++; }
//Knoten erzeugen, der Output-Variablen enthält; eise (// create node that contains output variables; ice (
TLI—;TLI—;
KFGLlstNodeC helpNodel ("OUTPUT", OP,TLI->getScopeLevel ( ) ,TLI-KFGLlstNodeC helpNodel ("OUTPUT", OP, TLI-> getScopeLevel (), TLI-
>getLιneNumber ( ) ) ; helpNodel .Uses . push_back ( KFGUseC (TLI->getName ( ) , TLI- >getScopeLevel ( ) ) ) ; push_front (helpNodel ) ;> getLιneNumber ()); helpNodel .Uses. push_back (KFGUseC (TLI-> getName (), TLI-> getScopeLevel ())); push_front (helpNodel);
Anzahl_Uses++;Number_use ++;
TLI—;TLI—;
Anweιsungen++; break; default:Instructions ++; break; default:
TLI—;TLI—;
}}
KnotenNummern ( ) ;Node numbers ();
KFGListC:: iterator KFG = beginl);KFGListC :: iterator KFG = beginl);
Knotenldentifizierer (KFG) ; addL elnToList ( ) ;Node identifier (KFG); addL elnToList ();
Anzahl Deklarationen = zaehleDeklaratιonen(Ll ) ; void KFGListC: : KnotenNummern ( ) ( mt KnotenNr = 1;Number of declarations = count declarations (Ll); void KFGListC:: node numbers () (with node number = 1;
KFGListC: : iterator KFGI = beginl); while (KFGI '= end()) ( lf ( (KFGl->getKFGNodeType() == EL) II (KFGl->getKFGNodeType ( ) == ETh) II (KFGl->getKFGNodeType( ) == BE1) II (KFGl->getKFGNodeType( ) == EE1 ) ) ( KFG1++;KFGListC:: iterator KFGI = beginl); while (KFGI '= end ()) (lf ((KFGl-> getKFGNodeType () == EL) II (KFGl-> getKFGNodeType () == ETh) II (KFGl-> getKFGNodeType () == BE1) II (KFGl -> getKFGNodeType () == EE1)) (KFG1 ++;
) eise () ice (
KFGI->setKFGKnotenNummer (KnotenNr) ; KnotenNr++; KFG1++;KFGI-> setKFG node number (node number); Node number ++; KFG1 ++;
void KFGListC: :KnotenIdentιflzierer (KFGListC: :iterator KFG) int LOOPLevel = 0 int THENLevel = 0 int ELSELevel = 0 KFGListC: : iterator KFGI KFG; KFGListC: : iterator LOOPIT = KFG; KFGListC: : iterator IFIT KFG; KFGListC: : iterator ELSEIT = KFG; while (KFGI != end() ) ( switch (KFGl->getKFGNodeType ( ) ) case LC:void KFGListC:: node identifier (KFGListC:: iterator KFG) int LOOPLevel = 0 int THENLevel = 0 int ELSELevel = 0 KFGListC:: iterator KFGI KFG; KFGListC:: iterator LOOPIT = KFG; KFGListC:: iterator IFIT KFG; KFGListC:: iterator ELSEIT = KFG; while (KFGI! = end ()) (switch (KFGl-> getKFGNodeType ()) case LC:
LOOPLevel = KFGl->getLevel ( ) ;LOOPLevel = KFGl-> getLevel ();
KFG1++;KFG1 ++;
LOOPIT = KFGI; while ( (KFGl->getKFGNodeType ( ) != EL) II (KFGl->getLevel()LOOPIT = KFGI; while ((KFGl-> getKFGNodeType ()! = EL) II (KFGl-> getLevel ()
LOOPLevel ) ) {LOOPLevel)) {
KFGl->setKnotenIdent (LOOP) ; KFG1++; }KFGl-> setKnotenIdent (LOOP); KFG1 ++; }
Knotenldentifizierer (LOOPIT) ; } break; case IFC: <Node identifier (LOOPIT); } break; case IFC: <
THENLevel = KFGl->getLevel ( ) ;THENLevel = KFGl-> getLevel ();
KFG1++;KFG1 ++;
IFIT = KFGI; while ( (KFGl->getKFGNodeType() >= ETh) II (KFGl->getLevel () != THENLevel) )IFIT = KFGI; while ((KFGl-> getKFGNodeType ()> = ETh) II (KFGl-> getLevel ()! = THENLevel))
KFGl->setKnotenIdent (THEN) ;KFGl-> setKnotenIdent (THEN);
KFG1++; } Knotenldentifizierer (IFIT) ; } break; case BEI: (KFG1 ++; } Node identifier (IFIT); } break; case AT: (
ELSELevel = KFGl->getLevel ( ) ; KFG1++;ELSELevel = KFGl-> getLevel (); KFG1 ++;
ELSEIT = KFGI; while ( (KFGl->getKFGNodeType() != EE1) || (KFGl->getLevel (ELSEIT = KFGI; while ((KFGl-> getKFGNodeType ()! = EE1) || (KFGl-> getLevel (
!= ELSELevel) )! = ELSELevel))
KFGI->setKnotenIdent (ELSE) ; KFG1++;KFGI-> setKnotenIdent (ELSE); KFG1 ++;
Knotenldentifizierer (ELSEIT) ;Node identifier (ELSEIT);
} break; default:} break; default:
//cout « "Autsch" « endl;// cout «" Ouch "« endl;
KFG1++; ) //KFG1++; voiα KFGListC: :addLιneInToLιst ( ) ( mt zahl; char lιne[256]; KFGProgListC LP; lfstream datei ("CodeLine.dat") ; if (!dateι) ( cout « "ERROR: Cannot open file 'CodeLine.dat'." « endl;KFG1 ++; ) // KFG1 ++; voiα KFGListC:: addLιneInToLιst () (mt number; char lιne [256]; KFGProgListC LP; l fstream file ("CodeLine.dat"); if (! dateι)) (cout «" ERROR: Cannot open file 'CodeLine.dat' . "« Endl;
) eise ( while ( idatei.eof ( ) ) ( datei.getlmelline, 255, '\n'); for (int ι=0; Kstrlen(line) ; ι++) ( lf (line(ι) == •"' ) ( lιne[ι] = '\"; ) if (lineli) — '(') ( lιne(i] = ';'; ) } zahl = atoι(lιne);) eise (while (idatei.eof ()) (file.getlmelline, 255, '\ n'); for (int ι = 0; Kstrlen (line); ι ++) (lf (line (ι) == • "') (lιne [ι] ='\"; ) if (lineli) - '(') (lιne (i] = ';';)} number = atoι (lιne);
KFGLmeNodeC hknotendine, zahl ) ;KFGLmeNodeC hknotendine, number);
LP.push_back (hknoten) ;LP.push_back (hknoten);
//cout « line « " " « zahl « endl;// cout «line« "" «number« endl;
} } addLιneToKFG(LP);}} addLιneToKFG (LP);
void KFGListC: :addLιneToKFG (KFGProgListC S LP) { int dummy = 0; char help(256];void KFGListC:: addLιneToKFG (KFGProgListC S LP) {int dummy = 0; char help (256];
KFGListC: : iterator KFGI = end(); KFGProgListC: : iterator PROG1 = LP.endO; //KFGI—; while (KFGI != begιn()) ( KFGI—; lf ( (KFGl->getKFGNodeType() == EL) || (KFGl->getKFGNodeType () == ETh) II (KFGl->getKFGNodeType() == BEI ) || (KFGl->getKFGNodeType ( ) == EE1 ) ) ( KFGI—;KFGListC:: iterator KFGI = end (); KFGProgListC:: iterator PROG1 = LP.endO; // KFGI—; while (KFGI! = begιn ()) (KFGI—; lf ((KFGl-> getKFGNodeType () == EL) || (KFGl-> getKFGNodeType () == ETh) II (KFGl-> getKFGNodeType () == BEI ) || (KFGl-> getKFGNodeType () == EE1)) (KFGI—;
} while ((PROG1 '= LP.beginO) SS (dummy '= 1)) ( lf (KFGl->getLmeNr() == PROGl->getLmeNumber I ) ) ( strcpy (help,PROGl->getName () ) ; KFGl->setCodeLιne(help);} while ((PROG1 '= LP.beginO) SS (dummy' = 1)) (lf (KFGl-> getLmeNr () == PROGl-> getLmeNumber I)) (strcpy (help, PROGl-> getName ()); KFGl-> setCodeLιne (help);
PROG1—; dummy = 1; ) else{ PROG1—;PROG1—; dummy = 1; ) else {PROG1—;
PROG1 = LP. en l ); dummy = 0;PROG1 = LP. en l); dummy = 0;
int KFGListC: :zaehleDeklaratιonen (KFGTokenListC S TL) ( int zaehler = 0;int KFGListC:: count declarations (KFGTokenListC S TL) (int count = 0;
KFGTokenListC: : iterator TListI = TL.endO; while (strcmp(TLιstI->getName( ) ,"maιn") '= 0) ( lf (TLιstI->getTokenNodeType() == TD) f zaehler++; }KFGTokenListC:: iterator TListI = TL.endO; while (strcmp (TLιstI-> getName (), "maιn") '= 0) (lf (TLιstI-> getTokenNodeType () == TD) f counter ++;}
TListI—; return zaehler;TListI—; return counter;
//Funktion zur Ausgabe der KFGList auf den Bildschirm und in eine Datei "CFGList". void KFGListC: :LιsteAusgeben( ) { ofstream Ziell ("CFGLis . cfg" ) ; ostream_ιterator<KFGLιstNodeC> Pos(Zιell, "\n"); ostream_ιterator<KFGDefC> PosDIZiell, "\n") ostream_ιterator<KFGUseC> PosUIZiell, "\n"); ostream_ιterator<KFGUseC> PosPIZiell, "\n"); KFGListC: : iterator KLI = beginl ); KFGDefListC: : iterator DEF; KFGUseListC: : iterator USE; KFGPJJseListC: : iterator PJJSE; Ziell « "START" « endl « endl; while (KLI '= endO ) (// Function for outputting the KFGList on the screen and in a file "CFGList". void KFGListC:: Latest output () {ofstream target ("CFGLis. cfg"); ostream_ιterator <KFGLιstNodeC> Pos (Zιell, "\ n"); ostream_ιterator <KFGDefC> PosDIZiell, "\ n") ostream_ιterator <KFGUseC> PosUIZiell, "\ n"); ostream_ιterator <KFGUseC> PosPIZiell, "\ n"); KFGListC:: iterator KLI = beginl); KFGDefListC:: iterator DEF; KFGUseListC:: iterator USE; KFGPJJseListC:: iterator PJJSE; Target «" START "« endl «endl; while (KLI '= endO) (
Ziell « "Line " « KLI->getLιneNr ( ) « endl; Ziell « "Zeile " « KLI->getCodeLιne ( ) « endl; Ziell « "Knoten " « KLI->getKnotenNummer ( ) « endl; Ziell « "KnotenTyp " « KLI->getKnotenIdent O « endl;Target «" Line "« KLI-> getLιneNr () «endl; Target «" line "« KLI-> getCodeLιne () «endl; Target «" node "« KLI-> getNodeNumber () «endl; Target «" node type "« KLI-> getKnotenIdent O «endl;
Ziell « KLI->getStatement () « " " « KLI->getLevel () « endl; //*Pos++ - »KLI; DEF - KLI->Defs.begin(); USE = KLI->Uses.begin(); P_USE - KLI->P_Uses.beginl ); while (DEF !»= KLI->Defs.end( ) ) ( //*PosD++ = »DEF;Target «KLI-> getStatement ()« ""«KLI-> getLevel ()« endl; // * Pos ++ - » KLI; DEF - KLI-> Defs.begin (); USE = KLI-> Uses.begin (); P_USE - KLI->P_Uses.beginl); while (DEF! »= KLI-> Defs.end ()) (// * PosD ++ = » DEF;
Ziell « "DEF: " « DEF->getDef ( ) « " " « DEF- >getScopeLevelD( ) « endl; DEF++;Target «" DEF: "« DEF-> getDef () «" "« DEF-> getScopeLevelD () «endl; DEF ++;
) while (USE != KLI->Uses.end() ) ( //*PosU++ = »USE;) while (USE! = KLI-> Uses.end ()) (// * PosU ++ = » USE;
Ziell « "USE: " « USE->getUse ( ) « " " « USE- >getScopeLevelU( ) « endl;Target «" USE: "" USE-> getUse () "" "" USE-> getScopeLevelU () "endl;
USE++; } while (PJJSE '= KLI->P_Uses.end() ) ( //*PosP++ = «P_USE; Ziell « "P_USE: " « P_USE->getUse ( ) « " " «USE ++; } while (PJJSE '= KLI-> P_Uses.end ()) (// * PosP ++ = « P_USE; target« "P_USE:"«P_USE-> getUse ()« "" «
P_USE->getScopeLevelU 0 « endl; PJJSE++; )P_USE-> getScopeLevelU 0 «endl; PJJSE ++; )
Ziell « endl; KLI++;Target «endl; KLI ++;
))
Ziell « "STOP" « endl « endl; Ziell « "BASISGROESSEN:" « endl; Ziell « "Anzahl leerer Zweige: " « "0" « endl; Ziell « "Anzahl Entscheidungen: " « Entscheidungen « endl;Target «" STOP "« endl «endl; Target «" BASIC SIZES: "« endl; Target «" Number of empty branches: "« "0" «endl; Target «" Number of decisions: "« Decisions «final;
Ziell « "Anzahl Anweisungen: " « Anweisungen « endl; Ziell « "Anzahl atomarer Prädikate: " « Entscheidungen « endl; Ziell « "Anzahl Prädikate: " « Entscheidungen « endl;Target «" number of instructions: "« instructions «endl; Target «" number of atomic predicates: "« decisions «final; Target «" Number of predicates: "« Decisions «final;
Ziell « "Anzahl atomarer Prädikate, die arithm. Relationen sind: " « "0" « endl; Ziell « "Anzahl Schleifenentscheidungen: " « Schleifenentscheidungen « endl;Target «" Number of atomic predicates, which are arithmetic relations: "« "0" «endl; Target «" Number of loop decisions: "« Loop decisions «endl;
Ziell « "Anzahl nicht eingeschachtelter Schleifenentscheidungen: " « "0" « endl; Ziell « "Anzahl Zählschleifenentscheidungen: " « Zaehlschleifenentscheidungen « endl;Target «" Number of non-nested loop decisions: "« "0" «endl; Target «" number of counting loop decisions: "« counting loop decisions «endl;
Ziell « "Anzahl Deklarationen von strukturierten Datentypen: " « "0" « endl; Ziell « "Anzahl Deklarationen: " « Anzahl_Deklaratιonen « endl;Target «" Number of declarations of structured data types: "« "0" «endl; Target «" Number of declarations: "« Number_declarations «endl;
Ziell « "Anzahl Realelement-Deklarationen: " « "0" « endl; Ziell « "Anzahl Basistyp-Deklarationen: " « Anzahl_Deklaratιonen « endl; Ziell « "Anzahl Defs: " « Anzahl_Defs « endl; Ziell « "Anzahl Uses: " « Anzahl_Uses « endl; Ziell « "Anzahl P-Uses: " « Anzahl_P_Uses « endl « endl; basisgroessenlnDatei ( ) ; } void KFGListC: :basιsgroessenInDatei ( ) ( ofstream datei ("Basisgroessen.bgd", ιos::out); datei « "0" « endl; datei « Entscheidungen « endl; datei « Anweisungen « endl; datei « Entscheidungen « endl; datei « Entscheidungen « endl; datei « "0" « endl; datei « Schleifenentscheidungen « endl; datei « "0" « endl; datei « Zaehlschleifenentscheidungen « endl; datei « "0" « endl; datei « Anzahl_Deklaratιonen « endl; datei « "0" « endl; datei « Anzahl_Deklaratιonen « endl; datei « "0" « endl; datei « Anzahl_Defs « endl; datei « AnzahlJJses « endl; datei « Anzahl_P_Uses « endl; datei « "0" « endl; datei « "0" « endl; datei « "0" « endl; datei « "0" « endl; datei « "0" « endl; datei « "0" « endl; datei « "0" « endl; datei « "0" « endl;Target «" Number of real element declarations: "« "0"«endl; Target «" number of base type declarations: "« number_declarations «endl; Target «" number of defs: "« number_defs «endl; Target «" Number of Uses: "« Number_Uses «endl; Target «" Number of P-Uses: "« Number_P_Uses «endl« endl; base size file (); } void KFGListC:: basιsgroessenInDatei () (ofstream file ("Basisgroessen.bgd", ιos :: out); file «" 0 "« endl; file «decisions« endl; file «instructions« endl; file «decisions« endl; file «decisions« endl; file «" 0 "« endl; file «loop decisions« endl; file «" 0 "« endl; file «counting loop decisions« endl; file «" 0 "« endl; file «number_declarations« endl; file « "0"«endl; file« number_declarations «endl; file« "0"«endl; file« number_defs «endl; file« numberJJses «endl; file« number_P_Uses «endl; file «" 0 "« endl; file «" 0 "« endl; file «" 0 "« endl; file «" 0 "« endl; file «" 0 "« endl; file «" 0 "« endl; file «" 0 "« endl; file «" 0 "« endl;
»include "KFGListe .h" D»Include" KFGListe .h "D
DD
KFGListeT KFGListe;KFGListeT KFGListe;
D α void KFGListeAusgebenlKFGListeT S L) { 0D α void KFGListeAusgabelKFGListeT S L) {0
KFGListeT: : iterator I = L.beginO; D whiled '= L.endl) ) cout « »I++ « ' '; cout « " sιze() = " « L.sizeO « endl; }KFGListeT:: iterator I = L.beginO; D whiled '= L.endl)) cout « » I ++ «''; cout «" sιze () = "« L.sizeO «endl; }
»include "KFGListNode.h"»Include" KFGListNode.h "
»include <ιostream>»Include <ιostream>
00
D ostreamS Operator « ( ostreamS os, const KFGListNodeCS Node)( □ os « endl « "KnotenNr:" « Node. KnotenNr « " Typ:" « Node. Knotenldent « endl « Node. Statement « " Level:" « Node. Level; return os; int KFGLlstNodeC: :DummyNodeNr=l;D ostreamS Operator «(ostreamS os, const KFGListNodeCS Node) (□ os« endl «" NodeNo: "« Node. NodeNo «" Type: "« Node. Node ID "endl« Node. Statement «" Level: "« Node. Level ; return os; int KFGLlstNodeC:: DummyNodeNr = l;
00
»include "KFGNode.h" 0»Include" KFGNode.h "0
»include <ιostream> D»Include <ιostream> D
□ ostreamS Operator « ( ostreamS os, const KFGNodeCS Node)□ ostreamS Operator «(ostreamS os, const KFGNodeCS Node)
D os « Node. Name « " " « Node. ScopeLevel; return os; }D os «node. Name «" "« Node. ScopeLevel; return os; }
»include "KFGTokenList.h" D void KFGTokenListC: :KFGLιsteAusgeben( ) ( D ofstream Ziel ("CFGTokenList") ; D ostream_ιterator<KFGTokenNodeC> oPos(Zιel, "\n");»Include" KFGTokenList.h "D void KFGTokenListC:: KFGLιsteAusgabe () (D ofstream destination ("CFGTokenList"); D ostream_ιterator <KFGTokenNodeC> oPos (Zιel, "\ n");
DD
KFGTokenListC: : iterator I = beginl); 0 while (I != endl ) ) { //»oPos++ - I->getName();KFGTokenListC:: iterator I = beginl); 0 while (I! = Endl)) {// » oPos ++ - I-> getName ();
*oPos++ = »I;* oPos ++ = » I;
//cout « I->getName() « " " « I->getScopeLevel ( ) « " " « I- >getTokenNodeType ( ) « endl; I++; ) cout « " sizel) = " « sizeO « endl;// cout «I-> getName ()« "" «I-> getScopeLevel ()« "" «I-> getTokenNodeType ()« endl; I ++; ) cout «" sizel) = "« sizeO «endl;
»mclude "KFGTokenNode.h" »include <ιostream> ostreamS Operator « ( ostreamS os, const KFGTokenNodeCS Node)( os « Node.Name « " " « Node. ScopeLevel « " " « Node. TokenNodeType « " « Node. ineNumber « endl; return os;»Mclude" KFGTokenNode.h "» include <ιostream> ostreamS Operator «(ostreamS os, const KFGTokenNodeCS Node) (os« Node.Name «" "« Node. ScopeLevel «" "« Node. TokenNodeType «" «Node. IneNumber« endl; return os;
»include "KFGUse.h"»Include" KFGUse.h "
00
»include <ιostream> ostreamS Operator « ( ostreamS os, const KFGUseCS Node)( os « "USE: " « Node. Use « " " « Node. ScopeLevelU; return os;»Include <ιostream> ostreamS Operator« (ostreamS os, const KFGUseCS Node) (os «" USE: "« Node. Use «" "« Node. ScopeLevelU; return os;
/* D * Main program to test C++ grammar and preprocessor D/ * D * Main program to test C ++ grammar and preprocessor D
*/ π o »include "JLStr.h"* / π o »include" JLStr.h "
DD
»include "tokens.h"»Include" tokens.h "
00
»include "DLGLexer.h" »include "BufferedCPreParser.h"»Include" DLGLexer.h "» include "BufferedCPreParser.h"
»include "CPreToCPPBuffer.h"»Include" CPreToCPPBuffer.h "
»include "JLTokenBuffer.h"»Include" JLTokenBuffer.h "
»include "CPPParserSym.h"»Include" CPPParserSym.h "
»mclude "KFGTokenList.h" «include "KFGList. h"»Mclude" KFGTokenList.h "« include "KFGList. H"
» clude "graph.h"»Clude" graph.h "
»mclude "AS_Slιce.h"»Mclude" AS_Slιce.h "
»include "uwggraph.h"»Include" uwggraph.h "
« clude "KFGProgList .h" »include <ιostream> static void usagelchar* progname); int maindnt arge, char *argv|]) {«Clude" KFGProgList .h "» include <ιostream> static void usagelchar * progname); int maindnt arge, char * argv |]) {
// For reporting memory usage char *p = new char [ 100000) ; long heapl = (long) (void* )p; delete [ ] p;// For reporting memory usage char * p = new char [100000); long heapl = (long) (void *) p; delete [] p;
// Parse command-line options JLStr includePath; JLStr definitions;// Parse command-line options JLStr includePath; JLStr definitions;
FILE «lnputFile = stdin; bool doTraceParse = false; bool doTraeelnclude = false; bool doDump = false; char «progname = «argv; arge—; argv++; ofstream datei ("CodeLme.dat", ιos::trunc); while (arge > 0)FILE «inputFile = stdin; bool doTraceParse = false; bool doTraeelnclude = false; bool doDump = false; char «progname = « argv; arge—; argv ++; ofstream file ("CodeLme.dat", ιos :: trunc); while (arge> 0)
( if (argv[0] [0] == •-) ( switch (argv(0] [1] ) ( case ' I" : lf (argv[0] [2] != 0) ((if (argv [0] [0] == • - ) (switch (argv (0] [1]) (case 'I ": lf (argv [0] [2]! = 0) (
// argument is part of "-I" includePath += ' ; ' ; includePath += Sargv[0][2); } eise lf (arge > 1) arge—; argv++; includePath += ' ; ' ; includePath - «argv; ) eise ( usage (progname ) ; } break; case 'd' : lf (strcmp|argv[0], "-dump") == 0)// argument is part of "-I" includePath + = ';'; includePath + = Sargv [0] [2); } else lf (arge> 1) arge—; argv ++; includePath + = ';'; includePath - « argv; ) ise (usage (progname);} break; case 'd': lf (strcmp | argv [0], "-dump") == 0)
( doDump = true; ) break; case 'D': lf (argv[0] [2] '= 0) ((doDump = true;) break; case 'D': lf (argv [0] [2] '= 0) (
// argument is part of "-D" definitions += ';'; definitions += sargv|0][2);// argument is part of "-D" definitions + = ';'; definitions + = sargv | 0] [2);
} eise lf (arge > 1) (} ice lf (arge> 1) (
// argument follows "-D" arge—; argv++; definitions += ';'; definitions = *argv; } eise ( usage (progname ) ; } break; case ' t ' : lf (strcmp(*argv, "-traceParse" ) == 0) { doTraceParse = true;// argument follows "-D" arge—; argv ++; definitions + = ';'; definitions = * argv; } eise (usage (progname);} break; case 't': lf (strcmp (* argv, "-traceParse") == 0) {doTraceParse = true;
) eise lf (stremp (*argv, "-tracelnclude" ) == 0) ( doTraeelnclude = true; ) eise { usage (progname) ;) else lf (stremp (* argv, "-tracelnclude") == 0) (doTraeelnclude = true;) else {usage (progname);
} break; default: usage (progname ) ; break;} break; default: usage (progname); break;
) ) eise ()) ice (
// must be the input filename if (mputFile != stdin)// must be the input filename if (mputFile! = stdin)
((
// already have one usage (progname) ; )// already have one usage (progname); )
FILE *fp = fopen(*argv, "r"); lf (fp — NULL)FILE * fp = fopen (* argv, "r"); lf (fp - ZERO)
( fpnntf ( stderr, "%s : cannot open %s for ιnput\n" , progname, *argv) ; exιt ( O ) ;(fpnntf (stderr, "% s: cannot open% s for ιnput \ n", progname, * argv); exιt (O);
) putFile = fp;) putFile = fp;
} arge—; argv++; }} arge—; argv ++; }
//printf ("*s\n%s\n%s\n", includePath, definitions, mputFile) ; // Create input stream, lexer DLGFllelnput mput ( putFile) ; DLGLexer Scanner (Sinput) ; FastToken tok; Scanner. setToken(stok) ;// printf ("* s \ n% s \ n% s \ n", includePath, definitions, mputFile); // Create input stream, lexer DLGF l lelnput mput (putFile); DLGLexer scanner (Sinput); FastToken tok; Scanner. setToken (stok);
// Create preprocessor parser. Note that the preprocessor parser has // a built- token buffer in the form of an put Stack.// Create preprocessor parser. Note that the preprocessor parser has // a built-token buffer in the form of an put stack.
Buf eredCPreParser preprocessor (Sscanner) ; preprocessor . mit ( ) ;Buf eredCPreParser preprocessor (Sscanner); preprocessor. With ( ) ;
// set include path and defines directly for debugging if ( includePath. lengthO ~ 0)// set include path and defines directly for debugging if (includePath. lengthO ~ 0)
( includePath = "c: \\devstudιo\\vc\\ιnclude; \\msdev\\devstudιo\\vc\\mfc\\ιnclude" ; if (defimt ons . length l ) == 0 )(includePath = "c: \\ devstudιo \\ vc \\ ιnclude; \\ msdev \\ devstudιo \\ vc \\ mfc \\ ιnclude"; if (defimt ons. length l) == 0)
< definitions =<definitions =
" cplusplus; " " DATE =\"date\";""cplusplus;" "DATE = \" date \ ";"
" FILE =\"fιlename\";""FILE = \" fιlename \ ";"
" LINE =1 ; ""LINE = 1;"
" TIME =\"tιme\";""TIME = \" tιme \ ";"
" TIMESTAMP =\"tιmestamp\";' "_M_IX86=400;""TIMESTAMP = \" tιmestamp \ "; ' "_M_IX86 = 400;"
"_MSC_VER=1100;" "_WIN32;""_MSC_VER = 1100;" "_WIN32;"
"_INTEGRAL_MAX_BITS=64" ; }"_INTEGRAL_MAX_BITS = 64"; }
// Set preprocessor options preprocessor. SetIncludePath ( includePath ) ; preprocessor. SetDefinitions (definitions) ; // Set options in parser to make it act Standard with MS Extensions preprocessor. SetOption(CPreParserImp: :OptMSExtensιons, true) ; preprocessor. SetOption (CPreParserlmp: :OptBool, true) ; preprocessor. SetOption (CPreParserlmp: :OptWCharT, true) ; preprocessor. SetOption (CPreParserlmp: :OptPragmas, true) ; preprocessor. SetOption!CPreParserlmp: :OptExpandPragmas, true); preprocessor. SetOption (CPreParserlmp: :OptTrackInclude, doTraeelnclude) ;// Set preprocessor options preprocessor. SetIncludePath (includePath); preprocessor. SetDefinitions (definitions); // Set options in parser to make it act Standard with MS Extensions preprocessor. SetOption (CPreParserImp:: OptMSExtensιons, true); preprocessor. SetOption (CPreParserlmp:: OptBool, true); preprocessor. SetOption (CPreParserlmp:: OptWCharT, true); preprocessor. SetOption (CPreParserlmp:: OptPragmas, true); preprocessor. SetOption! CPreParserlmp:: OptExpandPragmas, true); preprocessor. SetOption (CPreParserlmp:: OptTrackInclude, doTraeelnclude);
// Buffer to störe tokens Output by preprocessor CPreToCPPBu fer pιpe2 ( Spreprocessor ) ;// Buffer to störe tokens Output by preprocessor CPreToCPPBu fer pιpe2 (Spreprocessor);
// Connect preprocessor to second token buffer so that the// Connect preprocessor to second token buffer so that the
// preprocessor can unilaterally squirt new tokens into the buffer preprocessor. SetBu er ( pιpe2) ; // Token buffer for the usual backtrack ng, etc.// preprocessor can unilaterally squirt new tokens into the buffer preprocessor. SetBu er (pιpe2); // Token buffer for the usual backtrack ng, etc.
JLTokenBuffer pιpe3 (Spιpe2, CPPParserSym: :ConstLLK) ;JLTokenBuffer pιpe3 (Spιpe2, CPPParserSym:: ConstLLK);
// Create the C++ parser CPPParserSym parser ( pιpe3) ;// Create the C ++ parser CPPParserSym parser (pιpe3);
// Set parser options to look like MSVC++ parser. SetOption (CPPParserSym: :OptPragmaMSPackιng, true) parser. SetOption (CPPParserSym: :OptMSTypedefHack, true); //preprocessor.doTrace (doTraceParse) ; parser . doTrace (doTraceParse ) ;// Set parser options to look like MSVC ++ parser. SetOption (CPPParserSym:: OptPragmaMSPackιng, true) parser. SetOption (CPPParserSym:: OptMSTypedefHack, true); //preprocessor.doTrace (doTraceParse); parser. doTrace (doTraceParse);
// Process top-level rule parser. mit ( ) ;// Process top-level rule parser. With ( ) ;
KFGTokenListC Ll; parser. translatιon_unit (Ll ) ;KFGTokenListC Ll; parser. translatιon_unit (Ll);
// Close the input file stream if (mputFile '= stdin)// Close the input file stream if (mputFile '= stdin)
{ fclose ( mputFile ) ; }{fclose (mputFile); }
// For reporting memory usage // For reporting memory usage p = new char[100000]; long heap2 = (long) (void* )p; delete [] p; cout « "Approx heap usage before dump: " « (heap2 - heapl ) « endl; if (doDump)// For reporting memory usage // For reporting memory usage p = new char [100000]; long heap2 = (long) (void *) p; delete [] p; cout «" Approx heap usage before dump: "« (heap2 - heapl) «endl; if (doDump)
((
// Dump the scope hierarchy cout « "Dump of scope hierarchy" « endl; parser. DumpScopes ( ) ; cout « endl;// Dump the scope hierarchy cout «" Dump of scope hierarchy "« endl; parser. DumpScopes (); cout «endl;
// For reporting memory usage // For reporting memory usage p = new char[100000] ; long heap3 = (long) (void* )p; delete [] p; cout « "Approx heap usage after dump: " « (heap3 - heapl) « endl; Ll .KFGListeAusgeben ( ) ; //Ll .KFGTokenListToKFGList ( ) ;// For reporting memory usage // For reporting memory usage p = new char [100000]; long heap3 = (long) (void *) p; delete [] p; cout «" Approx heap usage after dump: "« (heap 3 - heapl) «endl; Ll .KFGListeAusgabe (); // Ll .KFGTokenListToKFGList ();
KFGListC L2;KFGListC L2;
//KFGListC: : iterator Iter; L2. TokenLιst2KFGLιst ( Ll ) ; L2. ListeAusgeben ( ) ;// KFGListC:: iterator Iter; L2. TokenLιst2KFGLιst (Ll); L2. Output List ();
SliceC Slice;SliceC Slice;
Slice . startBuildSlice (L2 ) ; //Slice. uιldTestGraph(L2); //cout « Slice; uwggraphC uwggraph; //uwggraph.buildlfTree (Slice) ; uwggraph. startBuildFT ( Slice) ; cout << uwggraph; return 0;Slice. startBuildSlice (L2); // Slice. uιldTestGraph (L2); // cout «slice; uwggraphC uwggraph; //uwggraph.buildlfTree (Slice); uwggraph. startBuildFT (Slice); cout << uwggraph; return 0;
) static void usage ( char* progname ) ( fprintf ( stderr,) static void usage (char * progname) (fprintf (stderr,
"usage: %s [-1 directories] [-D definitions] (-traceParse] [ -tracelnclude ] [-o ofile] |ιfιle]\n" " -I directories- semicolon-separated list of include dιrectoπes\n""usage:% s [-1 directories] [-D definitions] (-traceParse] [-tracelnclude] [-o ofile] | ιfιle] \ n" "-I directories- semicolon-separated list of include dιrectoπes \ n"
-D definitions: semicolon-separated list of definitions, lιke:\n" symbol1; symbol2=value2\n" -traceParse: output debugging ιnformatιon\n" -tracelnclude: Output trace of include stack\n" " -dump: dump type and scope hιerarchy\n"-D definitions: semicolon-separated list of definitions, lιke: \ n "symbol1; symbol2 = value2 \ n" -traceParse: output debugging ιnformatιon \ n "-tracelnclude: Output trace of include stack \ n" "-dump: dump type and scope harcharchy \ n "
" ifile: name of mput file (otherwise it uses stdιn)\n", progname ); exιt(l); )"ifile: name of mput file (otherwise it uses stdιn) \ n", progname); exιt (l); )
«include <ιostream> »include <ιterator> «include <algorιthm> «include <fstream> «include "uwggraph. h" using namespace std;«Include <ιostream> "Include <ιterator>" include <algorιthm>"include<fstream>" include "uwggraph. H" using namespace std;
SliceC: : iterator uwggraphC: : fmdOutputNode (SliceC s Sl) { t dummy - 0; SliceC: : iterator SLl - Sl.begmO;SliceC:: iterator uwggraphC:: fmdOutputNode (SliceC s Sl) {t dummy - 0; SliceC:: iterator SLl - Sl.begmO;
SliceC: : iterator HELP = Sl.beginO; while ((SLl != Sl.endO) SS (dummy != 1)) ( if I (*SL1) .first. getKFGNodeType!) ~ OP ) HELP = SLl; dummy = 1;SliceC:: iterator HELP = Sl.beginO; while ((SLl! = Sl.endO) SS (dummy! = 1)) (if I (* SL1) .first. getKFGNodeType!) ~ OP) HELP = SLl; dummy = 1;
}}
SLl ++; } return HELP; }SLl ++; } return HELP; }
void uwggraphC: :startBuιldFT (SliceC S Sl) ( t posl - 0; int Posil = 0; mt SliceNr = 0; t LineNr = 0; int inLoop = 0; SlιceAusgeben(Sl) ; char NodeText (128] ; char BemerkungllOOO] ;void uwggraphC:: startBuιldFT (SliceC S Sl) (t posl - 0; int Posil = 0; mt SliceNr = 0; t LineNr = 0; int inLoop = 0; SlιceExit (Sl); char NodeText (128]; char remarkllOOO] ;
SliceC: : iterator SLl = f dOutputNode ( Sl ) ; SliceNr = (»SLl ) . first. getKnotenNummer ( ) ; LineNr = (»SLl ). first. getLineN O ; sprintf (NodeText, "Op%d", SliceNr); strcpy(Bemerkung, SLl->fιrst.getCodeLιne( ) ) ; //sprintf (Bemerkung, "Line %d", LineNr) ;SliceC:: iterator SLl = f dOutputNode (Sl); SliceNr = ( » SLl). first. getNodeNumber (); LineNr = ( » SLl). first. getLineN O; sprintf (NodeText, "Op% d", SliceNr); strcpy (remark, SLl-> fιrst.getCodeLιne ()); // sprintf (remark, "Line% d", LineNr);
SliceC: :Nachfolger: :ιterator BEGIN = (»SLl ) .second.beginl ) ; SliceC: :Nachfolger: :ιterator END » («SLl ) .second. end () ; while (BEGIN '= END) ( lf (BEGIN->second == KFK) ( uwgknotenC hknotenl (EFFECT, SliceNr, NodeText, Bemerkung) ; Posil = insert (hknotenl ) ; SliceC: :ιterator SLPUSE = findLastPUse (Sl, SliceNr);SliceC:: Successor:: ιterator BEGIN = ( » SLl) .second.beginl); SliceC:: Successor:: ιterator END »( « SLl) .second. end (); while (BEGIN '= END) (lf (BEGIN-> second == KFK) (uwgknotenC hknotenl (EFFECT, SliceNr, NodeText, remark); Posil = insert (hknotenl); SliceC:: ιterator SLPUSE = findLastPUse (Sl, SliceNr) ;
CheekLoopOrCondlSl, SLPUSE, SLl, Posil); mLoop = 1; BEGIN++; } eise (CheekLoopOrCondlSl, SLPUSE, SLl, Posil); mLoop = 1; BEGIN ++; } ice (
BEGIN++; ) } if (inLoop == 0) { uwgknotenC hknotenl (EFFECT, SliceNr,NodeText, Bemerkung) ; uwgknotenC hknoten2 (OR, "OR" ) ; insert (hknotenl, hknoten2, 0) ; n3 (CAUSE, SliceNr, NodeText, Bemerkung) ; knoten3, 0) ; ISl, SliceNr, posl); } check ( ) ; ' void uwggraphC: : checkLoopOrCond (SliceC S Sl, SliceC: : iterator SLPUSE, SliceC: : iterator SLORIG, t Posl) { int PosRet = 0; switch ( SLPUSE->fιrst. getKFGNodeType! ) ) ( case IFC:BEGIN ++; )} if (inLoop == 0) {uwgknotenC hknotenl (EFFECT, SliceNr, NodeText, remark); uwgknotenC hknoten2 (OR, "OR"); insert (hknotenl, hknoten2, 0); n3 (CAUSE, SliceNr, NodeText, remark); nodes3, 0); ISl, SliceNr, posl); } check (); 'void uwggraphC:: checkLoopOrCond (SliceC S Sl, SliceC:: iterator SLPUSE, SliceC:: iterator SLORIG, t Posl) {int PosRet = 0; switch (SLPUSE-> fιrst. getKFGNodeType!)) (case IFC:
PosRet = buildlnIfTreelSl, SLPUSE, SLORIG, Posl); //cout « "Testla: " « SLHELP->fιrst .getKnotenNummer ( ) « endl; break; case LC: buildInLoopTree (Sl, Posl, SLPUSE, SLORIG);PosRet = buildlnIfTreelSl, SLPUSE, SLORIG, Posl); // cout «" Testla: "« SLHELP-> fιrst .getKnotenNummer () «endl; break; case LC: buildInLoopTree (Sl, Posl, SLPUSE, SLORIG);
//cout « "Testlb: " « SLHELP->fιrst .getKnotenNummer ( ) « endl; break; default: cout « "Ups" « endl;// cout «" Testlb: "« SLHELP-> fιrst .getKnotenNummer () «endl; break; default: cout «" Oops "« endl;
}}
void uwggraphC: :addFιrstNodesToFT(ΞlιceC S Sl, t KnotenNr, mt Posl) ( int helpNr = 0; t ret - 0; mt pos - 0; int KnotenNrl = 0; int LineNrl = 0; char NodeText [128] ; char Bemerkung [1000];void uwggraphC:: addFιrstNodesToFT (ΞlιceC S Sl, t NodenNr, mt Posl) (int helpNr = 0; t ret - 0; mt pos - 0; int nodeNrl = 0; int LineNrl = 0; char NodeText [128]; char note [1000];
SliceC: : iterator NODE ■> definelterator (Sl, KnotenNr); SliceC: :Naehfolger: :iterator BEGIN = NODE->second.begιn( ) ; SliceC: :Nachfolger: : iterator END = NODE->second.end ( ) ; while (BEGIN != END) { helpNr = BEGIN->fιrst;SliceC:: iterator NODE ■> definelterator (Sl, node number); SliceC:: Successor:: iterator BEGIN = NODE-> second.begιn (); SliceC:: Successor:: iterator END = NODE-> second.end (); while (BEGIN! = END) {helpNr = BEGIN-> first;
KnotenNrl = Sl [helpNr] . first. getKnotenNummer () ; SliceC: : iterator N0DE1 = definelterator (Sl, KnotenNrl ) ; lf (NODEl->fιrst.getLevel() > 1) (NodeNrl = Sl [helpNr]. first. getNodeNumber (); SliceC:: iterator N0DE1 = definelterator (Sl, nodesNrl); lf (NODEl-> fιrst.getLevel ()> 1) (
SliceC: :ιterator PUSE = findLastPUse (Sl, KnotenNrl); switch ( PUSE->fιrst. getKFGNodeType () ) ( case IFC: ret = buildlnIfTreelSl, PUSE, NODE1, Posl); break; case LC: buildInLoopTree (Sl, Posl, PUSE, NODE1 ) ; break; default: cout « "Something is wrong'" « endl; } ) eise (SliceC:: ιterator PUSE = findLastPUse (Sl, nodesNrl); switch (PUSE-> fιrst. getKFGNodeType ()) (case IFC: ret = buildlnIfTreelSl, PUSE, NODE1, Posl); break; case LC: buildInLoopTree (Sl, Posl, PUSE, NODE1); break; default: cout «" Something is wrong '"« endl; }) ice (
LineNrl = Sl [helpNr] . first. getLineNr () ; sprintf (NodeText, "Op%d", KnotenNrl ) ; //sprintf (Bemerkung, "Line %d", LineNrl) ; strcpy!Bemerkung, Sl (helpNr) . first. getCodeLine ( ) ) ; uwgknotenC hknotenl (CAUSE, KnotenNrl, NodeText, Bemerkung) ; pos = insert (hknotenl ) ; verbmdeEcken (Posl,pos, 0) ; addFirstNodesToFTISl, KnotenNrl, Posl); }LineNrl = Sl [helpNr]. first. getLineNr (); sprintf (NodeText, "Op% d", nodesNrl); // sprintf (note, "Line% d", LineNrl); strcpy! remark, Sl (helpNr). first. getCodeLine ()); uwgknotenC hknotenl (CAUSE, nodesNrl, NodeText, remark); pos = insert (hknotenl); verbmdeEcken (Posl, pos, 0); addFirstNodesToFTISl, nodesNrl, Posl); }
BEGIN++;BEGIN ++;
SliceC: :ιterator uwggraphC: : findLastPUse (SliceC S Sl, int SliceNr) ( int helpNrl = 0; int SliceNrl = 0; SliceC: :ιterator SLl = definelterator (Sl, SliceNr);SliceC:: ιterator uwggraphC:: findLastPUse (SliceC S Sl, int SliceNr) (int helpNrl = 0; int SliceNrl = 0; SliceC:: ιterator SLl = definelterator (Sl, SliceNr);
SliceC: :ιterator SLHELP = SLl;SliceC:: ιterator SLHELP = SLl;
SliceC: :Nachfolger: : iterator BEGIN = («SLl ) .second. eginl ) ; SliceC: :Nachfolger: :ιterator END = («SLl ) .second. endl ) ; while (BEGIN '= END) ( if (BEGIN->second == KFK) ( helpNrl = BEGIN->fιrst;SliceC:: Successor:: iterator BEGIN = ( « SLl) .second. eginl); SliceC:: Successor:: ιterator END = ( « SLl) .second. endl); while (BEGIN '= END) (if (BEGIN-> second == KFK) (helpNrl = BEGIN->fιrst;
SliceNrl = Sl [helpNrl ]. first .getKnotenNummer () ;SliceNrl = Sl [helpNrl]. first .getNodeNumber ();
SLHELP = defιneIterator(Sl, SliceNrl); SLHELP = findLastPUse (Sl, SliceNrl);SLHELP = defιneIterator (Sl, SliceNrl); SLHELP = findLastPUse (Sl, SliceNrl);
BEGIN++; } return SLHELP;BEGIN ++; } return SLHELP;
SliceC: :ιterator uwggraphC: : fιndLastPUse2 (SliceC S Sl, int SliceNr, int RefNr) ( mt helpNrl = 0; lnt SliceNrl = 0; SliceC: :ιterator SLRETURN = definelterator (Sl, SliceNr);SliceC:: ιterator uwggraphC:: fιndLastPUse2 (SliceC S Sl, int SliceNr, int RefNr) (mt helpNrl = 0; lnt SliceNrl = 0; SliceC:: ιterator SLRETURN = definelterator (Sl, SliceNr);
SliceC: :ιterator SLHELP = SLRETURN;SliceC:: ιterator SLHELP = SLRETURN;
SliceC: :Nachfolger: : iterator BEGIN = SLRETURN->second.begιn ( ) ; SliceC: :Nachfolger: .iterator END = SLRETURN->second. end ( ) ; while (BEGIN != END) ( lf (BEGIN->second == KFK) ( helpNrl = BEGIN->fιrst;SliceC:: Successor:: iterator BEGIN = SLRETURN-> second.begιn (); SliceC:: Successor: .iterator END = SLRETURN-> second. end (); while (BEGIN! = END) (lf (BEGIN-> second == KFK) (helpNrl = BEGIN->fιrst;
SliceNrl = Sl [helpNrl] .first. getKnotenNummer () ; SLHELP = definelterator (Sl, SliceNrl);SliceNrl = Sl [helpNrl] .first. getNodeNumber (); SLHELP = definelterator (Sl, SliceNrl);
SLHELP = fιndLastPUse2(Sl, SliceNrl, RefNr); lf ( SLHELP->fιrst. getKnotenNummer ( ) '= RefNr) (SLHELP = fιndLastPUse2 (Sl, SliceNrl, RefNr); lf (SLHELP-> fιrst. getKnotenNummer () '= RefNr) (
SLRETURN = SLHELP; } }SLRETURN = SLHELP; }}
BEGIN++;BEGIN ++;
} return SLRETURN;} return SLRETURN;
}}
SliceC: : iterator uwggraphC: :lookForNextPUse (SliceC S Sl, SliceC: : iterator SNODE, SliceC: :ιterator SLPUSE) ( int helpNrl - 0; int helpNr2 = 0; int helpNr3 = 0; int dummy = 0; int dummyl = 0; int KnotenNrl = 0; int KnotenNr2 = 0; int RefNr = SLPUSE->flrst. getKnotenNummer () ; SliceC: : iterator HELP = SNODE; SliceC: : iterator RETURN = SNODE; SliceC: :Nachfolger: :ιterator BEGIN1 « SNODE->second.beginl ) ;SliceC:: iterator uwggraphC:: lookForNextPUse (SliceC S Sl, SliceC:: iterator SNODE, SliceC:: ιterator SLPUSE) (int helpNrl - 0; int helpNr2 = 0; int helpNr 3 = 0; int dummy = 0; int dummyl = 0; int NodeNrl = 0; int NodeNo2 = 0; int RefNr = SLPUSE-> flrst. GetNodeNumber (); SliceC:: iterator HELP = SNODE; SliceC:: iterator RETURN = SNODE; SliceC:: successor:: ιterator BEGIN1 «SNODE ->second.beginl);
SliceC: :Nachfolger: :ιterator END1 = SNODE->second.end() ; while I (BEGIN1 '= END1 ) SS (dummy != 1))( helpNrl = BEGINl->first;SliceC:: Successor:: ιterator END1 = SNODE-> second.end (); while I (BEGIN1 '= END1) SS (dummy! = 1)) (helpNrl = BEGINl-> first;
SliceC: :Nachfolger: :ιterator BEGIN2 = Sl [helpNrl] .second. beginl ) ; SliceC: :Nachfolger: :ιterator END2 = Sl [helpNrl] -second. end () ; while ((BEGIN2 '= END2 ) SS (dummyl '= 1)1 ( if (BEGIN2->second == KFK) ( helpNr2 = BEGIN2->flrst; if (Sl [helpNr2] .first. etKnotenNummer ( ) '= RefNr) ( KnotenNrl = Sl |helpNr2] . first. getKnotenNummer () ;SliceC:: Successor:: ιterator BEGIN2 = Sl [helpNrl] .second. beginl); SliceC:: Successor:: ιterator END2 = Sl [helpNrl] -second. end (); while ((BEGIN2 '= END2) SS (dummyl' = 1) 1 (if (BEGIN2-> second == KFK) (helpNr2 = BEGIN2-> flrst; if (Sl [helpNr2] .first. etKnotenNummer () '= RefNr ) (NodeNrl = Sl | helpNr2]. First. GetNodeNumber ();
RETURN = definelterator (Sl, KnotenNrl); SliceC: :Nachfolger: :ιterator BEGIN3 = RETURN-RETURN = definelterator (Sl, nodesNrl); SliceC:: Successor:: ιterator BEGIN3 = RETURN-
>second.begιn ( ) ;> second.begιn ();
SliceC: :Nachfolger: :ιterator END3 = RETURN- >second . end ( ) ; whlle (BEGIN3 '= END3) ( lf (BEGIN3->second == KFK) ( helpNr3 = BEGIN3->flrst; lf (Sl [helpNr3] . first. getKnotenNummer ( ) •- RefNr) {SliceC:: Successor:: ιterator END3 = RETURN-> second. end (); select (BEGIN3 '= END 3 ) (lf (BEGIN3-> second == KFK) (helpNr3 = BEGIN3->flrst; lf (Sl [helpNr3]. first. getKotenNummer () • - RefNr) {
KnotenNr2 =NodeNo2 =
Sl [helpNr3] . first .getKnotenNummer ( ) ;Sl [helpNr3]. first .getNodeNumber ();
RETURN = fιndLastPUse2(Sl, Kno- tenNr2, RefNr);RETURN = fιndLastPUse2 (Sl, NodeNr2, RefNr);
BEGIN3++; } dummyl = 1 ; dummy = 1;BEGIN3 ++; } dummyl = 1; dummy = 1;
) eise {) ice {
KnotenNrl = Sl [helpNrl ]. first. getKnotenNummer () ; HELP = definelterator (Sl, KnotenNrl); RETURN = lookForNextPUse(Ξl, HELP, SLPUSE);NodeNrl = Sl [helpNrl]. first. getNodeNumber (); HELP = definelterator (Sl, nodesNrl); RETURN = lookForNextPUse (Ξl, HELP, SLPUSE);
BEGIN2++; BEGIN1++;BEGIN2 ++; BEGIN1 ++;
} return RETURN;} return RETURN;
SliceC: : iterator uwggraphC: : returnCondNode (SliceC S Sl, int SliceNr) int helpNr = 0; mt dummy = 0; mt dummy2 = 0; int SlιceNr2 = 0;SliceC:: iterator uwggraphC:: returnCondNode (SliceC S Sl, int SliceNr) int helpNr = 0; mt dummy = 0; mt dummy2 = 0; int SlιceNr2 = 0;
SliceC: : iterator SLl = definelterator |S1, SliceNr); SliceC: : iterator HELP = SLl;SliceC:: iterator SLl = definelterator | S1, SliceNr); SliceC:: iterator HELP = SLl;
SliceC: :Nachfolger:: iterator BEGIN = (*SL1) .second.beginl ) ; SliceC: :Nachfolger: : iterator END = (»SLl ) .second. end( ); while ((BEGIN ι= END) SS (dummy != 1)) { helpNr = BEGIN->first; SliceNr = Sl [helpNr] . first. getKnotenNummer () ;SliceC:: successor :: iterator BEGIN = (* SL1) .second.beginl); SliceC:: Successor:: iterator END = ( » SLl) .second. end (); while ((BEGIN ι = END) SS (dummy! = 1)) {helpNr = BEGIN->first; SliceNr = Sl [helpNr]. first. getNodeNumber ();
HELP = definelteratorlSl, SliceNr);HELP = definelteratorlSl, SliceNr);
SliceC: :Nachfolger: :ιterator BEGIN2 = (»HELP) .second. beginl ) ; SliceC: :Nachfolger: :ιterator END2 = (»HELP) .second. endl ) ; while ( (BEGIN2 != END2 ) SS (dummy2 != D) ( if ( (»BEGIN2) .second == KFK) ( helpNr = (»BEGIN) . first;SliceC:: Successor:: ιterator BEGIN2 = ( » HELP) .second. beginl); SliceC:: Successor:: ιterator END2 = ( » HELP) .second. endl); while ((BEGIN2! = END2) SS (dummy2! = D) (if (( » BEGIN2) .second == KFK) (helpNr = ( » BEGIN). first;
SlιceNr2 = Sl [helpNr] . first .getKnotenNummer () ; HELP = definelteratorlSl, SlιceNr2); dummy2 = 1; dummy = 1;SlιceNr2 = Sl [helpNr]. first .getNodeNumber (); HELP = definelteratorlSl, SlιceNr2); dummy2 = 1; dummy = 1;
}}
BEGIN2++; } BEGIN++; return HELP;BEGIN2 ++; } BEGIN ++; return HELP;
//Funktion untersucht, ob zwei Kontrollstrukturen geschachtelt sind oder nicht. int uwggraphC: :checkPUsesl (SliceC S Sl, SliceC: : iterator SLPUSEREF, SliceC: : iterator SLPUSE) ( int helpreturn ■= 0; int KnotenNummerRef - 0; int helpNrl = 0; int KnotenNrl = 0;// Function examines whether two control structures are nested or not. int uwggraphC:: checkPUsesl (SliceC S Sl, SliceC:: iterator SLPUSEREF, SliceC:: iterator SLPUSE) (int helpreturn ■ = 0; int nodeNumberRef - 0; int helpNrl = 0; int nodeNrl = 0;
KnotenNummerRef = SLPUSE->first. getKnotenNummer () ; SliceC: :Nachfolger: :ιterator BEGIN1 = SLPUSEREF->second.beginl ) ; SliceC: :Nachfolger: .-iterator END1 = SLPUSEREF->second.end() ; while (BEGIN1 != END1 ) ( lf (BEGINl->second == KFK) ( helpNrl = BEGINl->fιrst;NodeNumberRef = SLPUSE-> first. getNodeNumber (); SliceC:: Successor:: ιterator BEGIN1 = SLPUSEREF-> second.beginl); SliceC:: Successor:.-Iterator END1 = SLPUSEREF-> second.end (); while (BEGIN1! = END1) (lf (BEGINl-> second == KFK) (helpNrl = BEGINl-> fιrst;
KnotenNrl = Sl [helpNrl] . first. getKnotenNummer () ; if (KnotenNrl == KnotenNummerRef) ( helpreturn = 1;NodeNrl = Sl [helpNrl]. first. getNodeNumber (); if (nodeNrl == nodeNumberRef) (helpreturn = 1;
} eise (} ice (
SLPUSEREF = de inelterator ( Sl, KnotenNrl ) ; helpreturn = checkPUsesl (Sl, SLPUSEREF, SLPUSE) ;SLPUSEREF = de inelterator (Sl, nodesNrl); helpreturn = checkPUsesl (Sl, SLPUSEREF, SLPUSE);
))
BEGIN1++; } return helpreturn;BEGIN1 ++; } return helpreturn;
t uwggraphC: :checkPUses2 (SliceC S Sl, SliceC: : iterator SLPUSEREF, SliceC: :ιterator SLPUSE) { mt helpreturn = 0; mt KnotenNummerRef = 0; int helpNrl = 0; int KnotenNrl = 0; KnotenNummerRef = SLPUSEREF->first. getKnotenNummer () ;t uwggraphC:: checkPUses2 (SliceC S Sl, SliceC:: iterator SLPUSEREF, SliceC:: ιterator SLPUSE) {mt helpreturn = 0; mt NodeNumberRef = 0; int helpNrl = 0; int nodeNrl = 0; NodeNumberRef = SLPUSEREF-> first. getNodeNumber ();
SliceC: :Nachfolger: : iterator BEGIN1 = SLPUSE->second.begιn ( ) ; SliceC: :Nachfolger: : iterator END1 = SLPUΞE->second.end() ; while (BEGIN1 '= END1 ) ( if (BEGINl->second == KFK) { helpNrl = BEGINl->first;SliceC:: Successor:: iterator BEGIN1 = SLPUSE-> second.begιn (); SliceC:: Successor:: iterator END1 = SLPUΞE-> second.end (); while (BEGIN1 '= END1) (if (BEGINl-> second == KFK) {helpNrl = BEGINl-> first;
KnotenNrl = Sl [helpNrl] . first .getKnotenNummer I ) ; lf (KnotenNrl == KnotenNummerRef) ( helpreturn = 1; } eise (NodeNrl = Sl [helpNrl]. first .get node number I); lf (nodeNrl == nodeNumberRef) (helpreturn = 1;} else (
SLPUSE = definelterator (Sl, KnotenNrl); helpreturn = checkPUses2 (Sl, SLPUSEREF, SLPUSE ) ; }SLPUSE = definelterator (Sl, nodesNrl); helpreturn = checkPUses2 (Sl, SLPUSEREF, SLPUSE); }
BEGIN1++; } return helpreturn;BEGIN1 ++; } return helpreturn;
int uwggraphC: :buιldInIfTree (SliceC S Sl, SliceC: : iterator SLIF, SliceC: : iterator SLORIG, int posl) ( int pos2 = 0; int posIFOR = 0; int posIFDFOR - 0; int posIFKFOR - 0; int posIFDFORA2 - 0; char NodeText [128]; char Bemerkun [ 1000] ; int KnotenNr = SLIF->fιrst. getKnotenNummer () ; int LineNr = SLIF->fιrst.getLιneNr ( ) ; sprintf (Bemerkung, "Verzweigung (%d)", LineNr) ; strcpy (NodeText, SLIF->fιrst.getCodeLιne ( ) ) ; uwgknotenC hknotenl (OR,NodeText, Bemerkung) ; pos2 = insert (hknotenl ) ; posIFOR = sizel) - 1; verbmdeEckenlposl, pos2,0); sprintf (NodeText, "Verzweιgung_KF(%d) ", LineNr) ; uwgknotenC hknotenδ (OR,NodeText) ; posIFKFOR = inser (hknotenδ) ; verbιndeEcken(pos2, posIFKFOR, 0) ; buιld_IFKF_Part(Sl, posIFKFOR, SLIF); switch (SLORIG->flrst.getKnotenIdent( ) ) ( case THEN: { sprintf (NodeText, "Verzweιgung_DF_Alt.l (%d) ", LineNr) ; uwgknotenC hknoten2 (AND, NodeText ) ; insert (hknotenl , hknoten2, 0) ; sprint (Bemerkung, "Alt.1 (%d) ", LineNr) ; sprintf (NodeText, "Alt .1 ( %d ) " , LineNr ) ; uwgknotenC hknoten3 (CAUSE, NodeText, Bemerkung) ; insert Ihknoten2,hknoten3,0) ; sprintf (NodeText, "Alt. l(%d)", LineNr) ; uwgknotenC hknoten<J (OR,NodeText ) ; insert (hknoten2,hknoten4, 0) ; posIFDFOR « sιze() - 1; buιld_Al_Part(Ξl, posIFDFOR, SLIF, SLORIG);int uwggraphC:: buιldInIfTree (SliceC S Sl, SliceC:: iterator SLIF, SliceC:: iterator SLORIG, int posl) (int pos2 = 0; int posIFOR = 0; int posIFDFOR - 0; int posIFKFOR - 0; int posIFDFORA2 - 0 ; char NodeText [128]; char remark [1000]; int nodeNo = SLIF-> fιrst. getKnotenNummer (); int LineNr = SLIF-> fιrst.getLιneNr (); sprintf (remark, "branching (% d)", LineNr ); strcpy (NodeText, SLIF-> fιrst.getCodeLιne ()); uwgknotenC hknotenl (OR, NodeText, remark); pos2 = insert (hknotenl); posIFOR = sizel) - 1; verbmdeEckenlposl, pos2.0); sprintf (NodeText, "Verzweιgung_KF (% d)", LineNr); uwgknotenC hknotenδ (OR, NodeText); posIFKFOR = inser (hnodeδ); connecting corners (pos2, posIFKFOR, 0); buιld_IFKF_Part (Sl, posIFKFOR, SLIF); switch (SLORIG-> flrst.getKnotenIdent ()) (case THEN: {sprintf (NodeText, "Verzweιgung_DF_Alt.l (% d)", LineNr); uwgknotenC hknoten2 (AND, NodeText); insert (hknotenl, hknoten2, 0); sprint (remark, "Alt.1 (% d)", LineNr); sprintf (NodeText, "Alt .1 (% d)", LineNr); uwgknotenC hknoten3 (CAUSE, NodeText, remark); insert Ihknoten2, hknoten3,0 ); sprintf (NodeText, "Alt. l (% d)", LineNr); uwgknotenC noden <J (OR, NodeText); insert (hknoten2, hknoten4, 0); posIFDFOR «sιze () - 1; buιld_Al_Part (Ξl, posIFDFOR, SLIF, SLORIG);
} break; case ELSE: sprintf (NodeText, "Verzweιgung_DF_Alt .2 (%d) ", LineNr) ; uwgknotenC hknoten2 (AND, NodeText ) ; insert (hknotenl, hknoten2, 0) ; sprintf (Bemerkung, "Alt.2 (%d) ", LineNr) ; sprintf (NodeText, "Alt .2 ( *d) " , LineNr ) ; uwgknotenC hknoten3(CAUSE,NodeText, Bemerkung) ; insert (hknoten2,hknoten3, 0) ; sprintf (NodeText, "Alt.2 (%d) ", LineNr) ; uwgknotenC hknoten4 (OR, NodeText ) ; insert (hknoten2,hknoten4, 0) ; posIFDFORA2 = sizeO - 1; build_Al_Part (Sl, posIFDFORA2, SLIF, SLORIG);} break; case ELSE: sprintf (NodeText, "Verzweιgung_DF_Alt .2 (% d)", LineNr); uwgknotenC hknoten2 (AND, NodeText); insert (hknotenl, hknoten2, 0); sprintf (remark, "Alt.2 (% d)", LineNr); sprintf (NodeText, "Alt .2 (* d)", LineNr); uwgknotenC hknoten3 (CAUSE, NodeText, remark); insert (hnode2, hnode3, 0); sprintf (NodeText, "Alt.2 (% d)", LineNr); uwgknotenC hknoten4 (OR, NodeText); insert (hknoten2, hknoten4, 0); posIFDFORA2 = sizeO - 1; build_Al_Part (Sl, posIFDFORA2, SLIF, SLORIG);
} break; default: cout « "Autsch1'1" « endl; return posIFDFOR;} break; default: cout «" Ouch 1 ' 1 "« endl; return posIFDFOR;
void uwggraphC: :buιld_Al_Part (SliceC s Sl, int posIFDFOR, SliceC: : iterator SLIF, SliceC: : iterator SLNODE) ( int posO = 0; int dummy = 0; int checkNr = 1; int checkPUse = 1; int helpNrl = 0; int helpNr2 = 0; mt KnotenNrO = 0; t KnotenNrl = 0; t KnotenNr2 = 0; int LineNrO » 0; int LineNrl = 0; char NodeTextO [128]; char BemerkungO [ 1000] ;void uwggraphC:: buιld_Al_Part (SliceC s Sl, int posIFDFOR, SliceC:: iterator SLIF, SliceC:: iterator SLNODE) (int posO = 0; int dummy = 0; int checkNr = 1; int checkPUse = 1; int helpNrl = 0; int helpNr2 = 0; with node number = 0; t node NR = 0; t node number 2 = 0; int LineNrO »0; int LineNrl = 0; char NodeTextO [128]; char remark O [1000];
KnotenNrO = SLNODE->first. getKnotenNummer () ;NodeNo = SLNODE-> first. getNodeNumber ();
LineNrO = SLNODE->fιrst.getLineNr() ; sprintf (NodeTextO, "Op%d", KnotenNrO);LineNrO = SLNODE-> fιrst.getLineNr (); sprintf (NodeTextO, "Op% d", nodeNoO);
//sprintf (BemerkungO, "Line %d", LineNrO) ; strcpy(Bemerkung0,SLNODE->fιrst.getCodeLιne( ) ) ; uwgknotenC hknotenO (CAUSE, KnotenNrO, NodeTextO, BemerkungO) ; posO = insert (hknotenO) ; verb deEcken (posIFDFOR,posO, 0) ;// sprintf (remarkO, "Line% d", LineNrO); strcpy (Comment0, SLNODE-> fιrst.getCodeLιne ()); uwgknotenC hknotenO (CAUSE, NodeNo, NodeTextO, remarkO); posO = insert (hknotenO); verb deEcken (posIFDFOR, posO, 0);
SliceC: :Nachfolger: : iterator BEGIN0 = SLNODE->second.begιn() ;SliceC:: Successor:: iterator BEGIN0 = SLNODE-> second.begιn ();
SliceC: :Nachfolger: : iterator END0 = SLNODE->second.end( ) ; while (BEGINO != END0) ( lf (BEGIN0->second == DFK) ( helpNrl = BEGIN0->first;SliceC:: Successor:: iterator END0 = SLNODE-> second.end (); while (BEGINO! = END0) (lf (BEGIN0-> second == DFK) (helpNrl = BEGIN0-> first;
KnotenNrl = Sl [helpNrl] . first. getKnotenNummer () ;NodeNrl = Sl [helpNrl]. first. getNodeNumber ();
SLNODE = definelterator (Sl, KnotenNrl ) ; lf (KnotenNrl < KnotenNrO) (SLNODE = definelterator (Sl, nodesNrl); lf (nodeNrl <nodeNo) (
SliceC: :Nachfolger: : iterator BEGIN1 = SLNODE->second.begιn( ) ; SliceC: :Nachfolger: : iterator END1 = SLNODE->second.end() ; while (BEGIN1 ' = END1) ( lf (BEGINl->second == KFK) ( helpNr2 = BEGINl->first; KnotenNr2 =SliceC:: Successor:: iterator BEGIN1 = SLNODE-> second.begιn (); SliceC:: Successor:: iterator END1 = SLNODE-> second.end (); while (BEGIN1 '= END1) (lf (BEGINl-> second == KFK) (helpNr2 = BEGINl-> first; nodeNo2 =
Sl [helpNr2] . first. getKnotenNummer ( ) ;Sl [helpNr2]. first. getNodeNumber ();
SliceC: : iterator HELPPUSE = defmeltera- tor(Sl,KnotenNr2); checkNr = checkUWGNode (KnotenNr2) ; lf (SLIF->fιrst.getKnotenNummer() > KnotenNr2)SliceC:: iterator HELPPUSE = defmelterator (Sl, NodeNo2); checkNr = checkUWGNode (nodeNo2); lf (SLIF-> fιrst.getKnotenNummer ()> NodeNo2)
( checkPUse checkPU- sesl ( Sl , SLIF, HELPPUSE) ; else ( checkPUse = checkPU- ses2 ( Sl, SLIF, HELPPUSE ) ;(checkPUse checkPU- sesl (Sl, SLIF, HELPPUSE); else (checkPUse = checkPU- ses2 (Sl, SLIF, HELPPUSE);
} lf (KnotenNr2 != SLIF-> irst. getKnotenNummer () ) if (checkPUse == 0) ( dummy = 1; HELPPUSE = fmdOutmostPU- se ( Sl , HELPPUSE) ; switch (HELPPUSE-} lf (NodeNo2! = SLIF-> first getNodeNumber ()) if (checkPUse == 0) (dummy = 1; HELPPUSE = fmdOutmostPUse (Sl, HELPPUSE); switch (HELPPUSE-
>first. getKFGNodeType () ) ( case LC: buildInLoopTree (Sl, po- sIFDFOR, HELPPUSE, SLNODE) ; break; case IFC: ret = buιldInIfTree(Sl, HELPPUSE, SLNODE, posIFDFOR); break; default: cout « "Falscher Weg in AI' " « endl;> first. getKFGNodeType ()) (case LC: buildInLoopTree (Sl, posIFDFOR, HELPPUSE, SLNODE); break; case IFC: ret = buιldInIfTree (Sl, HELPPUSE, SLNODE, posIFDFOR); break; default: cout «" Wrong way in AI '"« Endl;
) eise ( lf (checkNr == 0) ( dummy = 1; HELPPUSE = findOutmost-) ice (lf (checkNr == 0) (dummy = 1; HELPPUSE = findOutmost-
PUse (Sl, HELPPUSE ) ; switch (HELPPUSE-PUse (Sl, HELPPUSE); switch (HELPPUSE-
>first. getKFGNodeType () ) ( case LC: buildInLoopTree (Sl, posIFDFOR, HELPPUΞE, SLNODE) break; case IFC: ret = buildlnlf-> first. getKFGNodeType ()) (case LC: buildInLoopTree (Sl, posIFDFOR, HELPPUΞE, SLNODE) break; case IFC: ret = buildlnlf-
Tree ( Ξl , HELPPUSE, SLNODE, posIFDFOR) ; break; default: cout « "FalscherTree (Ξl, HELPPUSE, SLNODE, posIFDFOR); break; default: cout «" Wrong
Weg! " « endl;Path! "« Endl;
}}
BEGIN1++;BEGIN1 ++;
} lf (dummy == 0) (} lf (dummy == 0) (
LineNrl = Sl [helpNrl] . first. getLineNrl ) ; sprintf (NodeTextO, "Op%d" , KnotenNrl ) ;LineNrl = Sl [helpNrl]. first. getLineNrl); sprintf (NodeTextO, "Op% d", nodesNrl);
//sprintf (BemerkungO, "Line %d", LineNrl) ; strcpy(Bemer ungO, Sl [helpNrl ] .first. etCodeLine () ) ; uwgknotenC hknotenl (CAUSE, KnotenNrl,NodeTextO,BemerkungO) ; posl = insert (hknotenl ) ; verbindeEcken (posIFDFOR, posl, 0) ; buιld_Al_Part(Sl, posIFDFOR, SLIF, SLNODE); }// sprintf (remarkO, "Line% d", LineNrl); strcpy (Bemer ungO, Sl [helpNrl] .first. etCodeLine ()); uwgknotenC hknotenl (CAUSE, nodesNrl, NodeTextO, remarkO); posl = insert (hknotenl); connect corners (posIFDFOR, posl, 0); buιld_Al_Part (Sl, posIFDFOR, SLIF, SLNODE); }
))
BEGIN0++; dummy = 0;BEGIN0 ++; dummy = 0;
void uwggraphC: :buιld_IFKF_Part (SliceC S Sl, int posKFOR, SliceC: : iterator SLPUSE) ( int posl = 0; int ret = 0; int dummy = 0; int checkNr = 1; int checkPUse = 1; int helpNrl = 0; int helpNr2 - 0; int KnotenNrO = 0; mt KnotenNrl = 0; int KnotenNr2 = 0; mt LineNrO = 0; int LineNrl = 0; char NodeText [ 128 ] ; char BemerkungllOOO] ;void uwggraphC:: buιld_IFKF_Part (SliceC S Sl, int posKFOR, SliceC:: iterator SLPUSE) (int posl = 0; int ret = 0; int dummy = 0; int checkNr = 1; int checkPUse = 1; int helpNrl = 0; int helpNr2 - 0; int NodeNo = 0; mt NodeNrl = 0; int NodeNo2 = 0; mt LineNrO = 0; int LineNrl = 0; char NodeText [128]; char notellOOO];
KnotenNrO = SLPUSE->fιrst. getKnotenNummer () ; LineNrO = SLPUSE-> ιrst.getLineNr () ; sprintf (NodeText, "Op%d", KnotenNrO ) ;NodeNo = SLPUSE-> first. getNodeNumber (); LineNrO = SLPUSE-> ιrst.getLineNr (); sprintf (NodeText, "Op% d", nodeNo);
//sprintf (Bemerkung, "Line %d", LineNrO) ; strcpy!Bemerkung, SLPUSE->flrst. getCodeLine! ) ) ; uwgknotenC hknotenl (CAUSE, KnotenNrO, NodeText, Bemerkung) ; posl = insert (hknotenl ) ; verbindeEcken (posKFOR, pos1,0) ;// sprintf (note, "Line% d", LineNrO); strcpy! remark, SLPUSE-> flrst. getCodeLine! )); uwgknotenC hknotenl (CAUSE, node number, node text, remark); posl = insert (hknotenl); connect corners (posKFOR, pos1,0);
SliceC: :Nachfolger: :ιterator BEGIN0 = SLPUSE->second.begιn( ) ; SliceC: :Nachfolger: :ιterator END0 = SLPUSE->second.end ( ) ; while (BEGIN0 '= ENDO) { lf (BEGIN0->second -» DFK) ( helpNrl = BEGIN0->fιrst;SliceC:: Successor:: ιterator BEGIN0 = SLPUSE-> second.begιn (); SliceC:: Successor:: ιterator END0 = SLPUSE-> second.end (); while (BEGIN0 '= ENDO) {lf (BEGIN0-> second - »DFK) (helpNrl = BEGIN0-> fιrst;
KnotenNrl = Sl [helpNrl] . first .getKnotenNummer () ; SliceC: :ιterator SLNODE = definelterator (Sl, KnotenNrl ) ; lf (KnotenNrl < KnotenNrO) (NodeNrl = Sl [helpNrl]. first .getNodeNumber (); SliceC:: ιterator SLNODE = definelterator (Sl, nodesNrl); lf (nodeNrl <nodeNo) (
SliceC: :Nachfolger: : iterator BEGIN1 = SLNODE->second.begin ( ) ; SliceC: :Nachfolger: :ιterator END1 = SLNODE->second. endl) ; while (BEGIN1 '= END1 ) ( lf (BEGINl->second == KFK) ( helpNr2 = BEGINl->first; KnotenNr2 = Sl[helpNr2] . first .getKnotenNummer I ) ;SliceC:: Successor:: iterator BEGIN1 = SLNODE-> second.begin (); SliceC:: Successor:: ιterator END1 = SLNODE-> second. endl); while (BEGIN1 '= END1) (lf (BEGINl-> second == KFK) (helpNr2 = BEGINl-> first; nodeNo2 = Sl [helpNr2]. first .getKnotenNummer I);
SliceC: :ιterator HELPPUSE = defineltera- tor (Sl,KnotenNr2) ; checkNr = checkUWGNode (KnotenNr2) ; if (SLPUSE->fιrst. getKnotenNummer! ) > Kno- tenNr2) ( checkPUse = checkPU- sesl (Sl, SLPUSE, HELPPUSE ) ; eise ( checkPUse = checkPU- ses2 (Sl, SLPUSE, HELPPUSE) ; lf (KnotenNr2 '= SLPUSE- >fιrst. getKnotenNumme () ) ( if (checkPUse == 0) ( dummy = 1; HELPPUSE = findOutmostPU- se (Sl, HELPPUSE ) ; switch (HELPPUSE-SliceC:: ιterator HELPPUSE = definelterator (Sl, nodeNo2); checkNr = checkUWGNode (nodeNo2); if ( SLPUSE-> fιrst. getKnotenNummer!)> NodenNr2) (checkPUse = checkPU- sesl (Sl, SLPUSE, HELPPUSE); ise (checkPUse = checkPU- ses2 (Sl, SLPUSE, HELPPUSE); lf (nodeNo2 '= SLPUSE-> fιrst. getKknotenNumme ()) (if (checkPUse == 0) (dummy = 1; HELPPUSE = findOutmostPU- se (Sl, HELPPUSE); switch (HELPPUSE-
>first. getKFGNodeType! ) ) ( case LC: buildInLoopTree (Sl, posKFOR, HELPPUSE, SLNODE); break; case IFC: ret = buildlnIfTreelSl,> first. getKFGNodeType! )) (case LC: buildInLoopTree (Sl, posKFOR, HELPPUSE, SLNODE); break; case IFC: ret = buildlnIfTreelSl,
HELPPUΞE, SLNODE, posKFOR); break; default: cout « "Falscher Weg inHELPPUΞE, SLNODE, posKFOR); break; default: cout «" Wrong way in
AI! " « endl; eise ( lf (checkNr == 0) ( dummy = 1; HELPPUSE = findOutmost-AI! "« Endl; eise (lf (checkNr == 0) (dummy = 1; HELPPUSE = findOutmost-
PUse (Sl, HELPPUSE ) ; switch (HELPPUSE-PUse (Sl, HELPPUSE); switch (HELPPUSE-
>first. getKFGNodeType! ) ) ( case LC: buildInLoopTree (Sl, posKFOR, HELPPUSE, SLNODE); break; case IFC: ret = buildlnlf- Tree(Sl, HELPPUSE, SLNODE, posKFOR); break; default: cout « "Falscher Weg' " « endl;> first. getKFGNodeType! )) (case LC: buildInLoopTree (Sl, posKFOR, HELPPUSE, SLNODE); break; case IFC: ret = buildlnlf- Tree (Sl, HELPPUSE, SLNODE, posKFOR); break; default: cout «" Wrong way '"« endl ;
BEGIN1++; l f (dummy == 0 ) (BEGIN1 ++; l f (dummy == 0) (
LineNrl = Sl [helpNrl] . first. getLmeNr () ; sprintf (NodeText, "Op%d" , KnotenNrl ) ; //sprintf (Bemerkung, "Line %d", LineNrl ) ; strcpy)Bemerkung, Sl [helpNrl] . first. getCodeLine ( ) ) ; uwgknotenC hknotenl (CAUSE, KnotenNrl,NodeText, Bemerkung) ; posl = insert (hknotenl ) ; verbindeEcken (posKFOR, posl, 0) ; buιld_IFKF_Part(Sl, posKFOR, SLNODE);LineNrl = Sl [helpNrl]. first. getLmeNr (); sprintf (NodeText, "Op% d", nodesNrl); // sprintf (note, "Line% d", LineNrl); strcpy) remark, Sl [helpNrl]. first. getCodeLine ()); uwgknotenC hknotenl (CAUSE, nodesNrl, NodeText, remark); posl = insert (hknotenl); connect corners (posKFOR, posl, 0); buιld_IFKF_Part (Sl, posKFOR, SLNODE);
BEGIN0++; dummy = 0;BEGIN0 ++; dummy = 0;
void uwggraphC: :buιldInLoopTree (SliceC s Sl, int Posl, SliceC: : iterator SLPUSE, SliceC: :ιterator SLNODE) ( mt posil = 0; int pos3 = 0; int posLOOPJCF = 0; int posOR_Dl = 0; t posOR_D2 - 0; t posANDJCF = 0; mt SliceNr = 0; int NodeNrD2 = 0; t KnotenNr = 0; t LineNr = 0;void uwggraphC:: buιldInLoopTree (SliceC s Sl, int Posl, SliceC:: iterator SLPUSE, SliceC:: ιterator SLNODE) (mt posil = 0; int pos3 = 0; int posLOOPJCF = 0; int posOR_Dl = 0; t posOR_D2 - 0 ; t posANDJCF = 0; mt SliceNr = 0; int NodeNrD2 = 0; t node number = 0; t LineNr = 0;
KnotenNr = SLPUSE->first. getKnotenNummer () ; LineNr = SLPUSE->fιrst.getLιneNr I ) ; char NodeText[128] ; char Bemerkung[1000] ; sprintf (Bemerkung, "Schleife (%d) ", KnotenNr) ; strcpy(NodeText,SLPUSE->fιrst. getCodeLine! ) ) ; uwgknotenC hknotenl (OR,NodeText, Bemerkung) ; posil = insert (hknotenl) ; verbindeEcken (Posl,posil, 0) ; sprintf (NodeText, "Schlei fe_DF_Durchl .1 ( %d)", LineNr) ; uwgknotenC hknoten2 (AND,NodeText) ; sprintf (NodeText, "Schleife_DF_Durchl . + ( %d) " , LineNr ) ; uwgknotenC hknoten3 (AND, NodeText ) ; pos3 = insert (hknoten3) ; verbindeEcken!posil,pos3,0) ; sprintf (NodeText, "Schleife_KF (%d )", LineNr ) ; uwgknotenC hknoten4 (OR, NodeText ) ; insert (hknotenl, hknoten2, 0) ; insert (hknotenl,hknoten4, 0) ; posLOOPJCF = sizel) - 1; sprintf (Bemerkung, "Durchl.l (%d) ", LineNr) ; sprintf (NodeText, "Durchl .1 ( %d ) " , LineNr ) ; uwgknotenC hknoten5 (CAUSE,NodeText, Bemerkung) ; sprintf (NodeText, "Durchl .1 ( %d ) " , LineNr ) ; uwgknotenC hknoten6 (OR, NodeText) ; insert (hknoten2,hknoten5, 0) ; insert (hknoten2,hknoten6, 0) ; posOR_Dl = size!) - 1; sprintf (Bemerkung, "Durchl . + ( *d ) " , LineNr ) ; sprintf (NodeText, "Durchl . + ( %d ) ", LineNr ) ; uwgknotenC hknoten7 (CAUSE, NodeText, Bemerkung) ; sprintf (NodeText, "Durchl. + (%d)", LineNr) ; uwgknotenC hknotenδ (OR,NodeText) ; insert (hknoten3,hknoten"7, 0) ; posOR_D2 = insert (hknotenβ) ; verbindeEcken (pos3, posOR_D2,0); sprintf (NodeText, "KF ( %d) " , LineNr ) ; uwgknotenC hknoten9 (AND, NodeText ) ; insert (hknoten4,hknoten9, 0) ; insert (hknoten3,hknoten5, 0) ; posANDJCF = sizeO - 1; msert (hknoten9,hknoten5,0) ;NodeNo = SLPUSE-> first. getNodeNumber (); LineNr = SLPUSE-> fιrst.getLιneNr I); char NodeText [128]; char remark [1000]; sprintf (note, "loop (% d)", node number); strcpy (NodeText, SLPUSE-> fιrst. getCodeLine!)); uwgknotenC hknotenl (OR, NodeText, remark); posil = insert (hknotenl); connect corners (Posl, posil, 0); sprintf (NodeText, "Schlei fe_DF_Durchl .1 (% d)", LineNr); uwgknotenC hknoten2 (AND, NodeText); sprintf (NodeText, "Loop_DF_Durchl. + (% d)", LineNr); uwgknotenC hknoten3 (AND, NodeText); pos3 = insert (hknoten3); connect corners! posil, pos3,0); sprintf (NodeText, "Loop_KF (% d)", LineNr); uwgknotenC hknoten4 (OR, NodeText); insert (hknotenl, hknoten2, 0); insert (hknotenl, hknoten4, 0); posLOOPJCF = sizel) - 1; sprintf (note, "Durchl.l (% d)", LineNr); sprintf (NodeText, "Durchl .1 (% d)", LineNr); uwgknotenC hknoten5 (CAUSE, NodeText, remark); sprintf (NodeText, "Durchl .1 (% d)", LineNr); uwgknotenC hknoten6 (OR, NodeText); insert (hknoten2, hknoten5, 0); insert (hknoten2, hknoten6, 0); posOR_Dl = size!) - 1; sprintf (remark, "Durchl. + (* d)", LineNr); sprintf (NodeText, "Durchl. + (% d)", LineNr); uwgknotenC hknoten7 (CAUSE, NodeText, remark); sprintf (NodeText, "Durchl. + (% d)", LineNr); uwgknotenC hknotenδ (OR, NodeText); insert (hknoten3, hknoten "7, 0); posOR_D2 = insert (hknotenβ); connectEcken (pos3, posOR_D2,0); sprintf (NodeText," KF (% d) ", LineNr); uwgknotenC hknoten9 (AND, NodeText); insert (hknoten4, hknoten9, 0); insert (hknoten3, hknoten5, 0); posANDJCF = sizeO - 1; msert (hknoten9, hknoten5,0);
NodeNrD2 = buιldIn_LoopKF_ANDPart (Sl, posANDJCF, SLPUSE); buιldIn_LoopKF_ORPart (Sl, posLOOFJCF, SLPUSE, NodeNrD2);NodeNrD2 = buιldIn_LoopKF_ANDPart (Sl, posANDJCF, SLPUSE); buιldIn_LoopKF_ORPart (Sl, posLOOFJCF, SLPUSE, NodeNrD2);
//buιldIn_D2_Part (Sl, posOR_D2, SLPUSE, SLNODE, NodeNrD2); buιldIn_Dl_Part (Sl, posOR_Dl, SLPUSE, SLNODE, NodeNrD2); buιldIn_D2_Part(Sl, posOR_D2, SLPUSE, SLNODE, NodeNrD2);// buιldIn_D2_Part (Sl, posOR_D2, SLPUSE, SLNODE, NodeNrD2); buιldIn_Dl_Part (Sl, posOR_Dl, SLPUSE, SLNODE, NodeNrD 2 ); buιldIn_D2_Part (Sl, posOR_D2, SLPUSE, SLNODE, NodeNrD2);
void uwggraphC: :buιldIn_Dl_Part (SliceC S Sl, int posOR_Dl, SliceC: : iterator SLPUSE, Sli¬ ceC: :ιterator SLNODE, int D2_RefNr) ( int posl ■= 0; int ret = 0; int KnotenNrl = 0; int LineNrl = 0;void uwggraphC:: buιldIn_Dl_Part (SliceC S Sl, int posOR_Dl, SliceC:: iterator SLPUSE, Sli ¬ ceC:: ιterator SLNODE, int D2_RefNr) (int posl ■ = 0; int ret = 0; int nodeNrl = 0; int LineNrl = 0;
SliceC: : iterator ITERl = fmd_Dl_Node (Sl, SLPUSE, SLNODE); SliceC: :ιterator HELP = ITERl; swιtch(ITERl->fιrst. getKFGNodeType! ) ) ( case IFC: HELP = fιnd_Dl_Node(Sl, ITERl, SLNODE); ret = buildlnIfTreelSl, ITERl, HELP,posOR_Dl); break; case LC:SliceC:: iterator ITERl = fmd_Dl_Node (Sl, SLPUSE, SLNODE); SliceC:: ιterator HELP = ITERl; swιtch (ITERl-> fιrst. getKFGNodeType!)) (case IFC: HELP = fιnd_Dl_Node (Sl, ITERl, SLNODE); ret = buildlnIfTreelSl, ITERl, HELP, posOR_Dl); break; case LC:
HELP = fιnd_Dl_Node(Ξl, ITERl, SLNODE); buildInLoopTree (Sl,posOR_Dl, ITERl, SLNODE) ; break; default: addAllDlNodes ( Sl , ITERl ,posOR_Dl , D2_Ref r ) ; , SliceC: :ιterator uwggraphC: : fιnd_Dl_Node (SliceC S Sl, SliceC: : iterator SLPUSE, SliceC: : iterator SLNODE) ( int helpNrl = 0; int helpNr2 = 0; mt dummyl = 0; int dummy∑ = 0; int KnotenNrRet = 0; int KnotenNrRetl = 0; int PUseNr = SLPUSE->fιrst. getKnotenNummer () ; int PUseLevel = SLPUSE->first.getLevel () ;HELP = fιnd_Dl_Node (Ξl, ITERl, SLNODE); buildInLoopTree (Sl, posOR_Dl, ITERl, SLNODE); break; default: addAllDlNodes (Sl, ITERl, posOR_Dl, D2_Ref r); . SliceC:: ιterator uwggraphC:: fιnd_Dl_Node (SliceC S Sl, SliceC:: iterator SLPUSE, SliceC:: iterator SLNODE) (int helpNrl = 0; int helpNr2 = 0; mt dummyl = 0; int dummy∑ = 0; int nodeNoRet = 0; int NodeNoRetl = 0; int PUseNo = SLPUSE-> first getNodeNumber (); int PUseLevel = SLPUSE-> first.getLevel ();
SliceC:: iterator RETURNITER = SLNODE; KnotenNrRetl = SLNODE->first. getKnotenNummer () ; lf (KnotenNrRetl -== (PUseNr + 1)) (SliceC :: iterator RETURNITER = SLNODE; NodeNoRetl = SLNODE-> first. getNodeNumber (); lf (NodeNoRetl - == (PUseNr + 1)) (
RETURNITER = definelterator (Sl, KnotenNrRetl ) ; dummyl « 1; dummy2 = 1;RETURNITER = definelterator (Sl, nodeNoRetl); stupid «1; dummy2 = 1;
}}
SliceC: :Nachfolger:: iterator BEGIN1 = ΞLNODE->second.beginl ) ; SliceC: :Nachfolger: :ιterator END1 = SLNODE->second.end( ) ; while ((BEGIN1 != END1 ) SS (dummyl != 1)) ( helpNrl = BEGINl->fιrst; lf ( (Sl[helpNrl) .first. getKnotenNummer ( ) > PUseNr) SS (SlfhelpNrl] .first. getLevel ( ) >= PUseLevel ) ) ( lf (Sl [helpNrl] . first. etLevel ( ) > PUseLevel) ( KnotenNrRetl = Sl [helpNrl ]. first .getKnotenNummer () ; lf (KnotenNrRetl == (PUseNr + 1)) {SliceC:: successor :: iterator BEGIN1 = ΞLNODE-> second.beginl); SliceC:: Successor:: ιterator END1 = SLNODE-> second.end (); while ((BEGIN1! = END1) SS (dummyl! = 1)) (helpNrl = BEGINl-> fιrst; lf ((Sl [helpNrl) .first. getKotenNummer ()> PUseNr) SS (SlfhelpNrl] .first. getLevel () > = PUseLevel)) (lf (Sl [helpNrl]. First. EtLevel ()> PUseLevel) (NodeNoRetl = Sl [helpNrl]. First .getNodeNumber (); lf (NodeNoRetl == (PUseNr + 1)) {
RETURNITER = definelterator ( Sl, KnotenNrRetl ) ; dummyl = 1; dummy2 = 1 ; }RETURNITER = definelterator (Sl, nodeNoRetl); dummyl = 1; dummy2 = 1; }
SliceC: :Nachfolger: : iterator BEGIN2 = Sl [helpNrl] .second.beginl ) ;SliceC:: Successor:: iterator BEGIN2 = Sl [helpNrl] .second.beginl);
SliceC: :Nachfolger: :ιterator END2 = Sl (helpNrl] .second. end( ) while ( (BEGIN2 '= END2 ) SS (dummy2 != 1)) ( lf (BEGIN2->second == KFK) ( helpNr2 = BEGIN2->first; KnotenNrRet = Sl [helpNr2] . first. getKnotenNummer ( ) ; if (KnotenNrRet != PUseNr) ( RETURNITER = definelterator ( Sl , KnotenNrRet ) ; dummyl = 1; dummy∑ = 1 ; } }SliceC:: Successor:: ιterator END2 = Sl (helpNrl] .second. End () while ((BEGIN 2 '= END2) SS (dummy2! = 1)) (lf (BEGIN2-> second == KFK) (helpNr2 = BEGIN2->first; NodeNoRet = Sl [helpNr2]. First. GetNodeNumber (); if (NodeNoRet! = PUseNr) (RETURNITER = definelterator (Sl, NodeNoRet); dummyl = 1; dummy∑ = 1;}}
BEGIN2++; } } eise ( KnotenNrRet = Sl [helpNrl] . first .getKnotenNummer () ;BEGIN2 ++; }} else (NodeNoRet = Sl [helpNrl]. first .getNodeNumber ();
RETURNITER = definelterator (Sl, KnotenNrRet ) ; dummyl = 1 ; } BEGIN1++;RETURNITER = definelterator (Sl, nodeNoRet); dummyl = 1; } BEGIN1 ++;
) lf ((RETURNITER == SLNODE) SS (dummyl == 0)) { BEGIN1 = SLNODE->second.beginl ); while (BEGIN1 '= END1 ) ( helpNrl = BEGINl->fιrst;) lf ((RETURNITER == SLNODE) SS (dummyl == 0)) {BEGIN1 = SLNODE-> second.beginl); while (BEGIN1 '= END1) (helpNrl = BEGINl-> fιrst;
KnotenNrRet = Sl [helpNrl] . first .getKnotenNummer () ; SliceC: : iterator SLNODE = definelterator (Sl, KnotenNrRet ) ; RETURNITER = fιnd_Dl_Node (Sl, SLPUSE, SLNODE); BEGIN1++; )NodeNoRet = Sl [helpNrl]. first .getNodeNumber (); SliceC:: iterator SLNODE = definelterator (Sl, nodeNoRet); RETURNITER = fιnd_Dl_Node (Sl, SLPUSE, SLNODE); BEGIN1 ++; )
} return RETURNITER; }} return RETURNITER; }
void uwggraphC: :buιldIn_D2_Part (SliceC S Sl, int posOR_D2, SliceC: : iterator SLPUSE, SliceC: : iterator SLNODE, mt KnotenNrD2) ( int helpNrl = 0; int helpNr2 = 0; int KnotenNrl = 0; t LineNrl = 0; t KnotenNrD2Ret - 0; int USEinD2KnotenNr ■= 0; char Bemerkungl [1000] ; char NodeTextl [128];void uwggraphC:: buιldIn_D2_Part (SliceC S Sl, int posOR_D2, SliceC:: iterator SLPUSE, SliceC:: iterator SLNODE, with node numberD2) ( int helpNrl = 0; int helpNr2 = 0; int nodeNrl = 0; t LineNrl = 0; t NodeNoD2Ret - 0; int USEinD2KnotenNr ■ = 0; char note [1000]; char NodeTextl [128];
SliceC: :ιterator D2_NODE = definelteratorlSl, KnotenNrD2); KnotenNrl = D2_NODE->first. getKnotenNummer I ) ; LineNrl - D2_N0DE->fιrst.getLιneNr I ) ; sprintf (NodeTextl , "Op%d" , KnotenNrl ) ;SliceC:: ιterator D2_NODE = definelteratorlSl, node number D2); NodeNrl = D2_NODE-> first. getKnotenNumber I); LineNrl - D2_N0DE-> fιrst.getLιneNr I); sprintf (NodeTextl, "Op% d", nodesNrl);
//sprintf (Bemerkungl, "Line %d", LineNrl) ; strcpy(Bemerkungl,D2_N0DE->first. getCodeLine! ) ) ; uwgknotenC hknotenl (CAUSE, KnotenNrl,NodeTextl, Bemerkungl ) ; posl = insert (hknotenl) ; verbindeEcken (posOR_D2,posl, 0) ;// sprintf (note, "Line% d", LineNrl); strcpy (remark, D2_N0DE-> first. getCodeLine!)); uwgknotenC hknotenl (CAUSE, nodesNrl, NodeTextl, remarkl); posl = insert (hknotenl); connectCorner (posOR_D2, posl, 0);
SliceC: :Nachfolger: :ιterator BEGIN1 = D2_NODE->second.begιn( ) ; SliceC: :Nachfolger: : iterator END1 = D2_NODE->second.end () ; while (BEGIN1 '= END1) ( lf (BEGINl->second == DFK) ( helpNrl = BEGINl->fιrst;SliceC:: Successor:: ιterator BEGIN1 = D2_NODE-> second.begιn (); SliceC:: Successor:: iterator END1 = D2_NODE-> second.end (); while (BEGIN1 '= END1) (lf (BEGINl-> second == DFK) (helpNrl = BEGINl-> fιrst;
KnotenNrl = Sl [helpNrl] . first .getKnotenNummer () ; LineNrl = Sl [helpNrl] . first .getLineNr () ; sprintf (NodeTextl, "Op%d", KnotenNrl) ; //sprintf (Bemerkungl, "Line %d", LineNrl) ; strcpy(Bemerkungl, Sl (helpNrl] . first. getCodeLine ( ) ) ; uwgknotenC hknoten2 (CAUSE, KnotenNrl, NodeTextl, Bemerkungl ) ; pos2 = insert (hknoten2) ; verbιndeEcken(posOR_D2,pos2,0) ;NodeNrl = Sl [helpNrl]. first .getNodeNumber (); LineNrl = Sl [helpNrl]. first .getLineNr (); sprintf (NodeTextl, "Op% d", nodesNrl); // sprintf (note, "Line% d", LineNrl); strcpy (remarkl, Sl (helpNrl]. first. getCodeLine ()); uwgknotenC hknoten2 (CAUSE, nodesNrl, NodeTextl, remarkl); pos2 = insert (hknoten2); connecting corners (posOR_D2, pos2,0);
SliceC: :Nachfolger: :ιterator BEGIN2 = Sl [helpNrl] .second.beginl ) ; SliceC: :Nachfolger: : iterator END2 = Sl [helpNrl] .second. end () ; while (BEGIN2 != END2 ) ( helpNr2 = BEGIN2->first; if ( (BEGIN2->second -= DFK) SS (Sl [helpNr2] .first. getKnotenNummer ( ) '= KnotenNrD2)) ( //SliceC: :ιterator SLNODE1 = definelterator (Sl, KnotenNrl ) ;SliceC:: Successor:: ιterator BEGIN2 = Sl [helpNrl] .second.beginl); SliceC:: Successor:: iterator END2 = Sl [helpNrl] .second. end (); while (BEGIN2! = END2) (helpNr2 = BEGIN2-> first; if ((BEGIN2-> second - = DFK) SS (Sl [helpNr2] .first. getKnotenNummer () '= nodeNoD2)) (// SliceC:: ιterator SLNODE1 = definelterator (Sl, nodesNrl);
//buιldIn_D2_Part ( Sl ,posOR, SLPUSE, SLNODE1 , KnotenNrD2 ) ;// buιldIn_D2_Part (Sl, posOR, SLPUSE, SLNODE1, node number D2);
}}
BEGIN2++;BEGIN2 ++;
} BEGIN1++;} BEGIN1 ++;
}}
SliceC: :ιterator USEmD2 = fmd_Dl_Node (Sl, SLPUSE, SLNODE); SliceC: :ιterator HELP = USEιnD2; if (USEιnD2->fιrst. getLevel! ) > SLPUSE->fιrst. getLevel () ) ( USEιnD2KnotenNr = USEmD2->fιrst. getKnotenNummer () ; KnotenNrD2Ret = fmdD2Node (Sl, USEιnD2); if (KnotenNrD2Ret == USEιnD2KnotenNr) ( switch (USEιnD2->first. getKFGNodeType! ) ) ( case IFC:SliceC:: ιterator USEmD2 = fmd_Dl_Node (Sl, SLPUSE, SLNODE); SliceC:: ιterator HELP = USEιnD2; if (USEιnD2-> fιrst. getLevel!)> SLPUSE-> fιrst. getLevel ()) (USEιnD2KnotNr = USEmD2-> fιrst. getKnotNumber (); nodeNoDD2Ret = fmdD2Node (Sl, USEιnD2); if (nodeNoDD2Ret == USEιnD2KnotNr) (switch (USEιnD2-> first. getKF)) (case. getKFGNode)
HELP = fιnd_Dl_Node(Sl,USEιnD2, SLNODE); //ret = buildlnIfTreelSl, UΞEιnD2, HELP, posOR); ret = buιldD2InIfTree (Ξl,USEιnD2,HELP,posOR_D2) ; break; case LC:HELP = fιnd_Dl_Node (Sl, USEιnD2, SLNODE); // ret = buildlnIfTreelSl, UΞEιnD2, HELP, posOR); ret = buιldD2InIfTree (Ξl, USEιnD2, HELP, posOR_D2); break; case LC:
HELP = f ιnd_Dl_Node ( Sl , USEιnD2 , SLNODE ) ; buildInLoopTree ( Sl , posOR_D2 , USEιnD2 , SLNODE ) ; break; default : cout « "Uups ! ! ' " « endl ; } )HELP = f ιnd_Dl_Node (Sl, USEιnD2, SLNODE); buildInLoopTree (Sl, posOR_D2, USEιnD2, SLNODE); break; default: cout «" Oops!! '"« endl; })
}}
int uwggraphC: :fιndD2Node (SliceC S Sl, SliceC: :ιterator PUSE) ( int dummy = 0; int helpNrl = 0; int helpNr2 = 0; int KnotenNrReturn - PUSE->first. getKnotenNummer () ; mt PUSEKnotenNr = PUSE->first .getKnotenNummer I) ; SliceC: :Nachfolger: :ιterator BEGIN1 = PUSE->second.begιn ( ) ; SliceC: :Nachfolger: :ιterator END1 = PUSE->second. end ( ) ; while ( (BEGIN1 '= END1 ) SS (dummy '= 1)1 ( lf (BEGINl->second == DFK) { helpNrl = BEGINl->first; SliceC: :Nachfolger: :ιterator BEGIN2 = Sl [helpNrl] .second.begin! ) ; SliceC: :Nachfolger: : iterator END2 = Sl [helpNrl] . second. end( ) ; while ( (BEGIN2 != END2) SS (dummy != 1)){ if (BEGIN2->second == KFK) ( helpNr2 = BEGIN2->fιrst; lf (Sl[helpNr2) .first. getKnotenNummer ( ) — PUSEKno- tenNr) (int uwggraphC:: fιndD2Node (SliceC S Sl, SliceC:: ιterator PUSE) (int dummy = 0; int helpNrl = 0; int helpNr2 = 0; int nodeNoReturn - PUSE-> first. getKnotNumber (); mt PUSEKnotNo = PUSE-> first .get node number I); SliceC:: Successor:: ιterator BEGIN1 = PUSE-> second.begιn (); SliceC:: Successor:: ιterator END1 = PUSE-> second. end (); while ((BEGIN1 '= END1) SS (dummy' = 1) 1 (lf (BEGINl-> second == DFK) {helpNrl = BEGINl->first; SliceC:: Successor:: ιterator BEGIN2 = Sl [helpNrl] .second.begin! ); SliceC:: Successor:: iterator END2 = Sl [helpNrl]. second. end (); while ((BEGIN2! = END2) SS (dummy! = 1)) {if (BEGIN2-> second == KFK) (helpNr2 = BEGIN2->fιrst; lf (Sl [helpNr2) .first. getKnotenNummer () - PUSEKno- tenNr) (
KnotenNrReturn = Sl lhelpNr2] . first. getKnotenNummer I ) ; dummy - 1 ;NodeNoReturn = Sl lhelpNr2]. first. getKnotenNumber I); dummy - 1;
} } BEGIN2++;}} BEGIN2 ++;
}}
))
BEGIN1++; ) return KnotenNrReturn;BEGIN1 ++; ) return nodeNoReturn;
int uwggraphC: :buildIn_LoopKF_ANDPart (SliceC S Sl, int posANDJCF, SliceC: :ιterator SLPUSE) t pos = 0; int helpNrl = 0; int helpNr2 = 0; int RefPUse = 0; int KnotenNr = O.mt LineNr = 0; t dummy = 0; int dummyl = 0; char Bemerkung [1000] ; char NodeText [128); RefPUse = SLPUSE->first. getKnotenNummer () ;int uwggraphC:: buildIn_LoopKF_ANDPart (SliceC S Sl, int posANDJCF, SliceC:: ιterator SLPUSE) t pos = 0; int helpNrl = 0; int helpNr2 = 0; int RefPUse = 0; int node number = O.mt line number = 0; t dummy = 0; int dummyl = 0; char remark [1000]; char NodeText [128); RefPUse = SLPUSE-> first. getNodeNumber ();
SliceC: :Nachfolger: :ιterator BEGIN « SLPUSE->second.begιn() ; SliceC: :Nachfolger:: iterator END = SLPUSE->second.end ( ) ; while ((BEGIN != END) SS (dummyl != 1)) ( if (BEGIN->second == DFK) ( helpNrl = BEGIN->first;SliceC:: Successor:: ιterator BEGIN «SLPUSE-> second.begιn (); SliceC:: successor :: iterator END = SLPUSE-> second.end (); while ((BEGIN! = END) SS (dummyl! = 1)) (if (BEGIN-> second == DFK) (helpNrl = BEGIN-> first;
ΞliceC: :Nachfolger: : iterator BEGIN2 = Sl [helpNrl ] .second. beginl) ; ΞliceC: :Nachfolger: :ιterator END2 = Sl [helpNrl ] .second. end () ; while ((BEGIN2 != END2 ) SS (dummy != 1)) ( if (BEGIN2->second «« KFK) ( helpNr2 = BEGIN2->first; lf (Sl [helpNr2] .first. getKnotenNummer ( ) == RefPUse) ( KnotenNr = Sl [helpNrl] . firs .getKnotenNummer () ; LineNr = Sl [helpNrl] . first .getLineNr () ; sprintf (NodeText, "Op%d", KnotenNr) ; //sprintf (Bemerkung, "Line %d", LineNr) ; strcpylBemerkung, Sl [helpNrl] . first. getCodeLine ( ) ) ; uwgknotenC hkno- ten |CAUSE, KnotenNr, NodeText, Bemerkung) ; pos = insert (hknoten) ; verbindeEcken (posAND_KF, pos, 0) ; dummy = 1; dummyl = 1;ΞliceC:: Successor:: iterator BEGIN2 = Sl [helpNrl] .second. beginl); ΞliceC:: Successor:: ιterator END2 = Sl [helpNrl] .second. end (); while ((BEGIN 2 ! = END2) SS (dummy! = 1)) (if (BEGIN2-> second «« KFK) (helpNr2 = BEGIN2->first; lf (Sl [helpNr 2 ] .first. getKnotenNummer () = = RefPUse) (NodeNo = Sl [helpNrl]. Firs .getNodeNumber (); LineNr = Sl [helpNrl]. First .getLineNr (); sprintf (NodeText, "Op% d", NodeNo); // sprintf (remark, " Line% d ", LineNr); strcpylMarkung, Sl [helpNrl]. First. GetCodeLine ()); uwgknotenC hknoten | CAUSE, node number, NodeText, remark); pos = insert (hknoten); connectEcken (posAND_KF, pos, 0 ); dummy = 1; dummyl = 1;
BEGIN2++;BEGIN2 ++;
}}
BEGIN++; return KnotenNr;BEGIN ++; return node number;
void uwggraphC: :buιldIn_LoopKF_ORPart (SliceC S Sl, t po≤LOOPJCF, ΞliceC: : iterator SLl, t KnotenNrD2) { int posl = 0; int pos2 = 0; int helpNrl = 0; t helpNr2 = 0; int KnotenNr = 0; int KnotenNrl = 0; int LineNr = 0; int LineNrl = 0; char NodeText [128] ; char Bemerkung [ 1000] ;void uwggraphC:: buιldIn_LoopKF_ORPart (SliceC S Sl, t po≤LOOPJCF, ΞliceC:: iterator SLl, t nodeNoD2) {int posl = 0; int pos2 = 0; int helpNrl = 0; t helpNr2 = 0; int node number = 0; int nodeNrl = 0; int LineNr = 0; int LineNrl = 0; char NodeText [128]; char remark [1000];
KnotenNr = SLl->fιrst. getKnotenNummer I ) ; LineNr = SLl->first .getLineNr I ) ; sprintf (NodeText, "Op%d", KnotenNr) ; //sprintf (Bemerkung, "Line %d", LineNr) ; strcpylBemerkung, SLl->first. getCodeLine! ) ) ; uwgknotenC hknotenl (CAUSE, KnotenNr, NodeText, Bemerkung) ; posl » insert (hknotenl ) ; verbindeEcken (posLOOPJCF,posl, 0) ;NodeNo = SLl-> first. getKnotenNumber I); LineNr = SLl-> first .getLineNr I); sprintf (NodeText, "Op% d", node number); // sprintf (remark, "Line% d", LineNr); strcpyl remark, SLl-> first. getCodeLine! )); uwgknotenC hknotenl (CAUSE, NodeNo, NodeText, Comment); posl »insert (hknotenl); connect corners (posLOOPJCF, posl, 0);
SliceC: :Nachfolger:: iterator BEGIN = SLl->second.begin() ; SliceC: :Nachfolger: : iterator END - SLl->second.end ( ) ; while (BEGIN '= END) ( lf (BEGIN->second == DFK) ( helpNrl = BEGIN->fιrst;SliceC:: successor :: iterator BEGIN = SLl-> second.begin (); SliceC:: Successor:: iterator END - SLl-> second.end (); while (BEGIN '= END) (lf (BEGIN-> second == DFK) (helpNrl = BEGIN-> fιrst;
KnotenNrl = Sl [helpNrl] . first. getKnotenNummer () ; lf (KnotenNrl '= KnotenNrD2) (NodeNrl = Sl [helpNrl]. first. getNodeNumber (); lf (nodeNrl '= nodeNoD2) (
LineNrl = Sl [helpNrl] . first. getLineNr I ) ; sprintf (NodeText, "Op%d" , KnotenNrl ) ;LineNrl = Sl [helpNrl]. first. getLineNr I); sprintf (NodeText, "Op% d", nodesNrl);
//sprintf (Bemerkung, "Line %d", ineNrl) ; strcpy(Bemerkung,SLl->fιrst. getCodeLine ( ) ) ; uwgknotenC hknotenl (CAUSE, KnotenNrl, NodeText, Bemerkung) ; posl = insert (hknotenl ) ; verbindeEcken (posLOOPJCF,posl, 0) ; j// sprintf (note, "Line% d", ineNrl); strcpy (remark, SLl-> fιrst. getCodeLine ()); uwgknotenC hknotenl (CAUSE, nodesNrl, NodeText, remark); posl = insert (hknotenl); connect corners (posLOOPJCF, posl, 0); j
SliceC: : iterator NEXTNODE = definelterator (Sl, KnotenNrl ) ; SliceC: :Nachfolger: : iterator BEGIN2 = NEXTNODE->second.begιn () ; ΞliceC: :Nachfolger: : iterator END2 = NEXTNODE->second.end( ) ; while (BEGIN2 '= END2) ( lf (BEGIN2->second == DFK) ( helpNr2 = BEGIN2->first; if (NEXTNODE->first. getKnotenNummer! ) '= KnotenNrD2) ( buιldIn_LoopKF_ORPart(Sl, posLOOPJCF, NEXTNODE, KnotenNrD2);SliceC:: iterator NEXTNODE = definelterator (Sl, nodesNrl); SliceC:: Successor:: iterator BEGIN2 = NEXTNODE-> second.begιn (); ΞliceC:: successor:: iterator END2 = NEXTNODE-> second.end (); while (BEGIN2 '= END2) (lf (BEGIN2-> second == DFK) (helpNr2 = BEGIN2-> first; if (NEXTNODE-> first. getKknotenNummer!)' = nodeNoD2) (buιldIn_LoopKF_ORPart (Sl, posLOOPJCF, NEXTNODE, nodeNoD2 );
BEGIN2++;BEGIN2 ++;
BEGIN++;BEGIN ++;
void uwggraphC: : addAllDlNodes (SliceC s Sl, SliceC: : iterator SLNODE, t posGatter, int D2_RefNr) ( int checkNr = 1; int helpNrl = 0; mt helpNr2 = 0; int SlιceNr2 = 0; int KnotenNrO = 0; int KnotenNrl = 0; int KnotenNr2 = 0; int LineNrl = 0; int LineNrO = 0; char Bemerkungl [1000] ; char NodeTextl [128];void uwggraphC:: addAllDlNodes (SliceC s Sl, SliceC:: iterator SLNODE, t posGatter, int D2_RefNr) ( int checkNr = 1; int helpNrl = 0; mt helpNr2 = 0; int SlιceNr2 = 0; int node number = 0; int nodeNrl = 0; int nodeNo2 = 0; int LineNrl = 0; int LineNrO = 0; char note [1000]; char NodeTextl [128];
KnotenNrO = SLNODE->flrst .getKnotenNummer () ; LineNrO = SLNODE->fιrst. getLineNr () ; sprintf (NodeTextl , "Op%d" , KnotenNrO ) ; //sprintf (Bemerkungl, "Line %d", LineNrO) ; strcpy(Bemerkungl,SLNODE->fιrst. etCodeLine ( ) ) ; uwgknotenC hknotenl (CAUSE, KnotenNrO, NodeTextl, Bemerkungl ) ; posl = insert (hknotenl ) ; verbindeEcken (posGatter, posl, 0) ;NodeNo = SLNODE-> flrst .getNodeNumber (); LineNrO = SLNODE-> first. getLineNr (); sprintf (NodeTextl, "Op% d", nodeNo); // sprintf (remark, "Line% d", LineNrO); strcpy (remark, SLNODE-> fιrst. etCodeLine ()); uwgknotenC hknotenl (CAUSE, knotNo, NodeTextl, remarkl); posl = insert (hknotenl); connect corners (posGatter, posl, 0);
SliceC: .-Nachfolger: :ιterator BEGIN1 = SLNODE->second. beginl ) ; ΞliceC: :Nachfolger: :ιterator END1 = SLNODE->second.end ( ) ; while (BEGIN1 '= END1 ) ( lf (BEGINl->second == DFK) ( helpNrl = BEGINl->first;SliceC:. Successor:: ιterator BEGIN1 = SLNODE-> second. beginl); ΞliceC:: successor:: ιterator END1 = SLNODE-> second.end (); while (BEGIN1 '= END1) (lf (BEGINl-> second == DFK) (helpNrl = BEGINl-> first;
KnotenNrl = Ξl [helpNrl ]. firs .getKnotenNummer I ) ; SLNODE = definelterator (Ξl, KnotenNrl ) ; lf ((KnotenNrl '= D2_RefNr) SS (KnotenNrl '= KnotenNrO)) { ΞliceC: :Nachfolger: : iterator BEGIN2 = Ξl [helpNrl ] . second.begin ( ) ; SliceC: :Nachfolger: :ιterator END2 = Sl (helpNrl] .second. end () ; hile (BEGIN2 != END2 ) ( lf (BEGIN2->second == KFK) { helpNr2 = BEGIN2->fιrst;NodeNrl = Ξl [helpNrl]. firs .get node number I); SLNODE = definelterator (Ξl, nodeNrl); lf ((nodeNrl '= D2_RefNr) SS (nodeNrl' = nodeNo)) {ΞliceC:: successor:: iterator BEGIN2 = Ξl [helpNrl]. second.begin (); SliceC:: Successor:: ιterator END2 = Sl (helpNrl] .second. End (); hile (BEGIN2! = END2) (lf (BEGIN2-> second == KFK) {helpNr2 = BEGIN2->fιrst;
SlιceNr2 = Sl [helpNr2] . first .getKnotenNummer () ;SlιceNr2 = Sl [helpNr2]. first .getNodeNumber ();
SliceC: : iterator HELPPUSE = definelteratorlSl,SliceC:: iterator HELPPUSE = definelteratorlSl,
SlιceNr2) ; checkNr = checkUWGNode (SlιceNr2) ; if (checkNr == 0) ( ΞliceC: : iterator HELP1 = findOutmostPU- se(Sl, HELPPUSE); switch (HELPl->fιrst. getKFGNodeType! ) 1 case LC: buildInLoopTree (Sl, posGatter,SlιceNr2); checkNr = checkUWGNode (SlιceNr2); if (checkNr == 0) (ΞliceC:: iterator HELP1 = findOutmostPU- (Sl, HELPPUSE); switch (HELPl-> fιrst. getKFGNodeType!) 1 case LC: buildInLoopTree (Sl, posGatter,
HELPPUSE, SLNODE) ; break; case IFC: ret = buildlnlf-HELPPUSE, SLNODE); break; case IFC: ret = buildlnlf-
Tree l Ξl, HELPPUSE, SLNODE, posGatter ) ; break; default: cout « "Falscher Weg' " « endl; }Tree l Ξl, HELPPUSE, SLNODE, posGatter); break; default: cout «" Wrong way '"« endl; }
} )})
BEGIN2++; } if (checkNr == 1 ) (BEGIN2 ++; } if (checkNr == 1) (
LineNrl = Sl [helpNrl] . first. getLineNr O ; sprintf (NodeTextl, "Op%d", KnotenNrl) ;LineNrl = Sl [helpNrl]. first. getLineNr O; sprintf (NodeTextl, "Op% d", nodesNrl);
//sprintf (Bemerkungl, "Line %d", LineNrl) ; strcpylBemerkungl, Sl [helpNrl] . first .getCodeLine! ) ) ; uwgknotenC hkno- ten2 (CAUSE, KnotenNrl, NodeTextl, Bemerkungl) ; posl = insert (hknoten2) ; verbindeEcken (posGatter, posl, 0) ; addAllDlNodes (Sl, SLNODE,posGatter, D2 RefNr) ; }// sprintf (note, "Line% d", LineNrl); strcpylMarketl, Sl [helpNrl]. first .getCodeLine! )); uwgknotenC hknoten2 (CAUSE, nodesNrl, NodeTextl, remarkl); posl = insert (hknoten2); connect corners (posGatter, posl, 0); addAllDlNodes (Sl, SLNODE, posGatter, D2 RefNr); }
} }}}
BEGIN1++; , ' mt uwggraphC: :buιldD2InIfTree (ΞliceC S Ξl, ΞliceC: : iterator SLIF, ΞliceC: : iterator SLORIG, int posl) ( mt pos2 = 0; int posIFOR = 0; int posIFDFOR = 0; int posIFKFOR = 0; mt posIFDFORAΣ = 0; char NodeText [128]; char Bemerkung [ 1000] ; int KnotenNr = SLIF->first. getKnotenNummer () ; int LineNr = SLIF->first .getLineNr () ; sprintf (NodeText, "Verzweιgung_D+ (%d) "»KnotenNr) ; strcpy(Bemerkung,SLIF->flrst. getCodeLine ( ) ) ; uwgknotenC hknotenl (OR, NodeText, Bemerkung) ; pos2 = insert (hknotenl ) ; posIFOR = sizeO - 1; verbindeEcken (posl, pos2,0); sprintf (NodeText, "Verzweιgung_KF_D+ (%d) ", LineNr) ; uwgknotenC hknotenδ ( OR, NodeText ) ; posIFKFOR = insert (hknotenδ) ; verbindeEcken (pos2, posIFKFOR, 0) ; buιldD2_IFKF_Part(Sl, posIFKFOR, SLIF); switch (ΞLORIG->fιrst.getKnotenIdent( ) ) ( case THEN: ( sprintf (NodeText, "Verzweιgung_DF_Alt .1_D+ ( %d ) " , LineNr ) ; uwgknotenC hknoten2 (AND, NodeTex ) ; insert (hknotenl,hknoten2, 0) ; sprintf ( Bemerkung, "Al .1_D+ ( %d ) " , LineNr ) ; sprintf (NodeText, "Alt .1_D+ I %d ) " , LineNr ) ; uwgknotenC hknoten3 (CAUΞE, NodeText, Bemerkung) ; insert (hknoten2,hknoten3, 0) ; sprintf (NodeText, "Alt .1_D+ ( % ) " , LineNr ) ; uwgknotenC hknoten4 ( OR, NodeText ) ; insert (hknoten2,hknoten , 0) ; posIFDFOR - sizeO - 1; buildD2_Al_Part(Sl, posIFDFOR, SLIF, SLORIG);BEGIN1 ++; , 'mt uwggraphC:: buιldD2InIfTree (ΞliceC S Ξl, ΞliceC:: iterator SLIF, ΞliceC:: iterator SLORIG, int posl) (mt pos2 = 0; int posIFOR = 0; int posIFDFOR = 0; int posIFKFORA = 0; mt posIFDFOR = 0; char NodeText [128]; char remark [1000]; int NodeNo = SLIF-> first. GetNodeNumber (); int LineNr = SLIF-> first .getLineNr (); sprintf (NodeText, "Branching_D + (% d)" » NodeNo); strcpy (remark, SLIF-> flrst. GetCodeLine ()); uwgknotenC hknotenl (OR, NodeText, remark); pos 2 = insert (hknotenl); posIFOR = sizeO - 1; verbindenEcken (posl, pos2,0) ; sprintf (NodeText, "Verzweιgung_KF_D + (% d)", LineNr); uwgknotenC hknotenδ (OR, NodeText); posIFKFOR = insert (hknotenδ); verbindeEcken (pos2, posIFKFOR, 0); buιldD2_IFKF_PART (SL, posIF switch (ΞLORIG-> fιrst.getKknotenIdent ()) (case THEN: (sprintf (NodeText, "Verzweιgung_DF_Alt .1_D + (% d)", LineNr); uwgknotenC hknoten2 (AND, NodeTex); insert (hknotenl, hknintf2, 0); (Note ung, "Al .1_D + (% d)", LineNr); sprintf (NodeText, "Alt .1_D + I% d)", LineNr); uwgknotenC hknoten3 (CAUΞE, NodeText, remark); insert (hnode2, hnode3, 0); sprintf (NodeText, "Alt .1_D + (%)", LineNr); uwgknotenC hknoten4 (OR, NodeText); insert (hnode2, hnode, 0); posIFDFOR - sizeO - 1; buildD2_Al_Part (Sl, posIFDFOR, SLIF, SLORIG);
} break; case ELSE: sprintf (NodeText, "Verzweιgung_DF_Alt.2_D+ (%d) ", LineNr) ; uwgknotenC hknoten2 (AND, NodeText) ; insert (hknotenl, hknoten2,0) ; sprintf (Bemerkung, "Alt .2_D+ ( %d) " , ineNrl ; sprintf (NodeText, "AIt .2_D+ ( %d ) " , LineNr ) ; uwgknotenC hknoten3(CAUSE,NodeText, Bemerkung) ; insert (hknoten2,hknoten3, 0) ; sprintf (NodeText, "Alt .2_D+ ( %d ) " , LineNr ) ; uwgknotenC hknoten4 (OR, NodeText ) ; insert (hknoten2,hknoten4, 0) ; posIFDFORA2 = sizeO - 1; buildD2_Al_Part(Sl, posIFDFORA2, SLIF, SLORIG);} break; case ELSE: sprintf (NodeText, "Verzweιgung_DF_Alt.2_D + (% d)", LineNr); uwgknotenC hknoten2 (AND, NodeText); insert (hknotenl, hknoten2.0); sprintf (remark, "Alt .2_D + (% d)", ineNrl; sprintf (NodeText, "AIt .2_D + (% d)", LineNr); uwgknotenC hknoten3 (CAUSE, NodeText, remark); insert (hknoten2, hknoten3, 0 ); sprintf (NodeText, "Alt .2_D + (% d)", LineNr); uwgknotenC hknoten 4 (OR, NodeText); insert (hknoten2, hknoten4, 0); posIFDFORA2 = sizeO - 1; buildD2_Al_Part (Sl, posIFDFORA2, SLIF , SLORIG);
} break; default: cout « "Autsch'!'" « endl; return posIFDFOR;} break; default: cout «" Ouch '!' "« endl; return posIFDFOR;
void uwggraphC: :buιldD2_Al_Part( SliceC S Sl, int posIFDFOR_D2, SliceC: : iterator SLIF, SliceC: : iterator SLNODE) (~ mt pos0_Al = 0 int posl_Al = 0 int helpNrO = 0 int helpNrl = 0 int KnotenNrO » 0 int KnotenNrl = 0 int KnotenNr2 = 0 int LineNrO = 0; int LineNrl = 0; char NodeTextO[128] ; char BemerkungO [ 1000] ; KnotenNrO = SLNODE->first. getKnotenNummer () ;void uwggraphC:: buιldD2_Al_Part (SliceC S Sl, int posIFDFOR_D2, SliceC:: iterator SLIF, SliceC:: iterator SLNODE) (~ mt pos0_Al = 0 int posl_Al = 0 int helpNrO = 0 int helpNrl = 0 int nodeNrO 0 int NodeNo2 = 0 int LineNrO = 0; int LineNrl = 0; char NodeTextO [128]; char RemarkO [1000]; NodeNoO = SLNODE-> first. GetNodeNumber ();
LineNrO - SLNODE->first. getLineNr () ; sprintf (NodeTextO, "Op%d" , KnotenNrO ) ; //sprintf (BemerkungO, "Line %d", LineNrO) ; strcpy(Bemerkung0,ΞLNODE->fιrst. getCodeLine! ) ) ; uwgknotenC hknotenO (CAUΞE, KnotenNrO, NodeTextO, BemerkungO) ; pos0_Al = insert (hknotenO) ; verbmdeEcken(posIFDFOR_D2,posO_Al, 0) ;LineNrO - SLNODE-> first. getLineNr (); sprintf (NodeTextO, "Op% d", nodeNoO); // sprintf (remarkO, "Line% d", LineNrO); strcpy (remark0, ΞLNODE-> first. getCodeLine!)); uwgknotenC hknotenO (CAUΞE, NodeNrO, NodeTextO, remarkO); pos0_Al = insert (hknotenO); verbmdeEcken (posIFDFOR_D2, posO_Al, 0);
SliceC: :Nachfolger: :ιterator BEGIN0 = SLNODE->second.beginl ) ; SliceC: :Nachfolger: :ιterator END0 = SLNODE->second.end( ) ; while (BEGIN0 != END0) ( helpNrO = BEGIN0->fιrst;SliceC:: Successor:: ιterator BEGIN0 = SLNODE-> second.beginl); SliceC:: Successor:: ιterator END0 = SLNODE-> second.end (); while (BEGIN0! = END0) (helpNrO = BEGIN0-> first;
KnotenNrl = Sl [helpNrO] . first. getKnotenNummer () ; if (KnotenNrl > KnotenNrO) (KnotNrl = Sl [helpNrO]. first. getNodeNumber (); if (nodeNrl> nodeNo) (
LineNrl = Sl [helpNrO] . first .getLineNr () ; sprintf (NodeTextO, "Op%d", KnotenNrl) ;LineNrl = Sl [helpNrO]. first .getLineNr (); sprintf (NodeTextO, "Op% d", nodesNrl);
//sprintf (BemerkungO, "Line %d", LineNrl ) ; strcpy (BemerkungO, Sl [helpNr0] .first .getCodeLine ( ) ) ; uwgknotenC hknotenl (CAUSE, KnotenNrl, NodeTextO, BemerkungO) ; posl_Al = insert (hknotenl ) ; verbmdeEcken(posIFDFOR_D2,posl_Al,0) ;// sprintf (remarkO, "Line% d", LineNrl); strcpy (CommentO, Sl [helpNr0] .first .getCodeLine ()); uwgknotenC hknotenl (CAUSE, nodesNrl, NodeTextO, remarkO); posl_Al = insert (hknotenl); verbmdeEcken (posIFDFOR_D2, posl_Al, 0);
SliceC: :Nachfolger: :ιterator BEGIN1 = Sl [helpNrO] .second.beginl ) ; ΞliceC: :Nachfolger: :ιterator END1 = Ξl [helpNrO] .second. endl ) ; while (BEGIN1 != END1 ) ( if (BEGINl->second == DFK) ( helpNrl = BEGINl->first;SliceC:: Successor:: ιterator BEGIN1 = Sl [helpNrO] .second.beginl); ΞliceC:: Successor:: ιterator END1 = Ξl [helpNrO] .second. endl); while (BEGIN1! = END1) (if (BEGINl-> second == DFK) (helpNrl = BEGINl-> first;
KnotenNr2 = Sl [helpNrl ). first .getKnotenNummer () ; if (KnotenNrl '= KnotenNr2) (NodeNo2 = Sl [helpNrl). first .getNodeNumber (); if (nodeNrl '= nodeNo2) (
ΞliceC: : iterator SLNODE = definelterattoorrl(SSll,.KKnnootteennNNrr22)) : buιldD2_Al_Part (Ξl, posIFDFOR_D2, SLIF,ΞliceC:: iterator SLNODE = definelterattoorrl (SSll, .KKnnootteennNNrr22)): buιldD2_Al_Part (Ξl, posIFDFOR_D2, SLIF,
SLNODE ) ; BEGIN1++;SLNODE); BEGIN1 ++;
} BEGIN0++;} BEGIN0 ++;
void uwggraphC: :buιldD2_IFKF_Part (ΞliceC S Sl, int posKFOR_D2, SliceC: : iterator ΞLPUSE) ( int posO_D2 = 0; int posl_D2 = 0; int ret - 0; mt dummy = 0; int helpNrO = 0; int helpNrl = int helpNr2 -= int checkPUse = 0 mt checkNode = 0 int KnotenNrO = 0 int KnotenNrl = 0 int KnotenNr2 = 0 int KnotenNr3 = 0 int LineNrO = 0; int LineNrl = 0; char NodeTextO [128]; char BemerkungO(lOOO) ;void uwggraphC:: buιldD2_IFKF_Part (ΞliceC S Sl, int posKFOR_D2, SliceC:: iterator ΞLPUSE) (int posO_D2 = 0; int posl_D2 = 0; int ret - 0; mt dummy = 0; int helpNrO = 0; int helpNrl = int helpNr2 - = int checkPUse = 0 mt checkNode = 0 int NodeNrO = 0 int NodeNrl = 0 int NodeNr2 = 0 int NodeNr3 = 0 int LineNrO = 0; int LineNrl = 0; char NodeTextO [128]; char CommentO (lOOO);
KnotenNrO = ΞLPUSE->fιrst .getKnotenNummer () ; LineNrO = SLPUSE->fιrst. getLineNr () ; sprintf (NodeTextO, "Op%d", KnotenNrO) ; //sprintf (BemerkungO, "Line %d", LineNrO) ; strcpy(BemerkungO,SLPUSE->fιrst. getCodeLine) ) ) ; uwgknotenC hknotenO (CAUSE, KnotenNrO, NodeTextO, BemerkungO) ; posO_D2 = insert (hknotenO) ; verbindeEcken (posKFOR_D2,posO_D2, 0) ;NodeNo = ΞLPUSE-> fιrst .getNodeNumber (); LineNrO = SLPUSE-> first. getLineNr (); sprintf (NodeTextO, "Op% d", nodeNoO); // sprintf (remarkO, "Line% d", LineNrO); strcpy (remarkO, SLPUSE-> fιrst. getCodeLine))); uwgknotenC hknotenO (CAUSE, NodeNo, NodeTextO, remarkO); posO_D2 = insert (hknotenO); connectCorner (posKFOR_D2, posO_D2, 0);
SliceC: :Nachfolger: :ιterator BEGIN0 = SLPUΞE->second.begιn ( ) ; ΞliceC: :Nachfolger: : iterator END0 = SLPUSE->second.end ( ) ; while (BEGIN0 '= END0) ( helpNrO = BEGIN0->fιrst;SliceC:: Successor:: ιterator BEGIN0 = SLPUΞE-> second.begιn (); ΞliceC:: successor:: iterator END0 = SLPUSE-> second.end (); while (BEGIN0 '= END0) (helpNrO = BEGIN0-> first;
KnotenNrl = Sl (helpNrO] . first .getKnotenNummer I ) ; SliceC: :ιterator SLNODE = definelterator (Sl, KnotenNrl ) ; lf (KnotenNrl > KnotenNrO) (NodeNrl = Sl (helpNrO]. First .getNodeNumber I); SliceC:: ιterator SLNODE = definelterator (Sl, nodesNrl); lf (NodeNrl> NodeNo) (
LineNrl = Ξl [helpNrO] . first. getLineNr () ; sprintf (NodeTextO, "Op%d" , KnotenNrl ) ;LineNrl = Ξl [helpNrO]. first. getLineNr (); sprintf (NodeTextO, "Op% d", nodesNrl);
//sprintf (BemerkungO, "Line %d", LineNrl) ; strcpy(BemerkungO,Ξl IhelpNrO] . first. getCodeLine ( ) ) ; uwgknotenC hknotenl (CAUΞE, KnotenNrl, NodeTextO, BemerkungO) ; posl_D2 = insert (hknotenl ) ; verbindeEcken (posKFOR_D2,posl_D2, 0) ;// sprintf (remarkO, "Line% d", LineNrl); strcpy (NoteO, Ihl IhelpNrO]. first. getCodeLine ()); uwgknotenC hknotenl (CAUΞE, nodesNrl, NodeTextO, remarkO); posl_D2 = insert (hknotenl); connectCorner (posKFOR_D2, posl_D2, 0);
ΞliceC: :Nachfolger: :ιterator BEGIN1 = SLNODE->second.begm ( ) ;ΞliceC:: successor:: ιterator BEGIN1 = SLNODE-> second.begm ();
SliceC: :Nachfolger: :ιterator END1 ΞLNODE->second. end ( ) ; while (BEGIN1 != END1 ) { lf (BEGINl->second «= DFK) ( helpNrl = BEGINl->fιrst;SliceC:: Successor:: ιterator END1 ΞLNODE-> second. end (); while (BEGIN1! = END1) {lf (BEGINl-> second «= DFK) (helpNrl = BEGINl-> fιrst;
KnotenNrΣ = Sl [helpNrl] . first. getKnotenNummer O ; lf (KnotenNr2 '= KnotenNrl) (Nodal number = Sl [helpNrl]. first. getNodeNumber O; lf (nodeNo2 '= nodeNrl) (
SliceC: : iterator SLNODE = defmeltera- tor (Sl,KnotenNr2);SliceC:: iterator SLNODE = defmelterator (Sl, nodeNo2);
ΞliceC: :Nachfolger: :ιterator BEGIN2 =ΞliceC:: Successor:: ιterator BEGIN2 =
Sl [helpNrl] . second.beginl ) ;Sl [helpNrl]. second.beginl);
ΞliceC: :Nachfolger: :ιterator END2 =ΞliceC:: successor:: ιterator END2 =
Sl [helpNrl] .second. end ( ) ; while (BEGIN2 '= END2) ( lf (BEGIN2->second == KFK) ( helpNr2 = BEGIN2->first; KnotenNr3 =Sl [helpNrl] .second. end (); while (BEGIN2 '= END2) (lf (BEGIN2-> second == KFK) (helpNr2 = BEGIN2-> first; nodeNo3 =
Sl [helpNr2] . first .getKnotenNummer ( ) ;Sl [helpNr2]. first .getNodeNumber ();
SliceC: : iterator HELPPUSE = definelterator (Sl,KnotenNr3) ; if (SLPUSE- >first. getKnotenNumme ( ) > KnotenNr3) checkPUse = checkPU- sesl ( Ξl , ΞLPUSE, HELPPUSE ) ; eise { checkPUse = checkPU- ses2 (Sl, ΞLPUSE, HELPPUSE ) ; checkNode = checkU-SliceC:: iterator HELPPUSE = definelterator (Sl, node number 3 ); if (SLPUSE-> first. getKnotNum ()> NodeNo3) checkPUse = checkPU- sesl (Ξl, ΞLPUSE, HELPPUSE); else {checkPUse = checkPUSes2 (Sl, ΞLPUSE, HELPPUSE); checkNode = checkU-
WGNode I KnotenNr2 ) ; lf (checkNode == 0) { if (checkPUse == 0) (WGNode I node number 2 ); lf (checkNode == 0) {if (checkPUse == 0) (
//HELPPUSE = fin- dOutmostPUse (Ξl, HELPPUSE ) ; switch (HELPPUSE- >first. getKFGNodeType () ) ( case LC: buildInLoopTree (Sl, posKFOR_D2, HELPPUΞE, ΞLNODE); dummy - 1; break; case IFC: ret - buildlnIfTreelSl, HELPPUSE, SLNODE, posKFOR D2 ) ; dummy = 1; break; default:// HELPPUSE = find-OutmostPUse (Ξl, HELPPUSE); switch (HELPPUSE-> first. getKFGNodeType ()) (case LC: buildInLoopTree (Sl, posKFOR_D 2 , HELPPUΞE, ΞLNODE); dummy - 1; break; case IFC: ret - buildlnIfTreelSl, HELPPUSE, SLNODE, posKFOR D2); dummy = 1; break; default:
"Falscher Weg in AI ! " « endl; eise ("Wrong way in AI!" «Endl; ice (
LineNrl =LineNrl =
Ξl[helpNr2] . first. getLineNr () ; sprintf (NodeTextO, "Op%d", KnotenNr2 ) ;Ξl [helpNr2]. first. getLineNr (); sprintf (NodeTextO, "Op% d", NodeNo2);
//sprintf (BemerkungO, "Line %d", LineNrl ) ; strcpy!BemerkungO, l [helpNr2] . first .getCodeLine ( ) ) ; uwgknotenC hkno- tenl (CAUSE, KnotenNr2, NodeTextO, BemerkungO) ; posl D2 = insert (hknotenl ) ; verbindeEcken (posKFOR D2,posl D2,0);// sprintf (remarkO, "Line% d", LineNrl); strcpy! remarkO, l [helpNr2]. first .getCodeLine ()); uwgknotenC hknotenl (CAUSE, NodeNo2, NodeTextO, remarkO); posl D2 = insert (hknotenl); connect corners (posKFOR D2, posl D2,0);
BEGIN2++;BEGIN2 ++;
) BEGIN1++;) BEGIN1 ++;
BEGIN0++ ;BEGIN0 ++;
SliceC: : iterator uwggraphC: : findOutmostPUse (SliceC s Sl, ΞliceC: : iterator ΞLPUΞE) ( int dummy = 0; int helpNrl = 0; mt checkNr = 0; int KnotenNrl = 0; SliceC:: iterator RETURN = SLPUSE;SliceC:: iterator uwggraphC:: findOutmostPUse (SliceC s Sl, ΞliceC:: iterator ΞLPUΞE) (int dummy = 0; int helpNrl = 0; mt checkNr = 0; int nodeNrl = 0; SliceC :: iterator RETURN = SLPUSE;
SliceC: :Nachfolger: :ιterator BEGIN1 = SLPUΞE->second.beginl ) ; ΞliceC: :Nachfolger: :ιterator END1 = SLPUSE->second.end ( ) ; while ÜBEGIN1 != END1 ) SS (dummy '= 1))( lf (BEGINl->second == KFK) ( helpNrl = BEGINl->first;SliceC:: Successor:: ιterator BEGIN1 = SLPUΞE-> second.beginl); ΞliceC:: Successor:: ιterator END1 = SLPUSE-> second.end (); while ÜBEGIN1! = END1) SS (dummy '= 1)) (lf (BEGINl-> second == KFK) (helpNrl = BEGINl-> first;
KnotenNrl = Ξl [helpNrl ]. first .getKnotenNummer () ; checkNr = checkUWGNode (KnotenNrl ) ; lf (checkNr == 0) (NodeNrl = Ξl [helpNrl]. first .getNodeNumber (); checkNr = checkUWGNode (nodesNrl); lf (checkNr == 0) (
ΞLPUSE = definelterator (Ξl, KnotenNrl); RETURN = findOutmostPUse (Ξl, ΞLPUΞE); dummy = 1; eiseΞLPUSE = definelterator (Ξl, nodeNrl); RETURN = findOutmostPUse (Ξl, ΞLPUΞE); dummy = 1; else
RETURN = ΞLPUΞE; dummy = 1;RETURN = ΞLPUΞE; dummy = 1;
BEGINH return RETURN;BEGINNING return RETURN;
int uwggraphC: : checkUWGNode(int SliceNr) ( int dummy = 0; uwggraphC: : iterator ITER = beginl); while (ITER '= endO) ( if ( (»ITER) .first. getCauseNrl ) == SliceNr) ( dummy = 1;int uwggraphC:: checkUWGNode (int SliceNr) (int dummy = 0; uwggraphC:: iterator ITER = beginl); while (ITER '= endO) (if (( » ITER) .first. getCauseNrl) == SliceNr) (dummy = 1;
) ITER++;) ITER ++;
} lf (dummy ■== 1 ) return 1; eise return 0; )} lf (dummy ■ == 1) return 1; else return 0; )
ΞliceC: :ιterator uwggraphC: :definelterator (ΞliceC S Ξl, mt SliceNr) ( int dummy = 0;ΞliceC:: ιterator uwggraphC:: definelterator (ΞliceC S Ξl, mt SliceNr) (int dummy = 0;
SliceC: : iterator ITER = Sl.beginO; SliceC: :ιterator HELP = Sl.beginO; while ((ITER '= Sl.endO) SS (dummy != 1)) ( lf ( («ITER) .first.getKnotenNummer ( ) == SliceNr) ( HELP = ITER; dummy = 1; } ITER++;SliceC:: iterator ITER = Sl.beginO; SliceC:: ιterator HELP = Sl.beginO; while ((ITER '= Sl.endO) SS (dummy! = 1)) (lf (( « ITER) .first.getKnotenNummer () == SliceNr) (HELP = ITER; dummy = 1;} ITER ++;
} return HELP; }} return HELP; }
void S Ξl ) ( ostream_ιterator<KFGLιstNodeC> POSITIZiel, "Knoten\n"); ostream_ιterator<KFGLιstNodeC> POSIT2(Zιel, " Nachfolger: "); ostream_ιterator<GraphKanteC> KANTEIT (Ziel, "\n"); Ziel « "SLICE:" « endl « endl; for (int l = 0; l < Sl.sizeO; ++ι) ( Ziel « Sl[ι]. first « " <";void S Ξl) ( ostream_ιterator <KFGLιstNodeC> POSITI target, "node \ n"); ostream_ιterator <KFGLιstNodeC> POSIT2 (Zιel, "successor:"); ostream_ιterator <GraphKanteC> KANTEIT (target, "\ n"); Target «" SLICE: "« endl «endl; for (int l = 0; l <Sl.sizeO; ++ ι) (target «Sl [ι]. first« "<";
SliceC: :Nachfolger: :ιterator IT = Sl [l] .second. beginl ) ; SliceC: :Nachfolger: :ιterator ITEND = Sl [l ] .second. end () ; while (IT != ITEND) (SliceC:: Successor:: ιterator IT = Sl [l] .second. beginl); SliceC:: Successor:: ιterator ITEND = Sl [l] .second. end (); while (IT! = ITEND) (
Ziel « Ξl[ («IT) .first] .first « ' ' // Ecke « endl « "Kante:" « («IT). second « ' '; // KantenwertTarget «Ξl [( « IT) .first] .first «'' // corner« endl «" edge: "« ( « IT). second «''; // edge value
++IT;++ IT;
Ziel « ">\n";Target «"> \ n ";
„ include "uwgkante . h" D ffinclude <ιostream> D"Include" uwgkante. H "D ffinclude <ιostream> D
D ostreamS Operator << ( ostreamS os, const uwgkanteCS Node)| D os « Node.Number << endl ; return os; ffinclude "uwgknoten.h"D ostreamS Operator << (ostreamS os, const uwgkanteCS Node) | D os «Node.Number <<endl; return os; ffinclude "uwgknoten.h"
D ftmclude <iostream>D ftmclude <iostream>
DD
D ostreamS Operator « ( ostreamS os, eonst uwgknotenCS Node)(D ostreamS Operator «(ostreamS os, eonst uwgknotenCS Node) (
//os « Node. Gatterldent « " " « Node. CauseNr « " " « Node. gattertext « endl //return os; lf (Node.getNodeldentl ) == EFFECT) ( os « "%%EFFECT:\"" « Node .gatterbemerkung « »\» :\»» « Node. gattertext « "\"," « Node.Gatterldent « " , , 10; " « endl; return os; ) eise lf (Node.getNodeldentl) == OR) ( os « "%%OR:l:\"" « Node. gattertext << "\": \"keme\", " « Node. Gatterldent « ", , 10; " « endl; return os; } eise lf (Node.getNodeldentl) == AND) ( os « "%%AND:\"" « Node. gattertext « "\":\"keine\", " « Node. Gatterldent « " , , 10; " « endl; return os; } eise lf (Node.getNodeldentl) == NOT) ( os « "%%NOT:\"" « Node. gattertext « "\" : \"keιne\", " « Node. Gatterldent « " , , 10; " « endl; return os; }// os «node. Gatterldent «""« Node. CauseNr «""« Node. gate text «endl // return os; lf (Node.getNodeldentl) == EFFECT) (os «" %% EFFECT: \ "" «Node .gate remark« » \ » : \ »» «Node. gatetext« "\", "« Node.Gatterldent «", , 10; "« endl; return os;) else lf (Node.getNodeldentl) == OR) (os «" %% OR: l: \ "" «Node. Gattertext <<" \ ": \" keme \ " , "« Node. Gatterldent «",, 10; "« endl; return os;} else lf (Node.getNodeldentl) == AND) (os «" %% AND: \ "" «Node. Gattertext« "\" : \ "none \", "« Node. Gatterldent «",, 10; "« endl; return os;} else lf (Node.getNodeldentl) == NOT) (os «" %% NOT: \ "" «Node . gattertext «" \ ": \" keιne \ "," «Node. Gatterldent« ",, 10;"«endl; return os;}
/«eise if (Node.getNodeldentl) == CAUΞE) ( os « "%%CAUSE:\"" « Node. gattertext « "\":\"keme\", " « Node. Gatterldent « ", , 10; " « endl; return os; }«/ eise lf (Node.getNodeldentl) == CAUSE) { os « "%%CAUSE:\"" « Node. gatterbemerkung « "\» :\»» « Node. gattertext « "\"," « Node. Gatterldent « " , , 10; " « endl; return os; } eise ( os « Node.Gatterldent « " " « Node. CauseNr « " " « Node. attertext « endl ; return os; }/ «Else if (Node.getNodeldentl) == CAUΞE) (os« "%% CAUSE: \""« Node. Gattertext «" \ ": \" keme \ "," «Node. Gatterldent« ",, 10; "« Endl; return os;} « / else lf (Node.getNodeldentl) == CAUSE) {os« "%% CAUSE: \""« Node. Gate remark «" \ » : \ » » « Node. gattertext «" \ "," «Node. Gatterldent« ",, 10; "« Endl; return os;} ice (os «Node.Gatterldent« "" «Node. CauseNr« "" «Node. Attertext« endl; return os;}
} int uwgknotenC: : DummyNr = 1; } int uwgknotenC:: DummyNr = 1;
In diesem Dokument sind folgende Veröffentlichungen zitiert:The following publications are cited in this document:
[1] N. Leveson, Safety Verification of ADA Programs using Software fault trees, IEEE Software, Seite 48 bis 59, Juli 1991[1] N. Leveson, Safety Verification of ADA Programs using Software fault trees, IEEE Software, pages 48 to 59, July 1991
[2] Weiser M., Program Slicing, in: IEEE Transaction on Software Engineering, Vol. 10, No. 4 , July 1984, pp. 352-357[2] Weiser M., Program Slicing, in: IEEE Transaction on Software Engineering, Vol. 10, No. 4, July 1984, pp. 352-357
[3] Liggesmeyer P., Modultest und ModulVerifikation - State of the Art, Mannheim, Wien, Zürich: BI Wissenschaftsverlag 1990[3] Liggesmeyer P., module test and module verification - state of the art, Mannheim, Vienna, Zurich: BI Wissenschaftsverlag 1990
[4] DIN 25424-1: Fehlerbaumanalysen; Methoden und Bildzei- chen, September 1981[4] DIN 25424-1: fault tree analysis; Methods and symbols, September 1981
[5] DIN 25424-2: Fehlerbaumanalyse; Handrechenverfahren zur Auswertung eines Fehlerbaums, Berlin, Beuth Verlag GmbH, April 1990 [5] DIN 25424-2: fault tree analysis; Manual calculation method for evaluating a fault tree, Berlin, Beuth Verlag GmbH, April 1990

Claims

Patentansprüche claims
1. Verfahren zur Ermittlung einer Gesamtfehlerbeschreibung zumindest eines Teils eines Computerprogramms, durch einen Computer,1. Method for determining an overall error description of at least part of a computer program by a computer,
• bei dem zumindest der Teil des Computerprogramms gespeichert ist,In which at least the part of the computer program is stored,
• bei dem eine Kontrollflußbeschreibung und eine Datenflußbeschreibung für den Teil des Computerprogramms ermittelt werden,In which a control flow description and a data flow description are determined for the part of the computer program,
• bei dem Programmelemente aus dem Teil des Computerprogramms ausgewählt werden,In which program elements are selected from the part of the computer program,
• bei dem für jedes ausgewählte Programmelement unter Verwendung einer gespeicherten Fehlerbeschreibung, die jeweils einem Referenzelement zugeordnet ist, eine Elementenfehlerbeschreibung ermittelt wird, mit der mögliche Fehler des jeweiligen Programmelements beschrieben werden,In which an element error description is determined for each selected program element using a stored error description, which is assigned to a reference element, with which possible errors of the respective program element are described,
• bei dem mit einer Fehlerbeschreibung eines Referenzelements mögliche Fehler des jeweiligen Referenzelements beschrieben werden, undIn which possible errors of the respective reference element are described with an error description of a reference element, and
• bei dem aus den Elementenfehlerbeschreibungen die Gesamtfehlerbeschreibung unter Berücksichtigung der Kontrollflußbeschreibung und der Datenflußbeschreibung ermittelt wird.• in which the overall error description is determined from the element error descriptions taking into account the control flow description and the data flow description.
2. Verfahren nach Anspruch 1, bei dem die Kontrollflußbeschreibung in Form eines Kontrollflußgraphen vorliegt.2. The method of claim 1, wherein the control flow description is in the form of a control flow graph.
3. Verfahren nach Anspruch 1 oder 2, bei dem die Datenflußbeschreibung in Form eines Datenflußgra- phen vorliegt.3. The method of claim 1 or 2, wherein the data flow description is in the form of a data flow graph.
4. Verfahren nach einem der vorangegangenen Ansprüche, • bei dem die Fehlerbeschreibung in Form eines gespeicherten Fehlerbaums vorliegt, • bei dem die Elementenfehlerbeschreibung als Elementenfehlerbaum ermittelt wird, und4. The method according to any one of the preceding claims, • in which the error description is in the form of a stored error tree, • in which the element error description is determined as an element error tree, and
• bei dem die Gesamtfehlerbeschreibung als Gesamtfehlerbaum ermittelt wird.• in which the overall error description is determined as an overall error tree.
5. Verfahren nach einem der vorangegangenen Ansprüche, eingesetzt zur Fehleranalyse des Teils des Computerprogramms.5. The method according to any one of the preceding claims, used for error analysis of the part of the computer program.
6. Verfahren nach einem der vorangegangenen Ansprüche, • bei dem die Gesamtfehlerbeschreibung als Gesamtfehlerbaum ermittelt wird,6. The method as claimed in one of the preceding claims, in which the overall error description is determined as an overall error tree,
• bei dem der Gesamtfehlerbaum verändert wird hinsichtlich vorgebbarer Rahmenbedingungen.• in which the overall fault tree is changed with regard to specifiable framework conditions.
7. Verfahren nach Anspruch 6, bei dem die Veränderung durch Hinzufügen eines Ergänzungsfehlerbaums erfolgt.7. The method according to claim 6, wherein the change is made by adding a supplementary fault tree.
8. Anordnung zur Ermittlung einer Gesamtfehlerbeschreibung zumindest eines Teils eines Computerprogramms, durch einen Computer, mit einem Prozessor, der derart eingerichtet ist, daß folgende Schritte durchführbar sind:8. Arrangement for determining an overall error description of at least part of a computer program, by a computer with a processor, which is set up in such a way that the following steps can be carried out:
• zumindest der Teil des Computerprogramms ist gespeichert, • eine Kontrollflußbeschreibung und eine Datenflußbeschreibung werden für den Teil des Computerprogramms ermittelt,At least the part of the computer program is stored, a control flow description and a data flow description are determined for the part of the computer program,
• Programmelemente werden aus dem Teil des Computerprogramms ausgewählt,Program elements are selected from the part of the computer program,
• für jedes ausgewählte Programmelement wird unter Verwendung einer gespeicherten Fehlerbeschreibung, die jeweils einem• For each selected program element, using a stored error description, each one
Referenzelement zugeordnet ist, eine Elementenfehlerbeschreibung ermittelt, mit der mögliche Fehler des jeweiligen Programmelements beschrieben werden,Is assigned a reference element, an element error description is determined with which possible errors of the respective program element are described,
• mit einer Fehlerbeschreibung eines Referenzelements werden mögliche Fehler des jeweiligen Referenzelements beschrieben, und • aus den Elementenfehlerbeschreibungen wird die Gesamtfehlerbeschreibung unter Berücksichtigung der Kontrollflußbeschreibung und der Datenflußbeschreibung ermittelt.• An error description of a reference element describes possible errors of the respective reference element, and • The overall error description is determined from the element error descriptions taking into account the control flow description and the data flow description.
9. Anordnung nach Anspruch 8, bei der der Prozessor derart eingerichtet ist, daß die Kontrollflußbeschreibung in Form eines Kontrollflußgraphen vorliegt.9. Arrangement according to claim 8, wherein the processor is set up such that the control flow description is in the form of a control flow graph.
10. Anordnung nach Anspruch 8 oder 9, bei der der Prozessor derart eingerichtet ist, daß die Datenflußbeschreibung in Form eines Datenflußgraphen vorliegt.10. The arrangement of claim 8 or 9, wherein the processor is set up such that the data flow description is in the form of a data flow graph.
11. Anordnung nach einem der Ansprüche 8 bis 10, bei der der Prozessor derart eingerichtet ist, daß11. Arrangement according to one of claims 8 to 10, wherein the processor is set up such that
• die Fehlerbeschreibung in Form eines gespeicherten Fehlerbaums vorliegt,The error description is in the form of a stored error tree,
• die Elementenfehlerbeschreibung als Elementenfehlerbaum ermittelt wird, und • die Gesamtfehlerbeschreibung als Gesamtfehlerbaum ermittelt wird.• the element error description is determined as an element error tree, and • the overall error description is determined as an overall error tree.
12. Anordnung nach einem der Ansprüche 8 bis 11, eingesetzt zur Fehleranalyse des Teils des Computerprogramms.12. Arrangement according to one of claims 8 to 11, used for error analysis of the part of the computer program.
13. Anordnung nach einem der Ansprüche 8 bis 12, bei der der Prozessor derart eingerichtet ist, daß13. Arrangement according to one of claims 8 to 12, wherein the processor is set up such that
• die Gesamtfehlerbeschreibung als Gesamtfehlerbaum ermittelt wird, • der Gesamtfehlerbaum verändert wird hinsichtlich vorgebbarer Rahmenbedingungen.• the overall error description is determined as an overall error tree, • the overall error tree is changed with regard to predefinable framework conditions.
14. Anordnung nach Anspruch 13, bei der der Prozessor derart eingerichtet ist, daß die Verän- derung durch Hinzufügen eines Ergänzungsfehlerbaums erfolgt. 14. Arrangement according to claim 13, wherein the processor is set up in such a way that the change is made by adding a supplementary fault tree.
15. Computerprogramm-Erzeugnis, das ein computerlesbares Speichermedium umfaßt, auf dem ein Programm gespeichert ist, das es einem Computer ermöglicht, nachdem es in einen Speicher des Computers geladen worden ist, folgende Schritte durchzuführen zur Ermittlung einer Gesamtfehlerbeschreibung zumindest eines Teils eines Computerprogramms:15. A computer program product comprising a computer-readable storage medium on which a program is stored which, after it has been loaded into a memory of the computer, enables a computer to carry out the following steps for determining an overall error description of at least part of a computer program:
• zumindest der Teil des Computerprogramms ist gespeichert,At least the part of the computer program is stored,
• eine Kontrollflußbeschreibung und eine Datenflußbeschreibung werden für den Teil des Computerprogramms ermittelt, • Programmelemente werden aus dem Teil des Computerprogramms ausgewählt,A control flow description and a data flow description are determined for the part of the computer program, program elements are selected from the part of the computer program,
• für jedes ausgewählte Programmelement wird unter Verwendung einer gespeicherten Fehlerbeschreibung, die jeweils einem Referenzelement zugeordnet ist, eine Elementenfehlerbe- Schreibung ermittelt, mit der mögliche Fehler des jeweiligen Programmelements beschrieben werden,For each selected program element, an element error description is determined using a stored error description, which is assigned to a reference element, with which possible errors of the respective program element are described.
• mit einer Fehlerbeschreibung eines Referenzelements werden mögliche Fehler des jeweiligen Referenzelements beschrieben, und • aus den Elementenfehlerbeschreibungen wird die Gesamtfehlerbeschreibung unter Berücksichtigung der Kontrollflußbeschreibung und der Datenflußbeschreibung ermittelt.• An error description of a reference element describes possible errors of the respective reference element, and • The overall error description is determined from the element error descriptions taking into account the control flow description and the data flow description.
16. Computerlesbares Speichermedium, auf dem ein Programm ge- speichert ist, das es einem Computer ermöglicht, nachdem es in einen Speicher des Computers geladen worden ist, folgende Schritte durchzuführen zur Ermittlung einer Gesamtfehlerbeschreibung zumindest eines Teils eines Computerprogramms:16. Computer-readable storage medium, on which a program is stored, which enables a computer, after it has been loaded into a memory of the computer, to carry out the following steps for determining an overall error description of at least part of a computer program:
• zumindest der Teil des Computerprogramms ist gespeichert, • eine Kontrollflußbeschreibung und eine Datenflußbeschreibung werden für den Teil des Computerprogramms ermittelt,At least the part of the computer program is stored, a control flow description and a data flow description are determined for the part of the computer program,
• Programmelemente werden aus dem Teil des Computerprogramms ausgewählt,Program elements are selected from the part of the computer program,
• für jedes ausgewählte Programmelement wird unter Verwendung einer gespeicherten Fehlerbeschreibung, die jeweils einem• For each selected program element, using a stored error description, each one
Referenzelement zugeordnet ist, eine Elementenfehlerbe- Schreibung ermittelt, mit der mögliche Fehler des jeweiligen Programmelements beschrieben werden, mit einer Fehlerbeschreibung eines Referenzelements werden mögliche Fehler des jeweiligen Referenzelements beschrieben, und aus den Elementenfehlerbeschreibungen wird die Gesamtfehlerbeschreibung unter Berücksichtigung der Kontrollflußbeschreibung und der Datenflußbeschreibung ermittelt. Reference element is assigned, an element error Spelling is determined with which possible errors of the respective program element are described, possible errors of the respective reference element are described with an error description of a reference element, and the overall error description is determined from the element error descriptions taking into account the control flow description and the data flow description.
EP00929272A 1999-06-02 2000-04-03 Method and arrangement for determining a total error description of at least one part of a computer programme and computer programme product and computer-readable storage medium Withdrawn EP1200894A1 (en)

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
DE19925239 1999-06-02
DE19925239 1999-06-02
PCT/DE2000/001001 WO2000075780A1 (en) 1999-06-02 2000-04-03 Method and arrangement for determining a total error description of at least one part of a computer programme and computer programme product and computer-readable storage medium

Publications (1)

Publication Number Publication Date
EP1200894A1 true EP1200894A1 (en) 2002-05-02

Family

ID=7909989

Family Applications (1)

Application Number Title Priority Date Filing Date
EP00929272A Withdrawn EP1200894A1 (en) 1999-06-02 2000-04-03 Method and arrangement for determining a total error description of at least one part of a computer programme and computer programme product and computer-readable storage medium

Country Status (3)

Country Link
US (1) US7047523B1 (en)
EP (1) EP1200894A1 (en)
WO (1) WO2000075780A1 (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1364286B1 (en) 2001-02-20 2009-08-19 Siemens Aktiengesellschaft Method and device for determining a full error description for at least one part of a technical system, computer program element and computer-readable storage medium
JP2006113934A (en) * 2004-10-18 2006-04-27 Hitachi Ltd Program development support apparatus and method, and program
US7563542B2 (en) * 2005-10-05 2009-07-21 California Institute Of Technology Subfluorinated graphite fluorides as electrode materials
US7685471B2 (en) * 2007-02-01 2010-03-23 Fujitsu Limited System and method for detecting software defects
CN100461132C (en) * 2007-03-02 2009-02-11 北京邮电大学 Software safety code analyzer based on static analysis of source code and testing method therefor
US9189318B2 (en) * 2013-05-15 2015-11-17 Oracle International Corporation Path-sensitive analysis framework for bug checking
US11036866B2 (en) 2018-10-18 2021-06-15 Denso Corporation Systems and methods for optimizing control flow graphs for functional safety using fault tree analysis

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5740357A (en) * 1990-04-26 1998-04-14 Digital Equipment Corporation Generic fault management of a computer system
US5586252A (en) * 1994-05-24 1996-12-17 International Business Machines Corporation System for failure mode and effects analysis
US5500941A (en) * 1994-07-06 1996-03-19 Ericsson, S.A. Optimum functional test method to determine the quality of a software system embedded in a large electronic system
US5903453A (en) * 1996-01-19 1999-05-11 Texas Instruments Incorporated Method for estimating software operation and performance using a goal-question-metric paradigm
US6012152A (en) * 1996-11-27 2000-01-04 Telefonaktiebolaget Lm Ericsson (Publ) Software fault management system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See references of WO0075780A1 *

Also Published As

Publication number Publication date
US7047523B1 (en) 2006-05-16
WO2000075780A1 (en) 2000-12-14

Similar Documents

Publication Publication Date Title
Sivaramakrishnan et al. Declarative programming over eventually consistent data stores
Georgakopoulos et al. Specification and management of extended transactions in a programmable transaction environment
EP1764715B1 (en) Method for determining the quality of a set of properties, applicable for the verification and specification of circuits
DE19860061B4 (en) System for combinatorial equivalence testing
DE112005002402T5 (en) Hybrid hardware / software implementation of transaction memory access
DE112011102242T5 (en) Apparatus for processing a batch processing unit
DE19926116A1 (en) Method of multiple part process recording in configuration database
DE102004058288A1 (en) Apparatus and method for resolving errors in a dual execution unit processor
Dong et al. Ensuring structure and behavior correctness in design composition
DE112013007083B4 (en) Program analysis device, program analysis method and program analysis program
Aggarwal et al. Software Design Metrics for Object-Oriented Software.
EP1200894A1 (en) Method and arrangement for determining a total error description of at least one part of a computer programme and computer programme product and computer-readable storage medium
Orso et al. Incremental slicing based on data-dependences types
DE112004002576T5 (en) Management of external memory update for fault detection in redundant multithreading systems using speculative memory support
Vitek et al. A semantic framework for designer transactions
Xu et al. JMLAutoTest: A novel automated testing framework based on JML and JUnit
Lyu et al. Software diversity metrics and measurements
Georgakopoulos et al. An environment for the specification and management of extended transactions in DOMS
EP1745375A1 (en) Method for determining deadlocks in secondary processes
EP1202166A1 (en) System for verification of software application models in strings of software development tools
Derrick et al. Mechanizing a correctness proof for a lock-free concurrent stack
Thévenod-Fosse et al. Towards a statistical approach to testing object-oriented programs
EP0662226B1 (en) Method of processing an application program on a parallel-computer system
Marić Formal Verification of Fault-Tolerant Systems
Canals et al. Concurrency control for cooperating software processes

Legal Events

Date Code Title Description
PUAI Public reference made under article 153(3) epc to a published international application that has entered the european phase

Free format text: ORIGINAL CODE: 0009012

17P Request for examination filed

Effective date: 20011106

AK Designated contracting states

Kind code of ref document: A1

Designated state(s): AT BE CH CY DE DK ES FI FR GB GR IE IT LI LU MC NL PT SE

RBV Designated contracting states (corrected)

Designated state(s): DE FR GB

17Q First examination report despatched

Effective date: 20060627

GRAP Despatch of communication of intention to grant a patent

Free format text: ORIGINAL CODE: EPIDOSNIGR1

STAA Information on the status of an ep patent application or granted ep patent

Free format text: STATUS: THE APPLICATION IS DEEMED TO BE WITHDRAWN

18D Application deemed to be withdrawn

Effective date: 20100817