Skip to content

Commit

Permalink
Рефакторинг: замороженные функции могут иметь причину заморозки (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mazdaywik committed Dec 5, 2020
1 parent a74074f commit 4f6de03
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 28 deletions.
12 changes: 8 additions & 4 deletions src/compiler/Log-AST.ref
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ UndoubleEmtpyLines {

Element {
(Function s.Scope (e.Name) e.Body) = <Function (e.Name) s.Scope e.Body>;
(ColdFunction s.Scope (e.Name) e.Body)
= <ColdFunction (e.Name) s.Scope e.Body>;
(ColdFunction s.ColdBy s.Scope (e.Name) e.Body)
= <ColdFunction s.ColdBy (e.Name) s.Scope e.Body>;

(Swap GN-Entry e.Name) = ('$ESWAP ' <DisplayName e.Name> ';');
(Swap GN-Local e.Name) = ('$SWAP ' <DisplayName e.Name> ';');
Expand Down Expand Up @@ -71,8 +71,12 @@ Function {
}

ColdFunction {
(e.Name) s.Scope e.Body
= <Function-Aux ('* ' <DisplayName e.Name> ' *') s.Scope e.Body>;
s.ColdBy (e.Name) s.Scope e.Body
= <Function-Aux ('* ' <DisplayName e.Name> ' *') s.Scope e.Body>
: () e.FunctionLines
= ()
('/* Cold by ' <Explode s.ColdBy> ' */')
e.FunctionLines;
}

Function-Aux {
Expand Down
10 changes: 7 additions & 3 deletions src/compiler/OptTree-Drive.ref
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,14 @@ DriveInlineOptimizerTick {
= <MapAccum
{
(e.News-B (Function s.ScopeClass (e.Name) e._) e.News-E)
(s.Function s.ScopeClass (e.Name) e.Body)
, <OneOf s.Function Function ColdFunction> : True
(Function s.ScopeClass (e.Name) e.Body)
= (e.News-B e.News-E)
(Function s.ScopeClass (e.Name) e.Body);

(e.News-B (Function s.ScopeClass (e.Name) e._) e.News-E)
(ColdFunction s.ColdBy s.ScopeClass (e.Name) e.Body)
= (e.News-B e.News-E)
(s.Function s.ScopeClass (e.Name) e.Body);
(ColdFunction s.ColdBy s.ScopeClass (e.Name) e.Body);

(e.NewFunctions^) t.Other = (e.NewFunctions) t.Other;
}
Expand Down
22 changes: 3 additions & 19 deletions src/compiler/OptTree-Spec.ref
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ ColdAll {
= <Map
{
(Function s.ScopeClass (e.Name) e.Body)
= (ColdFunction s.ScopeClass (e.Name) e.Body);
= (ColdFunction SPEC s.ScopeClass (e.Name) e.Body);

t.OtherItem = t.OtherItem;
}
Expand Down Expand Up @@ -274,7 +274,7 @@ SpecUnit {
>
: (e.SpecInfo^ (e.Histories) (e.History^) (e.NewFunctions^)) e.Sentences^
= (e.SpecInfo (e.Histories) (e.NewFunctions))
(ColdFunction s.ScopeClass t.Name Sentences e.Sentences);
(ColdFunction SPEC s.ScopeClass t.Name Sentences e.Sentences);

(e.SpecInfo (e.Histories) (e.NewFunctions))
(Function s.ScopeClass t.Name Sentences e.Sentences)
Expand All @@ -286,7 +286,7 @@ SpecUnit {
: (e.SpecInfo^ (e.Histories^) (e.History^) (e.NewFunctions^))
e.Sentences^
= (e.SpecInfo (e.Histories) (e.NewFunctions))
(ColdFunction s.ScopeClass t.Name Sentences e.Sentences);
(ColdFunction SPEC s.ScopeClass t.Name Sentences e.Sentences);

(e.SpecInfo (e.Histories) (e.NewFunctions)) t.Other
= (e.SpecInfo (e.Histories) (e.NewFunctions)) t.Other;
Expand Down Expand Up @@ -1082,22 +1082,6 @@ PrepareSpecConditions {
>
}

/**
<OptTree-Spec-CleanupColdFunctions e.AST> == e.AST^
*/
$ENTRY OptTree-Spec-CleanupColdFunctions {
e.AST
= <Map
{
(ColdFunction s.ScopeClass (e.Name) e.Body)
= (Function s.ScopeClass (e.Name) e.Body);

t.OtherItem = t.OtherItem;
}
e.AST
>;
}

/*
Вспомогательные функции модуля
*/
Expand Down
18 changes: 16 additions & 2 deletions src/compiler/OptTree.ref
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $EXTERN OptTree-AutoMarkup-Drive, OptTree-AutoMarkup-CureDrives,
$EXTERN OptTree-Drive-Prepare, OptTree-Drive, OptTree-Drive-CleanupColdCalls;

*$FROM OptTree-Spec
$EXTERN OptTree-Spec-Prepare, OptTree-Spec, OptTree-Spec-CleanupColdFunctions;
$EXTERN OptTree-Spec-Prepare, OptTree-Spec;

*$FROM Log
$EXTERN Log-AST;
Expand Down Expand Up @@ -70,7 +70,7 @@ $ENTRY OptTree {
(pass
(trace 'before Spec')
(call &OptTree-Spec s.OptSpec)))
(call &OptTree-Spec-CleanupColdFunctions))
(call &WarmColdFunctions SPEC))
(begin
(call &OptTree-Drive-Prepare t.OptDrive)
(DriveLoop))))
Expand Down Expand Up @@ -115,6 +115,20 @@ $ENTRY OptTree-CleanupMarkup {
}


WarmColdFunctions {
s.ColdBy e.AST
= <Map
{
(ColdFunction s.ColdBy s.ScopeClass (e.Name) e.Body)
= (Function s.ScopeClass (e.Name) e.Body);

t.OtherItem = t.OtherItem;
}
e.AST
>;
}


ExpandClosures {
e.AST
= <Map
Expand Down

0 comments on commit 4f6de03

Please sign in to comment.