diff --git a/.github/workflows/CI-posix.yml b/.github/workflows/CI-posix.yml index b46283a3..902cce88 100644 --- a/.github/workflows/CI-posix.yml +++ b/.github/workflows/CI-posix.yml @@ -34,10 +34,10 @@ jobs: ./bootstrap.sh shell: bash - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: failure() with: - name: log-info-posix + name: log-info-posix-${{ matrix.os }}-${{ matrix.ccomp }} path: | autotests/__error.txt autotests/__dump.txt diff --git a/.github/workflows/CI-windows.yml b/.github/workflows/CI-windows.yml index dbbad96d..a2d821b1 100644 --- a/.github/workflows/CI-windows.yml +++ b/.github/workflows/CI-windows.yml @@ -25,10 +25,10 @@ jobs: bootstrap.bat shell: cmd - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: failure() with: - name: log-info-windows + name: log-info-windows-${{ matrix.ccomp }} path: | autotests\__error.txt autotests\__dump.txt diff --git a/autotests/opt-tree-match4.ref b/autotests/opt-tree-match4.ref new file mode 100644 index 00000000..03ae2335 --- /dev/null +++ b/autotests/opt-tree-match4.ref @@ -0,0 +1,16 @@ +* TREE + +$ENTRY Go { + /* пусто */ = : B = /* пусто */; +} + +* Проблема была в специализации этой функции, $ENTRY нужно, +* чтобы специализировался не вызов из Go, а сама эта функция +$ENTRY F { + t.A e.D t.E = ; +} + +G { + (e.F) e.F 'a' = A; + e.X = B; +} diff --git a/autotests/positive-random-test/@refal-5-lambda-diagnostics.ini b/autotests/positive-random-test/@refal-5-lambda-diagnostics.ini index 4dd0cdad..59c1c2c3 100644 --- a/autotests/positive-random-test/@refal-5-lambda-diagnostics.ini +++ b/autotests/positive-random-test/@refal-5-lambda-diagnostics.ini @@ -1,4 +1,6 @@ -memory-limit = 20000000 +memory-limit = 30000000 +# TODO: вернуть старое значение после слияния с v3.4 +# memory-limit = 20000000 step-limit = 1000000000 idents-limit = 5000 enable-debugger = false diff --git a/autotests/positive-random-test/saved-test-10_Wed_11-26-2025_15-48-44.92.ref b/autotests/positive-random-test/saved-test-10_Wed_11-26-2025_15-48-44.92.ref new file mode 100644 index 00000000..414ab0a4 --- /dev/null +++ b/autotests/positive-random-test/saved-test-10_Wed_11-26-2025_15-48-44.92.ref @@ -0,0 +1,674 @@ +$EXTERN ExtGo , ExtABD , ExtABBB , ExtDDDAC , ExtADBCA , ExtAD , ExtC , ExtBDABB ; + + + +DC { + ((3 e.7 5 ) 9 BAA (6 8 ) ) e.10 e.4 e.11 + ,0 4 : + { + t.1 e.4 e.12 7 s.5 'c' + ,(e.11 ) : + ,DDDA e.12 : + ,: e.3 5 6 e.5 + + , : = + ; + t.1 'd' s.9 + ,6 6 : 'b' e.2 = + e.2 s.9 e.4 ACDC ; + t.1 'd' s.9 DBA e.6 (AA ) (() ) + ,(8 ) : 'd' 9 + ,B 0 () > +e.6 (e.10 7 e.11 ) ('b' 6 8 e.11 ) > > : 9 + ,: + ,: B + + ,: = + ; + }; + D e.3 (s.4 s.4 s.9 ) A ('c' 7 s.8 ) 10 = + 10 ; + ((CBC 'b' ) ) DA (s.4 s.4 s.9 ) A ('c' 7 s.8 ) 10 + , +> : + { + () e.8 B BB t.9 (BBB s.11 'd' ) 'a' + ,: 10 + ,: e.10 'd' = + 8 ; + e.2 BB t.9 (BBB s.11 'd' ) 'a' + ,: = + ; + e.2 t.3 CD 'b' (0 (10 1 'd' s.13 s.10 ) ('d' ) ) ADCC BB t.9 (BBB s.11 'd' ) +'a' + ,: (C e.5 'b' 5 ) CCC 'c' + , : 'a' 8 + ,: + ,ADBA 6 10 : + ,: = + e.5 ; + }; + ((CBC 'b' ) ) DA t.4 'a' BB 3 (s.4 s.4 s.9 ) A ('c' 7 s.8 ) 10 + ,: + + { + e.4 () () A + , AAD CBD D B : (e.3 2 ) 0 + ,: e.8 e.2 e.3 + + ,t.4 : 'd' B 0 'd' ADC + ,e.2 e.8 : + ,'d' : = + ; + }; +} + +$ENTRY ACC { + C 'd' BAC = + ; + C 'b' 2 C 'ca' CDA 'd' BAC + ,D : + { + 5 'a' + ,( ) : DDC (e.10 ) + ,10 'd' : + ,: + + ,'cb' : + { + 'b' + ,e.10 : 4 + ,AADB : 'b' + ,: 3 D + ,4 e.10 e.10 : + + ,D e.10 : = + () e.10 ; + 'b' t.5 'bc' e.6 D + , e.10 'b' 4 : + ,: (e.1 'c' +) 2 + ,: () (e.3 ) () = + ; + 'b' t.5 'b' CD DB DCB BD B + ,DDAA t.5 : + ,: e.4 DBDD 8 + , : +'d' = + ; + }; + e.4 9 AACB e.3 7 e.12 'a' + ,: e.6 + ,DCAC ( C +'b' 7 > ) e.4 e.3 ('a' 0 ) : 'b' e.10 ACC 5 () 4 + ,: 'cb' e.10 DBD + + ,CADC 'b' : (ABBB AB BABC ) e.9 () + ,: e.7 + ,: + { + 4 'd' A ('c' ABC ) + ,2 'd' : + ,: e.6 e.8 + ,BD > : e.8 5 = + ; + 4 'd' A e.1 + ,: A AAAD 'c' + ,CDA : + ,DBD : + ,e.9 > e.4 ( 2 ) : = + ; + 4 'd' A e.1 ('a' ) + ,e.6 : B ('a' ) = + ; + }; + e.8 'da' + ,: 4 10 + ,e.8 () e.8 : D 6 2 10 + ,() BA : + { + AC 'd' + ,ADD A : ('a' 1 e.13 ) e.3 + ,7 'd' D e.8 'c' : + + ,: + ,9 : = + ; + AC 'd' BBAC BD s.13 2 s.5 (10 D ) + ,'d' s.13 : () + ,: DD e.1 CBBA = + ; + AC 'd' B 'c' B 'd' () s.13 2 s.5 (10 D ) + , +> : DBCB 1 4 e.2 + ,: e.1 'c' e.2 e.5 e.7 + ,s.13 s.5 'c' : +e.5 = + > ; + }; + }; + C e.11 'a' CDA 'd' BAC + ,: + { + 'a' e.5 + , DC CDCA e.11 : 10 'b' e.12 'd' AACC + ,: 1 + ,e.5 1 'c' + ABB : 'aa' + ,: 3 (3 e.6 9 ) = + ; + }; + C BBD 'ccb' t.2 DD 3 e.7 e.4 e.5 e.10 'a' CDA 'd' BAC = + 'd' e.10 ; + C BBD 'cc' AD 'c' e.7 AA BA e.10 'a' CDA 'd' BAC + ,5 BABD 'c' +e.10 'd' e.10 (() e.7 e.7 7 (4 ) 5 ) e.10 > ) > : + { + 6 'c' 9 'd' + ,'b' : + ,: e.1 1 + ,: 9 () + ,: + + { + (0 8 ) 'c' + ,: 8 5 4 + ,'a' : DBDC + ,6 BCB A : ADA e.3 + + ,() 'a' : 10 = + ; + }; + 6 6 1 'c' (A ) AC + ,: + ,e.10 DCCC (9 CB CBAB 9 1 ) 0 ('a' e.7 4 ) : +DD 'd' e.13 D DDCA + ,: e.4 AACC ('a' ((CABD CDCB s.7 10 BD ) A ) ) t.11 + ,: +'d' (e.4 (CBA ) 'd' DC (9 BD BB e.13 ) e.9 ) 2 s.7 e.11 CCAA 2 + ,: () 1 0 + + ,: + { + 'd' DCA 'c' e.2 + ,: 0 0 3 7 6 = + ; + }; + }; +} + +CBD { + + ,3 : + { + CBCD + , : C e.1 'c' e.10 + ,: DCB DAC + ,: + { + (e.5 ) (7 A e.2 ) D = + ; + }; + CBCD 2 'd' DB (6 4 6 () ) + ,DCB 'a' (ABBD ) : 'a' + ,: + + { + + ,: () + ,: + ,5 'a' 3 : DBB CCA DAAD + ,: () 'd' = + > ; + + ,: 7 (CAD ) 9 A + ,4 : 'b' () (e.11 BA ) + ,: + ,: +6 'b' + ,e.11 'b' : 5 CBC 3 = + e.11 'dc' ; + }; + CBCD 2 (() e.10 e.6 ) () 'c' DADB 10 'd' DB (6 4 6 () ) + ,: B + ,: +'a' 10 e.13 = + ; + }; + t.2 'a' + ,AAC : + { + e.13 A (7 DCAC ) 9 ('a' ((e.7 e.4 0 ABD ) ) e.8 e.9 ) t.2 + ,: CDAD e.6 + + ,CDC 'ad' : A DBAC 'c' + ,e.8 'a' 6 : 'a' DA + ,8 : + { + ('bb' 1 (s.4 ) CBB ) ('d' ) 0 1 CDCA ACC 'aa' + , : = + ; + }; + }; + t.2 3 'd' 7 ('a' BBDA ) 'c' DBA (3 CB (DCC ) 'a' ) BC 'a' + ,((7 ) A 'a' +DCC ) t.2 t.2 : + { + 10 DDC + ,: + ,'c' : 7 + ,: C + ,: B 7 + ,: = + t.2 1 ; + }; + t.2 3 e.5 DBA 'd' DBA (3 CB (DCC ) 'a' ) BC 'a' = + e.5 ; + t.2 3 s.2 B DCAC BDD DBA 'd' DBA (3 CB (DCC ) 'a' ) BC 'a' + ,t.2 'b' +s.2 (0 (4 5 ) (t.2 (ADBB 'b' DBA 4 ) t.2 ) s.2 1 10 1 ) +('d' t.2 AD ( ) ( 'bd' ) ) : + { + () (e.3 CBAC 'a' ((e.2 'cd' ) 3 C ) ) + ,: (e.10 'd' ) + + ,: 4 BCD + ,: = + ; + () ADB + ,: (AADC ) e.7 + ,: 3 BDD 5 8 + ,: e.12 e.7 + ,: + + ,: = + ; + }; + t.2 3 s.2 3 0 e.4 'c' CDB 'b' DBA 'd' DBA (3 CB (DCC ) 'a' ) BC 'a' + ,: + + { + 'bb' + ,ACBD : 'b' + , (DACC ) > : 'd' e.13 + + ,(s.2 ) : BBDC (e.8 ) + ,4 : 'a' CB e.11 (0 ) 10 e.1 + ,CBCD s.2 : +e.10 = + e.10 A 'b' e.10 ; + }; +} + +A { + = + ( 'b' > 8 3 CBDC ) ('b' ) 'c' A 5 ; +} + +$ENTRY DDCDC { + BA 1 e.11 BDA 'c' B 6 'c' + ,7 ('b' BCBB (9 e.11 (2 e.11 'b' ) 'a' ABAB 8 ) +'a' BDCB 'b' ) : + { + s.13 s.7 'a' s.2 e.10 'b' + ,: + ,: 2 CBA 'c' + ,CDBD +10 : B 'c' = + 5 ; + s.13 s.7 'a' DCAC () e.3 e.7 BBD = + () 9 ; + }; + BA DDDC 6 'c' + ,: + { + 7 'd' + ,: e.4 'a' t.5 e.8 'd' + ,t.5 e.4 (CCAD 0 ) DA (DDBC 7 ) +'c' e.4 : 0 e.4 'a' + ,e.8 'd' : 5 B 4 + ,9 'c' : ADA + + ,t.5 'c' e.4 1 BDBC : + { + 1 s.9 'd' s.2 t.9 + ,: 2 + ,BBC s.9 0 : 1 + ,: + ,t.5 'a' +(6 s.2 ) CAAC : CBC + ,BDDA ( ) : 3 = + e.8 ; + 1 s.9 'd' e.8 9 s.2 t.9 + ,: 0 + ,BC AD : + ,DCD 'ac' : (e.7 ) +s.13 + , 8 CADB : + ,: = + 2 s.9 e.7 () ; + 1 s.9 'd' t.11 t.5 1 BD 10 D 'd' CD 9 s.2 t.9 + ,: BA + ,: BB 6 BA + + ,: = + 'c' ; + }; + CC s.3 7 'd' + ,'b' (DCA 4 ) s.3 : B ((CAB ) e.10 0 ) ((CDDA B 9 10 ) 'a' +() ) AAB 'a' = + 5 10 ; + }; + BA DDDC 6 'c' + ,10 0 'a' 2 : + { + (8 B ) s.6 'aa' CCB BBC + ,s.6 : B t.4 AD t.4 = + t.4 'a' ; + (8 B ) s.6 'aa' e.4 'cda' CCB BBC + ,0 'b' 8 : + ,: (t.10 'd' +3 e.9 e.8 'a' 10 ) (AA ) 'c' t.12 + ,t.10 9 'b' : + ,10 : CC = + CDC BBAA ; + (8 B ) s.6 t.11 e.11 'b' 4 AAB 'da' CCB BBC + ,s.6 7 e.11 : + ,: = + ; + }; + BA t.4 'b' C DDDC 6 'c' + ,t.4 t.4 : + { + 1 CCAC (8 e.6 (e.6 'd' DA CA e.12 e.8 ) (2 (e.9 'ad' DACA ) (9 e.6 'd' DC ) ACAB ) +(7 ('d' ) 'b' ) e.9 ) e.3 + ,'ab' 8 'd' 10 DBC e.9 : + ,e.12 (() 10 () 5 CDAD ) : e.11 + ,e.11 BB : CAD + + ,: + ,: = + e.3 BD CBCC t.4 1 ; + s.13 D () 'b' + ,DACA : + ,CDCB 'd' 6 : + { + DDBA 'b' 1 1 e.3 6 ('a' ) s.11 DDDA + ,10 (CCDC BCAC ) C : e.8 + + ,: e.13 + ,ADC t.4 t.4 7 : CDC (2 ) + ,s.13 ( ) 0 : A 6 AC + + ,10 : DBAC = + ; + DDBA 'b' BCBB ('a' ) s.11 DDDA + ,s.11 5 : s.4 ADC + ,: = + 3 ; + DDBA 'b' BCBB C e.3 5 8 t.8 'd' ('a' ) s.11 DDDA + ,( 'a' +) B 6 : + ,'a' DB : 4 + ,AD : 10 'b' + , : e.7 ('c' +C ) = + CB ; + }; + s.13 s.2 e.13 0 D CCAB ('b' 7 t.1 ) 'b' + ,'a' 1 9 'a' : 'c' = + BBB 'c' ; + }; + BA 0 'db' 8 DA 5 'db' DA t.4 'b' C DDDC 6 'c' + , > 6 : + { + + ,: C + ,t.4 : 'ca' + ,'b' : 10 BBBA + ,( ) +'a' : e.1 + , : = + e.1 C 2 ; + t.9 6 e.12 s.13 8 'b' + ,('d' 'a' ) 'a' : e.13 'a' 2 + ,: 'a' + ,'c' : 8 + , +: 5 + ,t.9 5 s.13 8 : 2 = + ; + t.9 AAD s.7 'a' e.5 'd' e.7 'b' t.11 6 e.12 s.13 8 'b' + ,: + + ,: + ,BBD 8 4 10 : + ,: + ,ADDD : 2 () + +,: + { + t.5 () 5 + ,'a' 5 (CCAA 'b' ) 4 : + ,: + ,: 1 + ,DC CBBA : +DDAB = + ; + }; + }; +} + +AAADB { + 8 'd' (e.12 e.10 CA 7 8 ) 7 + ,9 'b' DABA : + { + e.10 (4 4 e.7 ) + , : + ,'d' e.10 'c' : = + 'd' ; + CAC B + ,DACC CBCB : + ,'a' e.10 : + ,DAA 5 e.10 : (6 ABCD ) 'a' + + ,: = + 'b' ; + CAC B A (DDBA t.9 'a' B ) e.11 e.10 = + ; + }; + 8 s.2 ((('a' t.11 ) 2 t.6 ) 4 ) = + 'd' ; + 8 B CC 5 6 ABDC e.11 B s.2 ((('a' t.11 ) 2 t.6 ) 4 ) + ,((('a' AACA 1 ) CDA ) +t.6 ('c' D t.11 s.2 3 (C DAAD t.11 6 e.11 ) 'ca' ) 8 BD ) 'd' > 'd' : + { + C () 'd' 3 e.7 4 + ,: (B ACC e.4 ) ('db' ) BBA BA + ,1 : + + ,: + { + + ,: 10 + ,: + ,: () + ,: + ,: = + ; + () DBC DAAB e.5 = + ; + () e.5 + ,: e.11 + ,: + ,: CCBA + ,: 3 = + ; + }; + C () 'd' 3 C 'd' () 4 + ,: + { + 'c' 0 7 6 + ,: CDCD + ,(e.11 1 ) : = + ; + 'c' (ACB ) 9 e.2 AC e.12 DA 6 + , : + ,: e.3 BA e.12 + + ,: + ,: (e.1 ) 6 + ,: 'a' C () = + ; + 'c' (ACB ) 9 e.2 AC A ADA s.8 AAC 9 e.13 ('b' () 'c' ) A 6 + ,B : () + + ,: + ,: 4 CA e.7 + ,s.2 : AB 'a' D = + ; + }; + }; +} + +CCBD { + 'a' DAD e.6 'b' 1 s.13 CCBC ABD t.8 t.8 e.5 ('a' 6 9 2 e.5 ) + ,: + { + 'cc' (A e.13 ) (1 e.6 'd' e.4 ) (6 AD CBA e.8 ) (t.1 ) + , > 'd' > 2 1 : e.7 + ,'d' BC ABA 'a' 6 CA : A + ,() (e.8 ) +: + { + 'a' + ,: 'd' + , : CBD + ,2 : + ,: 1 e.5 e.12 + + ,(() ) : = + ; + 'ac' BADA 'd' 7 + ,: t.6 = + ; + }; + }; + C A CAC 6 'd' 6 6 t.8 t.8 e.5 ('a' 6 9 2 e.5 ) = + (6 CADB ) 'da' ; + C A CAC 6 'd' DCCA D CA 'bd' AD 6 6 t.8 t.8 e.5 ('a' 6 9 2 e.5 ) = + 1 ; +} + +BBD { + (B D () ) e.12 'c' + ,e.12 'd' 7 : + { + () t.11 (e.8 'd' ) 10 + ,2 : D + ,1 e.12 : + ,10 : e.1 C + + ,e.8 e.1 : 'c' (0 ) + ,BCA : = + ; + () t.11 'b' C 1 (B ) t.9 10 + ,CB : e.9 + ,e.12 BAB 9 : + { + (6 CDB ) 'b' BA + ,: = + t.9 ; + }; + () t.11 'd' e.1 'b' 2 1 (B ) t.9 10 + ,: BB + ,: () + +,: + ,: + { + e.5 (AB 'd' ) 0 DB 'c' + ,2 'b' : 10 + ,ABBD : = + 3 'd' ; + }; + }; + 6 6 e.13 2 DDDB BB + ,'d' : + { + t.1 DCBD 9 A + ,t.1 : 'c' e.1 + ,: DACB ((t.12 AB 6 9 4 ) ) () + + ,: (() ) = + t.12 ( ('dd' e.13 ) 'dc' 4 +> ) BDD 'b' ; + t.1 DCBD (() DDB e.6 'c' ('c' () 'b' ) e.13 AD ) e.5 B e.3 10 A + ,: + + , ( 10 ) : 0 e.11 2 + ,: + ,e.11 'cc' +: (() ) 'a' + ,: 1 e.7 e.2 'a' = + ; + t.1 DCBD 'a' s.3 (CDB BD 'b' s.6 'b' ) 'cb' 2 t.7 () ('b' CC ((1 ) 'd' +(((BAD 'b' ) ) () 8 s.11 ) ) 'c' (0 s.5 ) ) A + ,: (e.5 ('a' +6 e.3 'd' C ) 7 (CDCD e.9 'd' 7 'a' DA ) 'a' ) 3 + ,: (e.8 ) ACDA (7 1 ) + + ,B : = + ; + }; + 1 s.12 ABB (t.12 e.10 ) e.6 e.4 e.4 2 DDDB BB + ,BC 4 > +((AAC AA A 8 9 e.6 ) 'd' A ) ) (((10 'd' ) t.12 'c' (t.12 ABDD ) ) (() ) ) > : + { + () 4 (e.5 AD t.3 ) 6 (t.3 6 ) 5 + ,: + { + 'c' s.4 6 7 + ,: t.3 + ,: e.4 + ,: + ,: + +,: 5 (CBCB 0 ) = + ; + 'c' s.4 6 'd' e.10 9 ADD e.8 'a' + ,: + ,: e.7 + ,: CCA e.1 + + ,: + ,: 'b' = + ; + }; + () 'b' s.13 (6 t.10 e.1 ) 'd' (t.3 6 ) 5 + ,: + ,: ACB 'dc' +(CDC (t.11 'a' ) (e.4 CC e.5 ) ) = + ; + () 'b' s.13 (6 t.10 e.1 ) 'dc' 6 4 t.7 7 0 (t.3 6 ) 5 = + ; + }; + 1 s.12 'db' 7 'b' 2 DDDB BB + ,BCB ABAC ( 'c' +) B 3 CCB : + { + 3 9 DBD s.6 B 7 ('a' 9 'aa' CCB ) t.11 = + DAC ; + }; +} diff --git a/autotests/positive-random-test/saved-test-5_Wed_11-26-2025_14-58-40.02.ref b/autotests/positive-random-test/saved-test-5_Wed_11-26-2025_14-58-40.02.ref new file mode 100644 index 00000000..33cac186 --- /dev/null +++ b/autotests/positive-random-test/saved-test-5_Wed_11-26-2025_14-58-40.02.ref @@ -0,0 +1,272 @@ +$EXTERN ExtC , ExtD , ExtB ; + + + +D { + (7 ('c' ) ('a' 5 ) (BBD 'd' t.5 'c' AB ) ) () + ,4 : + { + e.12 BCA CC 'd' s.11 ('a' t.5 'a' e.2 ) 7 (t.5 CD ) + ,4 5 s.11 : + + ,: ('c' ) DBA (e.4 'bc' ) 6 = + ; + DD BAAB CABC ('c' ) CAA ('a' 7 BD ) 'd' e.1 e.7 s.2 'b' DCB 'd' s.11 ('a' t.5 'a' +e.2 ) 7 (t.5 CD ) + ,: + ,: 'b' + , > +> : + ,: 7 = + ; + }; + t.8 'c' BAC t.9 t.4 e.12 e.5 (7 ('c' ) ('a' 5 ) (BBD 'd' t.5 'c' AB ) +) () + ,() e.5 BC : + { + t.4 4 t.3 DDDB BB ('a' ) t.9 + ,: 'b' (B ) CBAC A (AA (0 ) DCBA ) 'a' 7 + + ,9 : + ,BCBD : CDC + ,: C () = + ; + t.4 4 t.3 DDDB 6 'a' () 8 6 1 DDDD ('a' ) t.9 + ,4 t.4 : () BDD + ,() +'b' e.5 : + ,4 (7 3 ) +() 5 ACDB 'd' t.8 : + ,() : + { + BCC 'c' + ,BDCB : e.3 + ,'a' (t.4 ) : + ,: B = + ; + 9 + ,8 : e.1 CAA + ,: + ,: () = + () ; + BCAB e.3 'b' DCBC BAC + ,: AABC 0 + ,: = + ; + }; + t.4 4 t.3 DDDB () 1 C e.13 9 8 5 e.9 (7 (3 3 ) 'a' A 1 ) 1 DDDD ('a' ) t.9 + + ,10 : + ,: e.2 'a' = + 3 t.3 ; + }; + e.12 CCBB 'b' () t.4 e.12 e.5 (7 ('c' ) ('a' 5 ) (BBD 'd' t.5 'c' AB ) +) () + ,: + { + 5 0 'd' + , D > : 'ac' + +,'da' : e.4 + ,(6 8 'c' ) 0 8 () C 4 : e.5 4 = + D 'd' ; + 5 0 'd' 2 + ,: BCD + ,: + , t.5 BB > t.5 : 'c' +e.8 + ,'cb' : DAB = + 6 DAD ; + }; +} + +CCB { + 'c' t.3 e.9 (4 9 ) BDAC = + D 'c' 7 ( t.3 ) > ; + 'c' t.3 'd' e.8 (e.10 1 ) (1 'cca' ) 6 (DAAC 8 CABC 'c' BBD ) 'ad' (B ) +(BD AAD t.10 () ) + ,(CAAB ) : + { + e.4 DDA B + ,9 (8 'c' ) 6 : e.1 + ,'b' AA B +BBCC > > : + ,: + ,: ('c' 6 e.9 ) 'a' AAC ('b' e.7 ) = + 5 ; + (9 'c' (CBDB 1 ) ) + ,AA 'a' ( ) : (2 ABBD 2 'db' e.10 4 ) +e.3 + ,8 e.3 : 'c' + ,ABD : 'ac' = + ; + 'db' ADCA 'b' t.4 'b' (D ('d' t.7 ) ) = + ; + }; +} + +CCC { + 2 'b' ('a' ) 'd' C 7 = + 'b' 2 'a' 6 ; +} + +CAAAD { + () 'd' = + 'c' ; + DDC e.4 BD e.12 'd' = + () 'b' ; +} + +$ENTRY DCCBC { + e.1 (e.4 3 ) () t.10 + , CBD ) 'c' D > > 'c' ADCD 'a' 4 'd' CA : + { + (t.2 ) 2 + ,5 ('d' 6 ) ('d' t.10 'c' ) () : + ,: 'a' +BBAA 5 'b' = + ; + }; + t.2 e.3 () () 5 s.8 () t.10 + ,6 t.2 : + { + (() (DCBA B ADDC ) (BB ) ) 'b' BAA s.7 'c' + ,: 10 + ,('c' ) 4 5 : +'d' + ,: (6 9 0 ) e.9 + ,t.10 : + ,: (CC e.6 ) 'b' + + ,'b' s.7 (e.6 'd' ) : + { + t.9 6 t.5 s.3 t.7 + ,4 : e.12 2 = + (DCAB ) ; + }; + }; + t.2 (6 (9 (0 CABB 8 8 ) 'c' (s.5 ) ) ) (8 e.12 e.12 C t.10 ) s.8 9 'd' 8 e.10 e.13 3 5 s.8 () +t.10 + , t.2 (B 7 ) > 'a' : + { + 1 1 + ,: BDB + ,: (e.6 ) + ,( s.5 ) e.13 0 : 'd' e.3 ('d' +e.12 'c' ) + ,: = + 'a' (8 10 ) 'c' ( ) ; + 1 1 e.11 ((DBCD BDB 6 e.3 ) 'd' ('a' 7 'a' ) (s.10 2 ) ('a' e.7 8 0 'b' +) (B e.12 'c' ) ('c' DCB 'd' e.3 CB 'd' ) ) 'cd' + ,: 'd' +0 AA 'd' s.7 + ,t.10 e.3 : + ,: BAA 'b' = + C CBCC e.12 ; + 1 1 ADAB 2 5 CD 0 (6 1 'c' ) = + ; + }; + t.2 (6 (9 (0 CABB 8 8 ) 'c' (s.5 ) ) ) (8 e.12 e.12 C t.10 ) s.8 ADBA AC 5 t.12 5 s.8 () +t.10 + ,e.12 CCD 3 B 'd' t.10 DDCB 3 (9 3 t.2 2 ADCA ) : + { + t.4 e.8 e.9 'c' e.10 + ,4 7 (1 'a' t.4 9 ) : = + ; + t.4 e.8 () () e.9 s.1 'a' + ,s.8 'cd' : = + 5 1 5 ; + t.4 e.8 () () e.9 s.1 CDA 'a' = + (() 'c' ) ; + }; +} + +B { + C C e.10 = + 'd' e.10 DCAA BCD e.10 ; +} + +$ENTRY CBBB { + 'a' CC BD 'a' (t.8 ABC s.5 BB ) 7 DDB (s.11 C (('cd' e.12 'bc' 7 e.2 e.8 ) +e.10 e.12 ('c' (10 7 CBAA 10 t.13 AC ) D 10 CC CCB 'c' e.3 ) ) (9 CCBD 9 'd' 4 e.1 BB ('da' +s.11 ABC e.5 ) s.4 ) ACA ) DBD 6 e.5 'b' = + 'd' ; + 'a' CC BD 'a' (t.8 ABC s.5 BB ) s.2 (3 5 ) 6 'c' e.2 = + (DCD 3 (CD C s.5 ) C ((8 'c' ) (DCCB e.2 CC 'bd' +) ) 5 'b' ( ) ) ; +} + +CB { + 3 (e.13 'd' e.5 (e.11 ) 'd' ) (7 10 ) (e.11 e.4 'd' 10 ) 'b' + +,('a' ) : + { + e.13 'a' e.1 s.6 + ,'b' AA 8 e.4 (4 'c' ) : + ,5 e.13 e.5 'a' +: e.7 5 = + e.1 4 6 ; + (10 'c' BAAC ) t.4 BCC 'd' s.9 s.3 6 'd' s.6 + ,BDA 9 ADBD : = + CCAB 'd' ; + (10 'c' BAAC ) t.4 BCC 'd' s.9 6 'd' s.6 + ,A e.5 : 8 = + ABD ; + }; + 9 'b' (CAD 8 (('a' ABA e.7 (BAD 10 CC e.4 'b' ) ADAC 7 e.3 A 'a' 8 ) (DDCC (s.10 ACBC 2 e.3 ) +e.13 0 (10 'b' e.2 e.13 B 7 D e.8 ADBD 7 ) ) ) (CCC e.7 CD 2 e.6 DDDA 8 2 e.9 4 'd' ) +) = + ; + 9 'b' DDA (9 e.12 ) 6 'd' ((e.11 ) ) = + > B C ; + 9 'b' DDA (9 e.12 ) 6 'd' ((e.11 ) ) BDAD 'd' e.8 ('dc' D BAD e.11 'bc' e.11 AADD ) +6 1 6 3 7 (10 'd' e.7 ) 10 (AB (('a' BC ) 1 C ) DBBB ) + ,: + { + 'd' s.4 s.3 2 6 e.7 s.4 e.5 A + ,: ('b' C 5 ('ddb' ) ) e.2 e.10 'c' +e.9 = + BAC ABDD ; + }; + 9 'b' DDA (9 e.12 ) 6 'd' ((e.11 ) ) BDAD s.9 3 8 (1 () ) 7 (10 'd' e.7 ) +10 (AB (('a' BC ) 1 C ) DBBB ) + ,() (3 5 ) e.11 : + { + ACBB 'b' CCC (('b' 4 () ) 6 e.8 ) + ,A (( +0 9 ) ) s.9 ) (('d' +) (e.12 ) 5 e.11 'd' ) > : + { + s.9 0 + ,: = + ; + DA s.9 0 + ,: + ,: + ,: + ,: = + ; + }; + }; + 9 'b' DDA (9 e.12 ) 6 'd' ((e.11 ) ) BDAD s.9 3 3 9 8 (1 () ) 7 (10 'd' e.7 ) +10 (AB (('a' BC ) 1 C ) DBBB ) + ,e.7 : + { + 2 5 5 10 B 5 + ,DAD (3 ) > BDBB > : D 'a' +e.8 + ,'c' : + ,9 ACC : = + DA ; + 2 5 'a' DBCD 10 B 5 + ,DB e.7 CDB ACC DAC : s.6 + ,'c' e.11 : + ,(6 e.12 ) +'c' : e.9 + ,: = + ; + }; +} diff --git a/distrib b/distrib index a71f671d..d6bc5c9b 160000 --- a/distrib +++ b/distrib @@ -1 +1 @@ -Subproject commit a71f671d8bff3482059787f53f3faeb638d2cf4d +Subproject commit d6bc5c9b58c7f9d7e290768a2767e3ed622e9e53 diff --git a/src/compiler/Engine.ref b/src/compiler/Engine.ref index b5421631..18654d64 100644 --- a/src/compiler/Engine.ref +++ b/src/compiler/Engine.ref @@ -598,10 +598,7 @@ BackEnd-RASLModule { BackEnd-NativeModule { t.NativeModule (e.SrcName) e.OutputName = - - > + (e.OutputName); } diff --git a/src/compiler/Generator-Native.ref b/src/compiler/Generator-Native.ref index a8a1bf72..8e52e2fa 100644 --- a/src/compiler/Generator-Native.ref +++ b/src/compiler/Generator-Native.ref @@ -1,5 +1,8 @@ $INCLUDE "LibraryEx"; +*$FROM Library +$EXTERN Open-Auto; + *$FROM DisplayName $EXTERN DisplayCName, CName; @@ -9,69 +12,75 @@ $EXTERN EscapeChar, EscapeString; $ENTRY GenProgram-Native { (e.SourceFileName) (e.TargetFileName) (e.NativeRASL) + = : s.FileNo + = + ; +} + +PutLines { + s.FileNo e.Lines = } e.Lines> +} - = - : (/* отступ должен остаться тем же */) e.Generated - - = ('// This file automatically generated from \'' e.SourceFileName '\'') - ('// Don\'t edit! Edit \'' e.SourceFileName '\' and recompile it') - () - ('#include "refalrts.h"') - () - e.Generated - () - ('//End of file') + : s.HeaderLen e.Header + + = : /* пусто */ + + = /* отступ */) + e.RASL + > + : (s.LineNo /* отступ должен остаться тем же */) + + = ; +} + +PutCommand-Native-WithInlines { + s.FileNo (e.Source) (e.Target) (s.LineNo e.Indent) + (CmdEmitNativeCode t.SrcPos e.Code) + + = t.SrcPos : { - e.Lines-B (NativeInsertBegin t.SrcPos) e.Lines-E = - ; - - e.Lines = e.Lines; - }; -} - -SetLineNumbers { - /* Оставляем на всякий случай для совместимости */ - (e.Source) (e.Target) s.LineNum (NativeInsertBegin s.SrcLineNum) e.Lines = - ('#line ' ' ' '"' '"') - e.Lines - >; + /* Оставляем на всякий случай для совместимости */ + s.SrcLineNum = s.SrcLineNum e.Source; + (FileLine s.Line e.File) = s.Line e.File; + (FileRowCol (s.Line s.Col) e.File) = s.Line e.File; + } + : s.SrcLine e.SrcFile - (e.Source) (e.Target) s.LineNum - (NativeInsertBegin (FileLine s.Line e.File)) e.Lines = - ('#line ' ' ' '"' '"') - e.Lines - >; + = : s.CodeLen e.Code^ - (e.Source) (e.Target) s.LineNum - (NativeInsertBegin (FileRowCol (s.Line s.Col) e.File)) e.Lines = - ('#line ' ' ' '"' '"') - e.Lines - >; + = <+ s.LineNo <+ s.CodeLen 2>> : s.NextLineNo - (e.Source) (e.Target) s.LineNum (NativeInsertEnd) e.Lines = - ('#line ' > ' ' '"' '"') - e.Lines - >; + = (s.NextLineNo e.Indent) + > + + >; - (e.Source) (e.Target) s.LineNum (e.OtherLine) e.Lines = - (e.OtherLine) - e.Lines - >; + s.FileNo (e.Source) (e.Target) (s.LineNo e.Indent) t.Command + = : (e.Indent^) e.Code + = : s.CodeLen e.Code^ + = (<+ s.LineNo s.CodeLen> e.Indent) + ; +} - (e.Source) (e.Target) s.LineNum /* кончились строки */ = - /* пусто */; +GenLineDirective { + s.Line e.File = '#line ' ' ' '"' '"' } ContextRange-B { diff --git a/src/compiler/GenericMatch.ref b/src/compiler/GenericMatch.ref index 053e754d..992df9fc 100644 --- a/src/compiler/GenericMatch.ref +++ b/src/compiler/GenericMatch.ref @@ -1976,9 +1976,12 @@ Solve-SymmClashes-Aux { = : (e.Left1) (e.Left2) = : (e.Right1) (e.Right2) = >; * E1 T1 {a} = E2 T2 {b} ↦ E1′ {c} = E2′ {d} && {e} T1 {f} = {g} T2 {h} @@ -1994,9 +1997,12 @@ Solve-SymmClashes-Aux { = : (e.Left1) (e.Left2) = : (e.Right1) (e.Right2) = >; /* {a} T {b} E1 = {c} e.X E2 ↦ e.X → t.NEW1 e.NEW2 || e.X → ε */ diff --git a/src/compiler/LowLevelRASL.ref b/src/compiler/LowLevelRASL.ref index 99414c96..d7b32429 100644 --- a/src/compiler/LowLevelRASL.ref +++ b/src/compiler/LowLevelRASL.ref @@ -46,8 +46,11 @@ $ENTRY LowLevelRASL { = : e.Items^ - = - ; + = + : (e.NativeItems) e.RASLItems + + = + ; } Canonize { @@ -322,3 +325,23 @@ MarkFunctionGenMode { s.GenMode (s.Type e.Info) = (s.Type e.Info); } + +SeparateItems { + (e.NativeItems) (s.ItemType e.ItemValue) + , UnitName Function-ToRASL CmdMetatable CmdEnum CmdSwap + CmdConditionFunc-ToRASL CmdConditionFunc-ToNative + CmdConditionFuncDecsrRasl CmdDeclaration + : e._ s.ItemType e._ + = (e.NativeItems) (s.ItemType e.ItemValue); + + (e.NativeItems) (Function-ToNative s.ScopeClass (e.Name) e.Commands) + = (e.NativeItems (Function-ToNative s.ScopeClass (e.Name) e.Commands)) + (Function-ToNative s.ScopeClass (e.Name) /* не копируем */); + + (e.NativeItems) (CmdNativeFunction s.ScopeClass (e.Name) t.SrcPos e.Code) + = (e.NativeItems (CmdNativeFunction s.ScopeClass (e.Name) t.SrcPos e.Code)) + (CmdNativeFunction s.ScopeClass (e.Name) t.SrcPos e.Code); + + (e.NativeItems) (CmdEmitNativeCode t.SrcPos e.Code) + = (e.NativeItems (CmdEmitNativeCode t.SrcPos e.Code)); +} diff --git a/src/lib/debug/refalrts-debugger.cpp b/src/lib/debug/refalrts-debugger.cpp index 2eaadffa..fb596d3d 100644 --- a/src/lib/debug/refalrts-debugger.cpp +++ b/src/lib/debug/refalrts-debugger.cpp @@ -652,6 +652,12 @@ std::pair ); } +namespace { + +class EOFInStream {}; + +} // безымянное namespace + std::string refalrts::debugger::RefalDebugger::ask_for_param( const std::string &appeal ) { @@ -659,8 +665,12 @@ std::string refalrts::debugger::RefalDebugger::ask_for_param( printf("param>"); char param[MAX_COMMAND_LEN] = {0}; - fgets(param, MAX_COMMAND_LEN - 1, m_in); - return trim(std::string(param)); + if (fgets(param, MAX_COMMAND_LEN - 1, m_in) != 0) { + return trim(std::string(param)); + } else { + printf("READ OPTION ERROR!\n"); + throw EOFInStream(); + } } //============================================================================= @@ -1249,12 +1259,13 @@ refalrts::FnResult refalrts::debugger::RefalDebugger::debugger_loop( char command[MAX_COMMAND_LEN] = {0}; for ( ; ; ) { printf("debug>"); - if (m_has_debugger_script) { - if (fgets(command, MAX_COMMAND_LEN - 1, m_in) == 0) { + if (fgets(command, MAX_COMMAND_LEN - 1, m_in) == 0) { + if (m_has_debugger_script) { break; + } else { + m_vm->set_return_code(0); + return cExit; } - } else { - fgets(command, MAX_COMMAND_LEN - 1, m_in); } std::pair cmdAndError = parse_input_line( std::string(command)); @@ -1381,7 +1392,12 @@ refalrts::debugger::RefalDebugger::handle_function_call( "Step #%d; Function <%s ...>\n", m_vm->step_counter(), callee == 0 ? "" : callee->name.name ); - if (debugger_loop(begin, end) == refalrts::cExit) { + try { + if (debugger_loop(begin, end) == refalrts::cExit) { + return cExit; + } + } catch (EOFInStream) { + m_vm->set_return_code(0); return cExit; } } diff --git a/src/lib/refalrts-dynamic.cpp b/src/lib/refalrts-dynamic.cpp index 05fd079c..9e2f5c4f 100644 --- a/src/lib/refalrts-dynamic.cpp +++ b/src/lib/refalrts-dynamic.cpp @@ -553,13 +553,12 @@ refalrts::Module::Loader::read_const_table() { new_table->externals_names.resize(fixed_part.external_count); new_table->externals_pointers.resize(fixed_part.external_count); - new_table->external_memory.resize(fixed_part.external_size); - read = fread(&new_table->external_memory[0], 1, fixed_part.external_size); + read = fread_vector(new_table->external_memory, fixed_part.external_size); PARSE_ASSERT( read == fixed_part.external_size, "can't read externals list in CONST_TABLE" ); - const char *next_external_name = &new_table->external_memory[0]; + const char *next_external_name = vector_ptr(new_table->external_memory); for (size_t i = 0; i < fixed_part.external_count; ++i) { new_table->externals_names[i] = next_external_name; PARSE_ASSERT( @@ -571,13 +570,12 @@ refalrts::Module::Loader::read_const_table() { m_module->m_unresolved_func_tables.push_front(new_table); new_table->idents.resize(fixed_part.ident_count); - new_table->idents_memory.resize(fixed_part.ident_size); - read = fread(&new_table->idents_memory[0], 1, fixed_part.ident_size); + read = fread_vector(new_table->idents_memory, fixed_part.ident_size); PARSE_ASSERT( read == fixed_part.ident_size, "can't read idents list in CONST_TABLE" ); - const char *next_ident_name = &new_table->idents_memory[0]; + const char *next_ident_name = vector_ptr(new_table->idents_memory); for (size_t i = 0; i < fixed_part.ident_count; ++i) { RefalIdentifier ident = ident_implode(m_module->m_domain, next_ident_name); if (! ident) { @@ -591,10 +589,7 @@ refalrts::Module::Loader::read_const_table() { next_ident_name += strlen(next_ident_name) + 1; } - new_table->numbers.resize(fixed_part.number_count); - read = fread( - &new_table->numbers[0], sizeof(RefalNumber), fixed_part.number_count - ); + read = fread_vector(new_table->numbers, fixed_part.number_count); PARSE_ASSERT( read == fixed_part.number_count, "can't read numbers list in CONST_TABLE" @@ -602,7 +597,7 @@ refalrts::Module::Loader::read_const_table() { new_table->strings.resize(fixed_part.string_count); new_table->strings_memory.resize(fixed_part.string_size); - char *string_target = &new_table->strings_memory[0]; + char *string_target = vector_ptr(new_table->strings_memory); for (size_t i = 0; i < fixed_part.string_count; ++i) { UInt32 length; read = fread(&length, sizeof(length), 1); @@ -614,8 +609,7 @@ refalrts::Module::Loader::read_const_table() { string_target += length; } - new_table->rasl.resize(fixed_part.rasl_length); - read = fread(&new_table->rasl[0], sizeof(RASLCommand), fixed_part.rasl_length); + read = fread_vector(new_table->rasl, fixed_part.rasl_length); PARSE_ASSERT( read == fixed_part.rasl_length, "can't read rasl in CONST_TABLE" ); @@ -660,10 +654,10 @@ void refalrts::Module::Loader::enumerate_blocks() { domain()->new_RASL_function( table->make_name(name), &table->rasl[offset], - &table->externals_pointers[0], - &table->idents[0], - &table->numbers[0], - &table->strings[0], + vector_ptr(table->externals_pointers), + vector_ptr(table->idents), + vector_ptr(table->numbers), + vector_ptr(table->strings), table->unit_name.c_str() ) ); @@ -675,8 +669,8 @@ void refalrts::Module::Loader::enumerate_blocks() { PARSE_ASSERT(table != 0, "CONST_TABLE must precede any function"); RefalNativeFunction *func = domain()->new_native_function( - &table->externals_pointers[0], - &table->idents[0], + vector_ptr(table->externals_pointers), + vector_ptr(table->idents), table->make_name(read_asciiz()) ); register_(func); @@ -731,8 +725,8 @@ void refalrts::Module::Loader::enumerate_blocks() { Metatable *metatable = domain()->new_metatable( table->make_name(name), - &table->externals_pointers[0], - &table->idents[0] + vector_ptr(table->externals_pointers), + vector_ptr(table->idents) ); for (UInt32 i = 0; i < count; ++i) { @@ -875,6 +869,11 @@ void refalrts::Domain::ModuleStorage::splice_and_init( refalrts::VM *vm, refalrts::Iter pos, refalrts::Domain::ModuleStorage& other, refalrts::FnResult& result ) { + result = cSuccess; + if (other.m_modules.empty()) { + return; + } + Module *first_new = other.m_modules.front(); m_modules.splice( @@ -887,7 +886,6 @@ void refalrts::Domain::ModuleStorage::splice_and_init( ++p; } - result = cSuccess; while (p != m_modules.end() && result == cSuccess) { (*p)->initialize(vm, pos, result); ++p; diff --git a/src/lib/refalrts-dynamic.h b/src/lib/refalrts-dynamic.h index 85052e5f..69f34053 100644 --- a/src/lib/refalrts-dynamic.h +++ b/src/lib/refalrts-dynamic.h @@ -130,6 +130,21 @@ class Module { return ::fread(ptr, size, count, m_stream); } + template + size_t fread_vector(std::vector &items, size_t count) { + items.resize(count); + if (count > 0) { + return fread(&items[0], sizeof(T), count); + } else { + return 0; + } + } + + template + static T* vector_ptr(std::vector &items) { + return items.size() > 0 ? &items[0] : 0; + } + Domain *domain() const { return m_module->domain(); } diff --git a/src/lib/refalrts-vm.cpp b/src/lib/refalrts-vm.cpp index 27c0cd0f..5e9707ca 100644 --- a/src/lib/refalrts-vm.cpp +++ b/src/lib/refalrts-vm.cpp @@ -71,7 +71,11 @@ void print_error_message( break; case refalrts::cNoMemory: - fprintf(stream, "\nNO MEMORY\n\n"); + fprintf( + stream, + "\nNO MEMORY (%lu nodes)\n\n", + (unsigned long) vm->domain()->memory_use() + ); break; case refalrts::cStepLimit: