From 48afb2524b46ec4f5d06a0e085742b384d8e3947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=B7=D0=B4=D0=B0=D0=B9=D1=89=D0=B8=D0=BA?= Date: Sun, 28 Jul 2019 11:36:10 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B5=D0=B4=D1=8B=D0=B4=D1=83=D1=89=D0=B5=D0=B3?= =?UTF-8?q?=D0=BE=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82=D0=B0=20(1)=20(#1?= =?UTF-8?q?22,=20#229,=20#239)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Очевидные упрощения кода --- src/compiler/OptTree-Drive.ref | 130 ++++++++------------------------- 1 file changed, 31 insertions(+), 99 deletions(-) diff --git a/src/compiler/OptTree-Drive.ref b/src/compiler/OptTree-Drive.ref index f0852d91..ede02426 100644 --- a/src/compiler/OptTree-Drive.ref +++ b/src/compiler/OptTree-Drive.ref @@ -105,8 +105,8 @@ GetDrivenFunctions { } OptSwitch { - OptDrive = &DriveSentence; - OptInline = &InlineSentence + OptDrive = Drive; + OptInline = Inline; } /* Осуществляет прогонку или оптимизацию в зависимости от ключа */ @@ -203,7 +203,7 @@ IsLexpr-Aux { /* Осуществляет попытку прогонки или встраивания в функции - == t.Function* + == t.Function* Возвращает модифицированную функцию и порожденные из прогонки или встраивания @@ -211,13 +211,14 @@ IsLexpr-Aux { OptimizeF { (Function s.ScopeClass (e.Name) Sentences e.Sentences) - ((e.OptNames) e.OptFunctions) s.OptSentence + ((e.OptNames) e.OptFunctions) s.Mode = : (e.NewFunctions) e.NewSentences = ((e.SntAcc e.NewSentences) (e.FunAcc e.NewFunctions)); @@ -231,59 +232,17 @@ OptimizeF { } /* - Осуществляет попытку встраивания отдельного предложения - + == (t.Func?) t.Sentence* */ -InlineSentence { - ((e.Left) (e.Right)) t.InlineInfo - , : t.Res e.Right^ +OptSentence { + ((e.Left) (e.Right)) t.DriveInfo s.Mode + , : t.Res e.Right^ , : False - = ; + = ; - t.Sentence ((e.OptNames) e.Left) = () t.Sentence -} - -/* Осуществляет попытку прогонки отдельного предложения вида pattern = expr - - == (t.Func?) t.Sentence* -*/ - -DriveSentence { - ((e.Left) (e.Right)) t.DriveInfo - , : t.Res e.Right^ - , : False - = ; - - ((e.Left) (e.Right)) t.InlineInfo - , : t.Res e.Right^ - , : False - = ; - - t.Sentence ((e.OptNames) e.Left) = () t.Sentence -} - -/* - - = (t.Func?) t.Sentence -*/ - -InlineSentence-Aux { - /* Встраивание */ - ((e.Left) (e.Right)) t.Res t.DriveInfo - = ; -} - -/* - - = (t.Func?) t.Sentence* -*/ - -DriveSentence-Aux { - /* Прогонка */ - ((e.Left) (e.Right)) t.Res t.DriveInfo - = ; + t.Sentence ((e.OptNames) e.Left) s.Mode = () t.Sentence } OptSentence-Aux { @@ -424,23 +383,10 @@ DropLeft { } /* - == Success t.Function | Failure + t.Function := (Drive s.ScopeClass (e.Name) e.Body) */ -FindInlineInfo { - t.InlineInfo e.Name = ; -} - -/* - == Success t.DriveInfo | Failure - t.DriveInfo := (Drive s.ScopeClass (e.Name) e.Body) -*/ - -FindDriveInfo { - t.DriveInfo e.Name = -} - FindOptInfo { t.DriveInfo e.Name , e.Name : e.Prefix '*' s.N @@ -472,62 +418,48 @@ CutSUF { e.Prefix = e.Prefix; } - -/* - == t.Found e.Expr - - t.Found ::= None | (CallBrackets e.Arg) -*/ - -FindDriveCall { - t.DriveInfo e.Expr - = - : (t.DriveInfo^ t.Found) e.Expr^ - = t.Found e.Expr -} - /* - == t.Found e.Expr + == t.Found e.Expr t.Found ::= None | (CallBrackets e.Arg) */ -FindInlineCall { +FindOptCall { t.InlineInfo e.Expr - = + = : (t.InlineInfo^ t.Found) e.Expr^ = t.Found e.Expr } FindOptimizedCall { - s.Filter t.DriveInfo e.Expr - = ; + t.DriveInfo e.Expr + = ; } FindOptimizedCall-Term { - s.Filter (t.DriveInfo None) (Brackets e.Expr) - = + (t.DriveInfo None) (Brackets e.Expr) + = : (t.DriveInfo^ t.Found) e.Expr^ = (t.DriveInfo t.Found) (Brackets e.Expr); - s.Filter (t.DriveInfo None) (ADT-Brackets (e.Name) e.Expr) - = + (t.DriveInfo None) (ADT-Brackets (e.Name) e.Expr) + = : (t.DriveInfo^ t.Found) e.Expr^ = (t.DriveInfo t.Found) (ADT-Brackets (e.Name) e.Expr); - s.Filter (t.DriveInfo None) (CallBrackets (Symbol Name e.Name) e.Expr) + (t.DriveInfo None) (CallBrackets (Symbol Name e.Name) e.Expr) , : True - , : Success t.Info + , : Success t.Info = (t.DriveInfo (CallBrackets (Symbol Name e.Name) e.Expr)) (TkVariable 'e' DRIVEN 0); * TODO: раскомментировать код ниже, когда будет реализовываться поддрежка * TODO: активных аргументов функций /* - s.Filter (t.DriveInfo None) (CallBrackets (Symbol Name e.Name) e.Expr) - , : Success t.Info - = + (t.DriveInfo None) (CallBrackets (Symbol Name e.Name) e.Expr) + , : Success t.Info + = : { (t.DriveInfo^ None) e.Expr^ = (t.DriveInfo (CallBrackets (Symbol Name e.Name) e.Expr)) @@ -538,12 +470,12 @@ FindOptimizedCall-Term { }; */ - s.Filter (t.DriveInfo None) (CallBrackets t.F e.Expr) - = + (t.DriveInfo None) (CallBrackets t.F e.Expr) + = : (t.DriveInfo^ t.Found) e.Expr^ = (t.DriveInfo t.Found) (CallBrackets t.F e.Expr); - s.Filter (t.DriveInfo t.Found) t.AnyTerm + (t.DriveInfo t.Found) t.AnyTerm = (t.DriveInfo t.Found) t.AnyTerm; }