Skip to content

Commit

Permalink
Оптимизировано число шагов в функции GetClearedByEntryPointsGraphRec (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mazdaywik committed Jul 4, 2020
1 parent 0b05b7a commit 7f86ee6
Showing 1 changed file with 49 additions and 47 deletions.
96 changes: 49 additions & 47 deletions src/compiler/OptTree-AutoMarkup-GraphExtractor.ref
Original file line number Diff line number Diff line change
Expand Up @@ -98,55 +98,57 @@ GetClearedByEntryPointsGraph {
}

GetClearedByEntryPointsGraphRec {
(e.Graph) (e.ProcessedNodes-Arg) (e.EntryPoints)
= <MapAccum
{
(
(e.ProcessedNodes-B (e.EntryPoint) e.ProcessedNodes-E)
(e.Result) (e.Graph^)
)
(e.EntryPoint)
= (
(e.ProcessedNodes-B (e.EntryPoint) e.ProcessedNodes-E)
(e.Result) (e.Graph)
);
(e.Graph) (e.ProcessedNodes) (e.EntryPoints)
= <DoGetClearedByEntryPointsGraphRec
(e.ProcessedNodes) (/* result */) (e.Graph) e.EntryPoints
>;
}

((e.ProcessedNodes) (e.Result) (e.Graph^))
(e.EntryPoint)
= (e.ProcessedNodes (e.EntryPoint))
: (e.NewProcessedNodes)
= <OptTree-AutoMarkup-GetElemByKey
(e.EntryPoint)
(e.Graph)
>
: e.Node (e.Graph^)
= e.Node
: {
Func (e.FuncName) Children (e.Children)
= <GetClearedByEntryPointsGraphRec
(e.Graph)
(e.NewProcessedNodes)
(e.Children)
>
: ((e.SubTreeResult) (e.Graph^))
= (
(e.NewProcessedNodes)
(<UnionWith (e.FuncName) e.SubTreeResult (e.Result)>)
(e.Graph)
);

e._
= (
(e.NewProcessedNodes)
(e.Result)
(e.Graph)
);
};
}
((e.ProcessedNodes-Arg) (/*result*/) (e.Graph)) e.EntryPoints
/*
Явный цикл вместо MapAccum нужен ради экономии числа шагов. Неоптимизированный
MapAccum требует дополнительных шагов на Mu, Apply и присваивание внутри
DoMapAccum.
*/
DoGetClearedByEntryPointsGraphRec {
(e.ProcessedNodes-B (e.EntryPoint) e.ProcessedNodes-E)
(e.Result) (e.Graph)
(e.EntryPoint) e.EntryPoints
= <DoGetClearedByEntryPointsGraphRec
(e.ProcessedNodes-B (e.EntryPoint) e.ProcessedNodes-E)
(e.Result) (e.Graph)
e.EntryPoints
>;

(e.ProcessedNodes) (e.Result) (e.Graph)
(e.EntryPoint) e.EntryPoints
= e.ProcessedNodes (e.EntryPoint) : e.NewProcessedNodes
= <OptTree-AutoMarkup-GetElemByKey
(e.EntryPoint)
(e.Graph)
>
: ((e.ProcessedNodes-Arg^) (e.Result) (e.Graph^))
= ((e.Result) (e.Graph))
: e.Node (e.Graph^)
= e.Node
: {
Func (e.FuncName) Children (e.Children)
= <GetClearedByEntryPointsGraphRec
(e.Graph) (e.NewProcessedNodes) (e.Children)
>
: ((e.SubTreeResult) (e.Graph^))
= <DoGetClearedByEntryPointsGraphRec
(e.NewProcessedNodes)
(<UnionWith (e.FuncName) e.SubTreeResult (e.Result)>)
(e.Graph)
e.EntryPoints
>;

e._
= <DoGetClearedByEntryPointsGraphRec
(e.NewProcessedNodes) (e.Result) (e.Graph) e.EntryPoints
>;
};

(e.ProcessedNodes) (e.Result) (e.Graph) /* пусто */
= ((e.Result) (e.Graph));
}

/*
Expand Down

0 comments on commit 7f86ee6

Please sign in to comment.