Skip to content

Commit

Permalink
Оптимизация специализированных замыканий без контекста (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mazdaywik committed May 13, 2020
1 parent e4cb960 commit 86343fc
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
32 changes: 32 additions & 0 deletions autotests/opt-tree-drive-spec3-closure.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
* TREE

$ENTRY Go {
/* empty */
= <Test 2> : s.F1 s.F2
= <Check 1 s.F1> <Check 2 s.F2>;
}

Test {
s.X = <F 1> <F s.X>
}

$DRIVE F;

F {
t.Mark
= {
/* empty */ = A t.Mark;
t.Mark = B t.Mark;
e._ t.Mark e._ = C t.Mark;
e.X = D e.X;
}
}

Check {
s.X s.F
= <s.F /* emtpy */> : A s.X
= <s.F s.X> : B s.X
= <s.F 'a' s.X 'z'> : C s.X
= <s.F 'abc'> : D 'abc'
= /* empty */;
}
11 changes: 10 additions & 1 deletion src/compiler/OptTree-Spec.ref
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,16 @@ SpecTerm {
: (e.SpecInfo^ (e.NewFunctions^))
(CallBrackets e.ClosureContent^ (TkVariable 'e@' 0))

= (e.SpecInfo (e.NewFunctions)) (ClosureBrackets e.ClosureContent);
= e.ClosureContent
: {
(Symbol Name e.OptName) /* пусто */
= (e.SpecInfo (e.NewFunctions)) (Symbol Name e.OptName);

e.ClosureContent^
= (e.SpecInfo (e.NewFunctions))
(ClosureBrackets e.ClosureContent);
};


(e.SpecInfo (e.NewFunctions)) (Brackets e.Expression)
= <SpecResult (e.SpecInfo (e.NewFunctions)) e.Expression>
Expand Down

0 comments on commit 86343fc

Please sign in to comment.