Skip to content

Commit

Permalink
FIXED: в режиме -OI пытаемся встроить $DRIVE-функции (#122, #229, #239)
Browse files Browse the repository at this point in the history
Ранее в режиме -OI встраивались только $INLINE-функции, а $DRIVE вообще
не трогались. А должны были, поскольку в режиме -OI метка $DRIVE должна
была рассматриваться как метка $INLINE, это входило в постановку задачи.
  • Loading branch information
Mazdaywik committed Aug 1, 2019
1 parent 2b8bcab commit 38b963c
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/compiler/OptTree-Drive.ref
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,7 @@ OptSentence-Aux {
t.DriveInfo

/* Поиск информации для прогонки */
= <FindOptInfo s.Mode t.DriveInfo e.Name>
: Success t.FunctionForDrive
= <FindOptInfo t.DriveInfo e.Name> : Success t.FunctionForDrive

= <OptSentence-MakeSubstitutions
s.Mode ((e.Left) (e.Right)) (e.Args) t.FunctionForDrive
Expand All @@ -314,7 +313,7 @@ OptSentence-Aux {
OptSentence-MakeSubstitutions {
s.Mode
((e.Left) (e.Expr)) (e.Args)
(s.Mode s.ScopeClass (e.Name) Sentences e.Body)
(s.FuncMode s.ScopeClass (e.Name) Sentences e.Body)

/* Активные вызовы игнорируем */
, <IsPassiveCall e.Args> : False
Expand All @@ -327,7 +326,7 @@ OptSentence-MakeSubstitutions {

s.Mode
((e.Left) (e.Expr)) (e.Args)
(s.Mode s.ScopeClass (e.Name) Sentences ((e.LS) (e.RS)) e.Rest)
(s.FuncMode s.ScopeClass (e.Name) Sentences ((e.LS) (e.RS)) e.Rest)

/* Если левая часть не L-выражение, допускаем только встраивание */
= <IsLexpr e.Left>
Expand All @@ -343,21 +342,28 @@ OptSentence-MakeSubstitutions {
>
: e.Solution

= <DecreaseMode s.Mode s.FuncMode> : s.Mode^

= <OptSentence-MakeSubstitutions-Aux
(e.RS) s.Mode (e.Name) (e.Rest) (e.Args)
e.Solution
>;

s.Mode
((e.Left) (e.Expr)) (e.Args)
(s.Mode s.ScopeClass (e.Name) Sentences e.Body)
(s.FuncMode s.ScopeClass (e.Name) Sentences e.Body)
= (
((ColdCallBrackets (Symbol Name e.Name) e.Args))
((/* нет присваиваний */) (/* нет сужений */))
(/* нет новых функций */)
);
}

DecreaseMode {
Inline s.Mode = Inline;
Drive s.Mode = s.Mode;
}

OptSentence-MakeSubstitutions-Aux {
/*
В случае решения без сужений просто применяем замены
Expand Down Expand Up @@ -423,7 +429,7 @@ DropLeft {
*/

FindInlineInfo {
t.InlineInfo e.Name = <FindOptInfo Inline t.InlineInfo e.Name>;
t.InlineInfo e.Name = <FindOptInfo t.InlineInfo e.Name>;
}

/*
Expand All @@ -432,11 +438,10 @@ FindInlineInfo {
*/

FindDriveInfo {
t.DriveInfo e.Name = <FindOptInfo Drive t.DriveInfo e.Name>
t.DriveInfo e.Name = <FindOptInfo t.DriveInfo e.Name>
}

FindOptInfo {
s.Mode
t.DriveInfo e.Name
, e.Name : e.Prefix '*' s.N
, <CutSUF e.Prefix> : e.Prefix^
Expand All @@ -449,7 +454,6 @@ FindOptInfo {
= Success
(s.Mode s.ScopeClass (e.Name) Sentences <DropLeft e.Sentences s.N>);

s.Mode
t.DriveInfo e.Name
, t.DriveInfo
: (
Expand All @@ -458,7 +462,6 @@ FindOptInfo {
)
= Success (s.Mode s.ScopeClass (e.Name) <s.Body>);

s.Mode
t.DriveInfo e.Name = Failure;
}

Expand Down

0 comments on commit 38b963c

Please sign in to comment.