-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathp.exw
2326 lines (2216 loc) · 85.7 KB
/
p.exw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--
-- p.exw: Phix: Pete's hybrid interpreted/compiled self hosted programming language.
--
-- Pronounced "fix". Test/trace/profile a program using "p test" (ie interpreter mode),
-- compile a program for distrubution using "p -c test", and/or use the gui front-end.
-- Rebuild the compiler in seconds using "p -c p", with no other tools/software needed.
-- Test compiler modifications using "p p test".
--
--format PE32
--format PE64
include builtins\pcase.e as pcase -- upper(), lower()
--include pmain.e -- main parser
include eval.e -- main parser
--include profile.e -- profile, profile_time, and opStats reporting
--include builtins\VM\pProfile.e
--include plist.e -- assembly and symbol table dump
--include builtins\VM\pMemChk.e -- check_heap
--DEV find a way to run terror.exw full test... (a stub? two top-level includes?)
--DEV migrate these into bench.exw???
--DEV better: create a file test\alltests.txt to contain this...
-- Lines which do not begin with <tab><double quote> are ignored.
--
-- Most of these tests are mundane, some exhaustively so:
--
constant testset={
-- "..\\test\\t01type.exw",--[ 1] OK -- very basic type checking
"t01type.exw", --[ 1] OK -- very basic type checking
"t02parms.exw", --[ 2] OK -- simple parameter checking (oldish)
"t03showt.exw", --[ 3] OK -- more very basic type checking
"t04unary.exw", --[ 4] OK -- tests for unary minus and 'not'
"t05inc0.exw", --[ 5] OK -- a trivial include
"t06inc1.exw", --[ 6] OK -- basic namespaces and scope
"t07inc2.exw", --[ 7] OK -- multiple includes, all vars named 'z'
"t08inc22.exw", --[ 8] OK -- multiple includes, different named vars
"t09inc3.exw", --[ 9] OK -- namespaced references to sub-includes [new feature]
"t10inc4.exw", --[10] OK -- more trivial includes (oldish)
"t11inc5.exw", --[11] OK -- subdirectory include [new feature]
"t12inc6.exw", --[12] OK -- more trivial multiple includes
"t13inc7.exw", --[13] OK -- automatic global resolution [new feature]
"t14inc8.exw", --[14] OK -- more ""
"t15inc9.exw", --[15] OK -- more trivial includes (oldish)
"t16incD.exw", --[16] OK -- test ../same is skipped
"t17incV.exw", --[17] OK -- test crazy \\/ and uPPER/LowerCase handling
"t18equal.exw", --[18] OK -- stress test of [not] equal (!=/=)
"t19find.exw", --[19] OK -- quick test of find()
"t20cast.exw", --[20] OK -- primitive assignments and type checks
"t21ret1.exw", --[21] OK -- simple function returns
"t22cmp.exw", --[22] OK -- stress test compare and relops
"t23subsc.exw", --[23] OK -- trivial subscript tests
"t24slice.exw", --[24] OK -- stress test slice ops
"t25rmdr.exw", --[25] OK -- stress test remainder()
"t26aprnd.exw", --[26] OK -- stress test append/prepend
"t27rpeat.exw", --[27] OK -- trivial test of repeat
"t28prntf.exw", --[28] OK -- trivial printf tests [pprntf.e]
"t29for.exw", --[29] OK -- for loop test [performance needs improving]
"t30prime.exw", --[30] OK -- a simple prime number function test
"t31sce.exw", --[31] OK -- short circuit tests (oldish)
"t32sprnt.exw", --[32] OK -- simple sprint() tests
"t33seqop.exw", --[33] OK -- (old) sequence tests
"t34andor.exw", --[34] OK -- simple and/or tests (oldish)
"t35cncat.exw", --[35] OK -- stress test the & operator
"t36match.exw", --[36] OK -- stress test match() function
"t37misc.exw", --[37] OK -- power/log/atom_to_float32/lower etc
"t38bltns.exw", --[38] OK -- check builtins/ compile cleanly
--DEV add:
--t39fio.exw
--t39riomini.exw
"t39rndio.exw", --[39] OK -- random i/o on 30K file till done
"t40rtnid.exw", --[40] OK -- tests on routine_id, call_proc etc.
"t41infan.exw", --[41] OK -- tests on inf and nan handling
"t42cback.exw", --[42] OK -- call_back tests
"t43tchk.exw", --[43] OK -- simple user defined type checks
"t44silly.exw", --[44] OK -- recursive return test (ie the function f() returns f() case)
"t45aod.exw", --[45] OK -- an assignment on declaration problem test
--DEV p64 -c t46 is broken (put back in a broken state 17/12/20)
"t46ltype.exw", --[46] OK -- localtype tests
"t47ltth.exw", --[47] OK -- localtype test harness, for tweakers of Assignment() in pmain.e
--DEV top-level abort(0) kills the run...
"t48init.exw", --[48] OK -- init tests ** not implemented/suboptimal **
--DEV p64 -c t49 is broken (now excluded below)
"t49ginfo.exw", --[49] OK -- gvar_scan final results tests.
--Fine, but needs annoying edit
"t50gscan.exw", --[50] OK -- some snippets which gave pgscan.e a hard time.
"t51nstc.exw", --[51] OK -- some tests for an upgrade to Expr().
"t52oparm.exw", --[52] OK -- optional parameter tests.
"t53switch.exw", --[53] OK -- switch tests [DEV incomplete].
"t54inc.exw", --[54] OK -- include bugfix (18/01/2012) part 1.
"t55incinc.exw", --[55] OK -- include bugfix (18/01/2012) part 2.
"t56inc.exw", --[56] OK -- ReLinkAsGlobal bugfix (27/12/2012)
--DEV broke 22/4/15: (seems ok now, even on lnx!)
"t57masgn.exw", --[57] OK -- test multiple assignment.
"t58rtxt.exw", --[58] OK -- file i/o tests
"t59mri.exw", --[59] OK -- test mutually recursive includes
"t60td.exw", --[60] OK -- timedate tests
--DEV this is a very windows-centric test, need something quite different for linux: (now excluded on LINUX)
"t61cffi.exw", --[61] OK -- cffi tests
"t62utf.exw", --[62] OK -- test the utf conversion routines
"t63regex.exw", --[63] OK -- test the regular expression routines
"t64struct.exw", --[64] OK -- test the new struct/class syntax
"t65filter.exw", --[65] OK -- test the filter() builtin
"t66prec.exw", --[66] OK -- test precedence handling (about time!)
"t67dicts.exw", --[67] OK -- test dictionaries (about time!)
"t68forin.exw", --[68] OK -- test the new for..in construct
"t69infnan.exw", --[69] OK -- test is_nan() and is_inf()
"t70nested.exw", --[70] OK -- test nested functions
"t71decode_flags.exw", --[71] OK -- test decode_flags()
"..\\demo\\mandle.exw", --[72] OK -- simple ascii mandlebrot demo
"..\\demo\\combo.exw", --[73] OK -- simple combinations function
"..\\demo\\takeuchi.exw",--[74] OK -- stress test function calls
-- "..\\demo\\arwen\\demo_controls.exw",
-1}
-- mainpath = rootpath&"test\\" -- see also smp under testall
-- mainfile = testset[14]
-- mainfile = "test9.exw" -- message box hook (OK)
-- mainpath = ""
-- mainfile = "pt.exw"
-- mainfile = "pt2.exw"
-- mainfile = "pt3.exw"
-- mainfile = "pgui.exw"
-- mainpath = "c:\\temp\\lzj\\"
-- mainfile = "lzjb.exw"
--
-- The demos that came with arwen:
--
-- mainpath = "demo\\arwen\\"
-- mainfile = "demo_controls.exw" -- OK
-- mainfile = "demo_curve_fit.exw" -- OK
-- mainfile = "demo_idle.exw" -- OK
-- mainfile = "demo_lists.exw" -- OK
-- mainfile = "demo_memo.exw" -- OK
-- mainfile = "demo_menus.exw" -- OK
-- mainfile = "demo_menus_od.exw" -- OK -- BUGS (same on RDS Eu)
-- mainfile = "demo_msgtraps.exw" -- OK
-- mainfile = "demo_progress.exw" -- OK
-- mainfile = "demo_resizing.exw" -- OK
-- mainfile = "demo_sysmenu.exw" -- OK
-- mainfile = "demo_tabs.exw" -- OK
-- mainfile = "demo_timer.exw" -- OK
-- mainfile = "demo_toolbar.exw" -- OK (null program)
-- mainfile = "demo_viewer.exw" -- OK
------ and a few of my own:
-- mainfile = "demo_listview.exw" -- OK
-- mainfile = "demo_treeview.exw" -- OK
-- mainfile = "demo_lbfc.exw" -- OK
-- mainfile = "demo_mmsd.exw" -- [missing]
-- mainfile = "pae\\mmsd.exw" -- OK
-- mainfile = "demo_vtext.exw" -- OK
-- mainfile = "generic.exw" -- OK
-- mainfile = "viewa.exw" -- OK
-- mainpath = rootpath&"demo\\"
-- mainfile = "Mandle.exw" -- OK (and 33 times faster than Eu!) (erm, 20...)
-- mainfile = "call.exw" -- OK (needed a fair few mods to asm.e though)
-- mainfile = "combo.exw" -- OK
-- mainfile = "goto.exw" -- OK (WARNING: different results are to be expected from
-- -- {p goto|exw goto} vs. {p -c goto|goto.exe|exw p goto}
-- -- - of course in the latter there is an implied -c)
-- mainfile = "hd.exw" -- OK
-- mainfile = "takeuchi.exw" -- OK
-- mainfile = "sanity.exw" -- OK
--?? mainfile = "clip.exw"
--also, that printf number too big for %x or %o format message. (one day)
--*** -- set_rand() [commented out for now]
--*** -- for loop control var not integer...
--*** -- for loop limit not integer (commented out in overflow())
-- sequence op (mul) (commented out in sequence_ops)
--*** -- for loop in atomic_ops() crashes [commented out]
--*** -- divide by 0 to get traceback... (need to get debug working!)
-- mainfile = "db01.exw"
-- mainpath = rootpath&"new\\"
-- mainfile = "t2.exw" -- OK, (make me a demo) [DEV]
-- quick test to ensure we get the ones out of \builtins not EUDIR\include:
-- mainpath = ""
-- mainfile = "get.e" -- OK
-- mainfile = "file.e" -- OK
-- mainfile = "sort.e" -- OK
-- mainfile = "misc.e" -- OK
-- mainfile = "dll.e" -- OK (after several routines [opcodes in Pve] commented out)
-- mainfile = "graphics.e" -- OK (almost completely commented out)
-- mainfile = "image.e" -- OK
-- mainfile = "mouse.e" -- all commented out (not supported for windows)
-- mainfile = "msgbox.e" -- OK
-- mainfile = "wildcard.e" -- OK (upper & lower removed, in pcase.e for Pve)
-- mainfile = "image.e" -- OK
-- mainfile = "machine.e" -- OK
-- mainfile = "safe.e"
-- mainfile = "database.e" -- OK, needs more testing
-- mainfile = "ppp.e" -- OK
-- mainfile = "arwen.ew" -- OK
-- mainpath = "demo\\win32lib\\"
-- mainfile = "win32lib.ew"
-- mainfile = "win32lib.ewx"
--
-- type error win32lib.ew line 18909:
-- if atom(lRefControl) or ..., where lRefControl had been defined as a
-- sequence. Removed the spurious test.
--
-- also, from Posetf, win32lib.ew line 11696, 16353, 23758, 23872, 25701, 30397:
-- vStreamCBPosn = floor(lEnd + 1) -- floor added PL 21/10
-- bgControl = floor(pOwner) -- floor added PL 21/10
-- lStart = floor(lNextElem) -- floor added PL 21/10
-- lTextPrinted = floor(lNextElem) -- floor added PL 21/10
-- offset = floor(address) -- floor added PL 21/10
-- origpos = floor(pos) -- floor added PL 22/10
--
-- win32lib.ew line 23352 for i = 0 to wParam, replaced with
-- for i = 0 to floor(wParam), also line 23335.
--
-- w32msgs.e 109: crash_message() undefined
-- mainfile = "CenterIt.exw"
-- mainpath = "C:\\Program Files\\Phix\\demo\\win32lib\\Demo\\"
-- mainfile = "Advanc.exw" -- OK
-- mainfile = "aktb.exw" -- OK
-- mainfile = "CenterIt.exw" -- OK
-- mainfile = "appselect.exw" -- OK
-- mainfile = "backcolor.exw" -- OK
-- mainfile = "BIGDOTS.EXW" -- OK
-- mainfile = "biglistview.exw" -- OK
-- mainfile = "bitmap.exw" -- OK
-- mainfile = "bitmap_zoom.exw" -- OK-ish (buggy demo, same on RDS)
-- mainfile = "BitMap10.exw" -- OK
-- however I had a Fatal exception which appeared to be a duff header...
-- disk space was v.low, so it could be that pfio.asm is not detecting
-- write/flush fails properly...
-- mainfile = "BitMap14.exw" -- OK
-- mainfile = "bitmap3.exw" -- OK
-- mainfile = "BitmapPrint.exw" -- OK
-- mainfile = "BitmapText.EXW" -- OK
-- mainfile = "BkGnd16.EXW" -- OK
-- mainfile = "boxes.exw" -- OK
-- mainfile = "Buttons5.exw" -- OK
-- mainfile = "Center1.exw" -- OK
-- mainfile = "charbmp.exw" -- OK
-- mainfile = "child4.exw" -- OK
-- mainfile = "childw.exw" -- OK
-- mainfile = "childw1.exw" -- OK
-- mainfile = "childw2.exw" -- OK
-- mainfile = "childw3.exw" -- OK
-- mainfile = "click.exw" -- OK
-- mainfile = "clientarea.exw" -- OK
-- mainfile = "clock.exw" -- OK
-- mainfile = "clock2.exw" -- OK
-- mainfile = "colorbtn.exw" -- OK
-- mainfile = "colorlabel.exw" -- OK
-- mainfile = "colorlabel2.exw" -- OK
-- mainfile = "colorlbl.exw" -- OK
-- mainfile = "colors.exw" -- OK
-- mainfile = "combo.exw" -- OK
-- mainfile = "ComboBoxEx.EXW" -- OK
-- mainfile = "ctrlq.exw" -- OK
-- mainfile = "destroy.exw" -- OK
-- mainfile = "destroy2.exw" -- OK
-- mainfile = "dicethrow.exw" -- OK
-- mainfile = "display.exw" -- OK
-- mainfile = "doevent.exw" -- OK
-- mainfile = "dosbox.exw" -- OK
-- mainfile = "dots.exw" -- OK
-- mainfile = "drawing2.exw" -- OK
-- mainfile = "drawRecTest.exw" -- OK
-- mainfile = "drawtext.exw" -- OK
-- mainfile = "EditBoxes.exw" -- OK
-- mainfile = "eucompress.exw" -- ?
-- mainfile = "ex00.exw" -- OK
-- mainfile = "EX01.EXW" -- OK
-- mainfile = "EX02.EXW" -- OK
-- mainfile = "EX03.EXW" -- OK
-- mainfile = "EX04.EXW" -- OK
-- mainfile = "EX05.EXW" -- OK
-- mainfile = "EX06.EXW" -- OK
-- mainfile = "EX07.EXW" -- OK
-- mainfile = "ex08.exw" -- OK
-- mainfile = "EX09.EXW" -- OK (required seq op fix/remove w32iff in setFont)
-- mainfile = "EX10.EXW" -- OK
-- mainfile = "EX11.EXW" -- OK
-- mainfile = "EX12.EXW" -- OK
-- mainfile = "EX13.EXW" -- OK
-- mainfile = "EX14.EXW" -- OK
-- mainfile = "ex15.exw" -- broke (same on RDS)
-- mainfile = "ex16.exw" -- OK
-- mainfile = "EX17.EXW" -- OK
-- mainfile = "EX18.EXW" -- OK
-- mainfile = "EX19.EXW" -- OK
-- mainfile = "EX20.EXW" -- OK
-- mainfile = "EX21.EXW" -- OK
-- mainfile = "EX22.EXW" -- OK
-- mainfile = "EX23.EXW" -- OK
-- mainfile = "F1Key.exw" -- OK
-- mainfile = "fastLV.exw" -- OK
-- mainfile = "fileprop.exw" -- OK
-- mainfile = "FindFile.EXW" -- OK
-- mainfile = "findstr.exw" -- OK
-- mainfile = "FlatToolBar.EXW" -- OK
-- mainfile = "focus.exw" -- **** BUG **** (closes immediately)
-- mainfile = "focus2.exw" -- OK
-- mainfile = "fullscreen.exw" -- OK
-- mainfile = "GENERIC.EXW" -- broken (same on RDS Eu)
-- mainfile = "getClientRect.exw" -- OK
-- mainfile = "getfile.exw" -- OK
-- mainfile = "getfocus.exw" -- OK
-- mainfile = "GetMfiles.EXW" -- OK
-- mainfile = "gradfil.exw" -- OK
-- mainfile = "groupadv.exw" -- OK
-- mainfile = "grouptab.exw" -- OK
-- mainfile = "HANDLERS.EXW" -- OK
-- mainfile = "hexes.exw" -- OK
-- mainfile = "hintwidth.exw" -- OK
-- mainfile = "HOV.EXW" -- OK
-- mainfile = "hover.exw"
-- mainfile = "icon00.exw" -- OK
-- mainfile = "idle.exw" -- OK
-- mainfile = "imageview.exw"
-- mainfile = "initfocus.exw" -- OK
-- mainfile = "inScreenPointIn.exw"-- OK
-- mainfile = "kick2.exw" -- OK
-- mainfile = "KM.EXW" -- ? phroom ?
-- mainfile = "life.exw" -- OK
-- mainfile = "list_additem.exw"
-- mainfile = "listdemo.exw"
-- mainfile = "listpop.exw"
-- mainfile = "listsync.exw"
-- mainfile = "listtabs.exw"
-- mainfile = "ListTreeView.EXW"
-- mainfile = "listtreeview2.exw"
-- mainfile = "listview.exw" -- OK
-- mainfile = "listview2.exw"
-- mainfile = "listview3.exw"
-- mainfile = "listviewbox.exw"
-- mainfile = "ListViewEdit.exw"
-- mainfile = "ListViewStyles.exw"
-- mainfile = "ListViewStyles2.exw"
-- mainfile = "listwin.exw"
-- mainfile = "loadlv1.exw"
-- mainfile = "loadlv2.exw"
-- mainfile = "loadlv3.exw"
-- mainfile = "long.exw"
-- mainfile = "lostfocus.exw"
-- mainfile = "lvcol.exw"
-- mainfile = "lvheadings.exw"
-- mainfile = "lvicon.exw"
-- mainfile = "lvicons.exw"
-- mainfile = "lvsetindexcoba.exw"
-- mainfile = "MAKEDOC.EXw"
-- mainfile = "MDI01.EXW"
-- mainfile = "Menu08.exw"
-- mainfile = "menubang.exw"
-- mainfile = "menuchk.exw"
-- mainfile = "mle_write.exw"
-- mainfile = "mletext.exw"
-- mainfile = "modal.exw"
-- mainfile = "modaltab.exw"
-- mainfile = "ModalWin.EXW"
-- mainfile = "MonthCalendar.EXW"
-- mainfile = "Mouse.dat"
-- mainfile = "mousetrap.exw"
-- mainfile = "MsgBox.exw"
-- mainfile = "MultiDialog.exw"
-- mainfile = "multisel.exw"
-- mainfile = "mwheel.exw"
-- mainfile = "nested_groups.exw"
-- mainfile = "notify.exw" -- OK
-- mainfile = "ntb.exw" -- OK
-- mainfile = "openfile.exw"
-- mainfile = "PageSetupDlg.EXW"
-- mainfile = "paintevent.exw"
-- mainfile = "parsexpm.exw"
-- mainfile = "password.exw"
-- mainfile = "peekstring.exw"
-- mainfile = "playsounds.exw"
-- mainfile = "pokie.exw" -- OK
-- mainfile = "popupwindow.exw"
-- mainfile = "PRETEND.EXW" -- OK
-- mainfile = "printerlines.exw"
-- mainfile = "PrintRichText.EXW"
-- mainfile = "progressbar.exw"
-- mainfile = "pw2.exw"
-- mainfile = "radios.exw"
-- mainfile = "randdots.exw" -- OK
-- mainfile = "rclick.exw"
-- mainfile = "ReBar.EXW"
-- mainfile = "RESIZE.EXW"
-- mainfile = "resizebmp.exw"
-- mainfile = "RichEdit.EXW"
-- mainfile = "richedit1.exw"
-- mainfile = "richedit2.exw"
-- mainfile = "rolling_die_2.exw" -- OK
-- mainfile = "rotated_text.exw" -- OK
-- mainfile = "rt.exw" -- broke (same on RDS)
-- mainfile = "RtClick.exw"
-- mainfile = "RTI.ex"
-- mainfile = "rubbish.txt"
-- mainfile = "rundemo.hpc"
-- mainfile = "RUNDEMO.HTX"
-- mainfile = "RunDemos.exw" -- OK (ish, ...)
-- mainfile = "RunDemos.lst"
-- mainfile = "saveas.exw"
-- mainfile = "Scramble.exw"
-- mainfile = "scroll.EXW"
-- mainfile = "scroll2.exw"
-- mainfile = "SCROLL3.EXW"
-- mainfile = "scroller.exw"
-- mainfile = "selectFolder.exw"
-- mainfile = "SETFOCUS.EXW"
-- mainfile = "setinitfocus.exw"
-- mainfile = "setmouse.exw"
-- mainfile = "setvis.exw"
-- mainfile = "shexec.exw"
-- mainfile = "showfile.exw"
-- mainfile = "showtext.exw"
-- mainfile = "simple_flatToolBar.EXW"
-- mainfile = "simple_list.exw"
-- mainfile = "simplelist.exw"
-- mainfile = "smalllv.exw"
-- mainfile = "splash.exw"
-- mainfile = "sprite.exw"
-- mainfile = "StatBar1.EXW"
-- mainfile = "StatBar2.EXW"
-- mainfile = "swin.exw" -- OK
-- mainfile = "tab_arrow.exw"
-- mainfile = "tabclick.exw"
-- mainfile = "tabCnt.exw"
-- mainfile = "TABCOLOR.EXW"
-- mainfile = "tabcontrol.exw"
-- mainfile = "tabcontrol2.exw"
-- mainfile = "TabItemDelete.exw"
-- mainfile = "tabListView.exw"
-- mainfile = "tesrtf.exw"
-- mainfile = "timer.exw"
-- mainfile = "ToolBar.EXW"
-- mainfile = "Tooltip.EXW"
-- mainfile = "tooltip_dynamic.exw"
-- mainfile = "trackbar.exw"
-- mainfile = "TranslatedIdeText.exw"
-- mainfile = "translbl.exw"
-- mainfile = "treevclick.exw"
-- mainfile = "treeview.exw"
-- mainfile = "treeview2.exw"
-- mainfile = "treeview3.exw"
-- mainfile = "tvchecked.exw"
-- mainfile = "tvedit.exw"
-- mainfile = "tvSave.EXW"
-- mainfile = "twowin.exw"
-- mainfile = "UpDown.EXW"
-- mainfile = "virt_lv.exw"
-- mainfile = "visibility.exw"
-- mainfile = "WalkDir.EXW"
-- mainfile = "window.exw"
-- mainfile = "wordcatcher.exw"
-- mainfile = "wprint.exw"
-- mainfile = "WrtLabel.EXW"
-- mainfile = "wscore.exw"
-- mainfile = "wscroll.exw"
-- mainfile = "Wstyles.EXW" -- OK
-- mainfile = "www.exw"
-- mainpath = "C:\\Program Files\\Edita\\"
-- mainfile = "test.exw"
-- mainfile = "edita.exw" -- OK 30/3/08 (bar the label colour problem!)
-- floor() required database.e 359:
-- for t = 1 to ntables do
-- made ntables an integer (was atom)
-- ditto line 371 (for r = 1 to tnrecs do)
-- ditto line 425 (for i = 1 to free_count do)
-- ditto line 747 (for i = 1 to nt do)
-- ditto line 788 (for j = 1 to block_size do)
-- ditto line 1072 (for i = key_location to nrecs+1 do)
-- ditto line 1207 (for i = key_location to nrecs do)
--
-- Not sure about this one [DEV]: edita.exw line 5006
-- or (msg = WM_ENDSESSION and wParam) then return saveAllFilesAndINI()
-- replaced with:
-- or (msg = WM_ENDSESSION and wParam!=0) then return saveAllFilesAndINI()
---- -- eamenus.ew line 1241: for i = 1 to length(menuset) do gives type error;
---- -- replaced line 1216 (for i = M_File to E_SelM do) with:
---- -- for i = floor(M_File) to floor(E_SelM) do
-- mainfile = "tedb.exw" -- OK 15/11/08
-- mainpath = "C:\\temp\\calc\\"
-- mainfile = "calc.exw" -- sequence op line 210, plus 3 in the testset,
-- Phix gets 3.2834812058e+272,
-- RDS Eu 3.283481206e+272, (close enough or better, I say!)
-- OK 30/3/08
include builtins\syswait.ew
atom k32=0, xDeleteFile, user32, xBeep
constant stdBeep = {-1}
procedure pinit() -- platform()=WINDOWS only
k32 = open_dll("kernel32.dll")
xDeleteFile = define_c_func(k32,"DeleteFileA",{C_PTR},C_LONG)
--DEV there's a Beep in kernel32?! (cross-platform beep() rqd)
user32 = open_dll("user32.dll")
xBeep = define_c_proc(user32, "MessageBeep", {C_INT})
end procedure
--DEV cross-platform builtin rqd:
procedure Delete(sequence filename)
-- filename is "pnew.exe", "pnew2.exe", "pnew", or "pnew2".
-- not critical should this fail.
--atom fstr
integer tries = 0
-- if platform()=WINDOWS then
-- if k32=0 then pinit() end if
-- fstr = allocate_string(filename)
-- while not c_func(xDeleteFile,{fstr}) do
-- tries += 1
-- if tries>20 then
-- puts(1,"(gave up)\n")
-- exit
-- end if
-- puts(1,filename&" in use, retrying..\n")
-- sleep(tries) -- 1,2,3...20 total 210 secs (3 mins 30 secs)
-- end while
-- free(fstr)
-- else
-- ?9/0
-- system("rm "&filename)
-- delete_file(filename)
while not delete_file(filename) do
tries += 1
if tries>20 then
puts(1,"(gave up)\n")
exit
end if
puts(1,filename&" in use, retrying..\n")
sleep(tries) -- 1,2,3...20 total 210 secs (3 mins 30 secs)
end while
-- end if
end procedure
procedure Retry(sequence msg)
puts(1,msg)
if platform()=WINDOWS then
if k32=0 then pinit() end if
c_proc(xBeep,stdBeep)
else
puts(1,7)
end if
sleep(1)
if find(get_key(),"nN") then abort(1) end if
puts(1,"\n")
end procedure
procedure OverWrite(sequence pw, integer fn, integer fin, integer oc)
-- pw ("pw.exe" or "p.exe") has just been successfully opened ("wb"),
-- as file number fn; copy newly created and verified pnew.exe to it,
-- from file number fin, and patch the subsystem in the pw.exe case.
-- oc is 0 (zero) for Overwrite, 1 for Create.
integer c
if platform()!=LINUX then
if oc then
puts(1,"Creating ")
else
puts(1,"Overwriting ")
end if
-- puts(1,pw&"\n")
puts(1,pw)
end if
while 1 do
c = getc(fin)
if c=-1 then exit end if
puts(fn,c)
end while
close(fin)
if platform()=WINDOWS then
if equal(pw,"pw.exe")
or (equal(pw,"p.exe") and oc=1) then
if seek(fn,#DC)!=0 then
puts(1,"\n\n**seek error on pw.exe**\n\nPress Enter...")
if wait_key() then end if
abort(1)
end if
if equal(pw,"pw.exe") then
puts(fn,2) -- IMAGE_SUBSYSTEM_WINDOWS_GUI
else
puts(fn,3) -- IMAGE_SUBSYSTEM_WINDOWS_CUI
end if
end if
end if
close(fn)
end procedure
function pnew()
return iff(platform()=WINDOWS?"pnew.exe":"pnew")
end function
function pnew2()
return iff(platform()=WINDOWS?"pnew2.exe":"pnew2")
end function
procedure verify_build()
-- 1) Check that pnew[.exe] and pnew2[.exe] are binary identical,
-- if not abort with 1 to signal failure.
integer fn, fn2, c, c2
sequence doOther
printf(1,"verifying %s==%s",{pnew(),pnew2()})
fn = open(pnew(),"rb")
fn2 = open(pnew2(),"rb")
if fn!=-1 and fn2!=-1 then
while 1 do
c = getc(fn)
c2 = getc(fn2)
if c!=c2 then fn = -1 exit end if
if c=-1 then exit end if
end while
end if
if fn=-1 or fn2=-1 then
puts(1,"\n\nRebuild unsuccessful, sorry\n\nPress Enter...")
if wait_key() then end if
abort(1)
end if
puts(1," OK\n")
close(fn2)
if seek(fn,0)!=0 then
printf(1,"\n\n**seek error on %s**\n\nPress Enter...",{pnew()})
if wait_key() then end if
abort(1)
end if
--
-- 2) The most likely case is p.exe is in use, as it is still running
-- from the original "p -c p" command. Alternatively, it all started
-- with "pw -c p" so pw.exe is still in use. This is an operating
-- system feature: rather than load the whole of p.exe (or any other
-- executable) into ram, it loads just the first few sectors, and
-- keeps p.exe open/in use throughout, in case it needs to load the
-- remainder and/or swap out some code pages should memory run low.
-- (If a code page has been modified, it goes to the normal swap
-- file, if not the os knows it can just re-load it from p.exe.)
-- This means that p.exe simply cannot be used to directly overwrite
-- p.exe however hard you try, instead an indirect route is needed.
--
-- Repeatedly try to open p.exe or pw.exe, displaying a message while
-- both are in use. (Doing so seems easier than using command_line()
-- to decide which.) When/if we manage to open one, overwrite it and
-- immediately run it with "-pmkr5" or "-pmkr6" to do the other one.
-- By not waiting for this very last step we allow the calling process
-- to terminate and avoid an "in use deadlock".
--
-- Note: if you run say "p -cp" from Edita, when it runs "pw -pmkr5"
-- to overwrite p.exe and terminates, Edita may notice that the
-- p.exe process has finished and re-grab focus, which may mean
-- that retry messages from the pw.exe process are obscured.
-- I suppose we could try sending Edita a message along the
-- lines of "replace waiting for that p.exe to finish with
-- waiting for this pw.exe to finish", perhaps...
-- Let me know if this behaviour annoys or confuses you.
--
if platform()=WINDOWS then
while 1 do
fn2 = open("pw.exe","wb")
if fn2!=-1 then
OverWrite("pw.exe",fn2,fn,0)
-- doOther = mainpath&"pw.exe -pmkr5" -- ie DoOther("p.exe")
doOther = '\"'&mainpath&"pw.exe\" -pmkr5" -- ie DoOther("p.exe")
exit
end if
fn2 = open("p.exe","wb")
if fn2!=-1 then
OverWrite("p.exe",fn2,fn,0)
doOther = '\"'&mainpath&"p.exe\" -pmkr6" -- ie DoOther("pw.exe")
exit
end if
Retry("Both p.exe and pw.exe are in use - retry?")
end while
elsif platform()=LINUX then
doOther = '\"'&mainpath&"pnew2\" -pmkr5" -- ie DoOther("p")
end if
puts(1," OK\n")
printf(1,"==>system(%s)\n",{doOther})
system(doOther) -- (no wait)
abort(0)
end procedure
procedure DoOther(sequence ppw)
-- ppw is "p.exe" or "pw.exe", or "p" on Linux.
integer fn, firsttime, fin
firsttime = 1 -- (sleep(1) once only, and not once each for ppw & pnew.exe])
--DEV commented out 29/05 (check list.asm, see if I missed anything/there should be a fin=-1 as well)
-- fn = -1
while 1 do
fn = open(ppw,"wb")
if fn!=-1 then exit end if
if firsttime then
sleep(1)
firsttime = 0
else
Retry(ppw&" in use - retry?")
end if
end while
while 1 do
fin = open(pnew(),"rb")
if fin!=-1 then exit end if
if firsttime then
sleep(1)
firsttime = 0
else
Retry(sprintf("%s in use - retry?",{pnew()}))
end if
end while
OverWrite(ppw,fn,fin,0)
--
-- finally, try to delete pnew[.exe] and pnew2[.exe]:
--
Delete(pnew())
Delete(pnew2())
abort(0)
end procedure
--with trace
include pgets0.ew
sequence default_commandlines
integer lend,
didx -- default_commandlines index. Note our table is "backwards"
function keyHandler(integer ch, integer virtKey, sequence r)
--
-- return value: atoms are ignored and input continues.
-- a sequence s of length 1 is treated specially,
-- if s[1] is a sequence or an atom < ' ' then
-- input is terminated and that value is returned
-- (ie to the gets0() call), otherwise s is the
-- new/replacement value of input (obviously to
-- leave the input as-is, just return eg 0).
--
integer newidx
sequence t
if ch=0 then
newidx = 0
if virtKey=G0_UP then
newidx = didx+1
if newidx>lend then newidx = lend end if
elsif virtKey=G0_DOWN then
newidx = didx-1
if newidx<=0 then newidx = 1 end if
elsif virtKey=G0_PGUP then
newidx = lend
elsif virtKey=G0_PGDN then
newidx = 1
elsif virtKey=G0_F1 then
return {"?",0,G0_CTRLZ}
elsif virtKey=G0_F7 then
if lend then
for i=lend to 1 by -1 do
puts(1,'\n'&default_commandlines[i])
end for
puts(1,"\nuse (pg) up/down to select:")
cpos = 0
newidx = didx
else
puts(1,"\nempty:")
end if
elsif virtKey=G0_F8 then
if didx<lend then newidx = didx+1 else newidx = 1 end if
else
if platform()=WINDOWS then
if k32=0 then pinit() end if
c_proc(xBeep,stdBeep)
else
?9/0
end if
return 0
end if
if newidx and newidx<lend then
didx = newidx
-- return {default_commandlines[didx],-1,0} -- cursor at end of default
return {default_commandlines[didx],0,0} -- cursor at start of default
end if
elsif ch<G0_BACK -- ctrl ABDEFG
or ch=11 -- ctrl K
or (ch>=14 and ch<=25) then -- ctrl NOPQRSTUWXY
-- ignore funny chars (smiley faces etc)
-- (C is copy, H is BS, I is TAB, J is LF,
-- L is clear, M is cr, V is paste, Z is EOF)
if platform()=WINDOWS then
if k32=0 then pinit() end if
c_proc(xBeep,stdBeep)
else
?9/0
end if
return 0
elsif cpos=lr or cpos+overstrike=lr then
-- if adding a char or replacing last char
if overstrike and cpos<lr then
r[cpos+1] = ch
else
r &= ch
end if
for i=1 to lend do
t = default_commandlines[i]
if match(r,t)=1 then
newidx = i
-- found a match, check it is unique
for j=i+1 to lend do
t = default_commandlines[j]
if match(r,t)=1 then
newidx = 0
exit
end if
end for
if newidx then
t = default_commandlines[newidx]
if not equal(r,t) then
didx = newidx
return {t,cpos,ch}
end if
end if
exit
end if
end for
end if
return ch
end function
constant r_keyHander = routine_id("keyHandler")
function de_quote(sequence s)
if length(s)>1
and s[1]='\"'
and s[length(s)]='\"' then
s = s[2..length(s)-1]
end if
return s
end function
function decode_number(sequence s)
integer res = 0
integer ch
if length(s)=0 then ?9/0 end if
for i=1 to length(s) do
ch = s[i]
if ch<'0' or ch>'9' then ?9/0 end if
res = res*10 + (ch-'0')
end for
return res
end function
procedure show_cmd_help()
puts(1,"\ninterpret: <filename>\n")
-- puts(1,"compile: -c <filename> (aka -compile <filename>)\n")
puts(1,"compile: -c <filename>\n\n")
puts(1,"also: -d creates a list.asm file,\n")
puts(1," -nodiag creates a smaller list.asm file,\n")
puts(1," -norun may be useful in batch jobs,\n")
puts(1," -test, tnn, b, bt, etc, and of course\n")
puts(1," -c p, which rebuilds the compiler.\n")
puts(1," for more details\\options see pth.exw.\n\n")
-- puts(1,"run tests: -test\n")
-- puts(1,"specific test: tnn [as test\\tnn*.exw, provided tnn.exw not found]\n")
-- puts(1,"benchmarks: b [as bench\\bench.exw, provided b.exw not found]\n")
-- puts(1,"last bench: bt [as bench\\benchtst.exw, provided bt.exw not found]\n")
-- puts(1,"dump: -d <filename> (aka -dump, -l, -list, -listing) --> list.asm\n")
-- puts(1,"nodiag: -nodiag <filename> (makes for a smaller -d listing)\n")
-- puts(1,"norun: -norun <filename> (normally used with -c in a batch file)\n")
-- puts(1,"visit website: -www\n\n")
puts(1,"Wildcards are allowed, as long as they select a single file, \n")
puts(1," with \".exw\" assumed, eg \"demo\\tak*\" runs demo\\takeuchi.exw.\n\n")
-- puts(1," For more details, eg rebuilding the compiler, see pth.exw.\n")
-- puts(1,"Press F7 to list prompt history, up/down to select (kept in p.ini).\n\n")
puts(1,"Press F7 to list prompt history, up/down to select.\n\n")
-- puts(1,"\ninterpret: <filename>\n")
-- puts(1,"compile: -c <filename> (aka -compile <filename>)\n")
-- puts(1,"run tests: -test\n")
-- puts(1,"specific test: tnn [as test\\tnn*.exw, provided tnn.exw not found]\n")
-- puts(1,"benchmarks: b [as bench\\bench.exw, provided b.exw not found]\n")
-- puts(1,"last bench: bt [as bench\\benchtst.exw, provided bt.exw not found]\n")
-- puts(1,"dump: -d <filename> (aka -dump, -l, -list, -listing) --> list.asm\n")
-- puts(1,"nodiag: -nodiag <filename> (makes for a smaller -d listing)\n")
-- puts(1,"norun: -norun <filename> (normally used with -c in a batch file)\n")
-- puts(1,"visit website: -www\n\n")
-- puts(1,"Wildcards are allowed, as long as they select a single file, with \n")
-- puts(1," \".exw\" assumed, eg \"demo\\tak*\" runs demo\\takeuchi.exw.\n")
-- puts(1," For more details, eg rebuilding the compiler, see pth.exw.\n")
-- puts(1,"Press F7 to list prompt history, up/down to select (kept in p.ini).\n\n")
-- puts(1,"command line is:")
-- ?command_line()
end procedure
sequence params
params = {}
procedure processCommandLine()
object x0
sequence default_commandline
string x
integer dfn, ch, k, k1, x1, xk, lencl, lenx
integer pfn, pwfn
--/**/atom R
sequence cl
sequence verinfo
--trace(1)
cl = command_line()
cl1 = cl[1]
while 1 do -- 17/8
if length(cl)<3 then
--removed 16/07/2013:
---- if r_proemh!=-1 then -- if perror.ew included by pmsgs.e
-- if get_r_proemh()!=-1 then -- if perror.ew included by pmsgs.e
------DEV run it under Phix!!! (IE: US, NOW!!)
-- if sequence(dir("pgui.exw")) then
-- mainpath = current_dir()&SLASH
-- mainfile = "pgui.exw"
-- return
-- elsif sequence(dir("pgui.exe")) then
-- system("pgui.exe",2)
-- abort(0)
-- end if
-- end if
-- version number is major.minor.bugfix
puts(1,"Phix hybrid interpreter/compiler.\n\n")
-- puts(1,"as modified by <insert your name here>\n")
--DEV we should do some #ilasm here to obtain correct version/build no,
-- and pemit.e should auto-increment something:
verinfo = phixversion&machine_bits()
-- verinfo = version()&machine_bits() -- (would be equivalent)
verinfo = append(verinfo,iff(platform()=WINDOWS?"Windows":"Linux"))
-- verinfo = version()&{machine_bits(),iff(platform()=WINDOWS?"Windows":"Linux")} -- (also equivalent)
verinfo = append(verinfo,date()[DT_YEAR])
printf(1,"Version %d.%d.%d (%d bit %s) Copyright Pete Lomax 2006..%d\n\n",verinfo)
default_commandline = ""
-- default_commandlines = readpini() -- DEV/SUG... (or is pgui.exw running off a separate db?)
default_commandlines = {}
dfn = open("p.ini","r")
if dfn!=-1 then
while 1 do
x0 = gets(dfn)
if atom(x0) then exit end if
k = length(x0)
if k>1 and x0[k]='\n' then
x0 = x0[1..k-1]
default_commandlines = append(default_commandlines,x0)
end if
end while
close(dfn)
end if
lend = length(default_commandlines)
didx = 0
if lend then
default_commandline = default_commandlines[1]
end if
while 1 do
--DEV it should also recognise "p -?"
puts(1,"Enter ? for options or filename to execute")
-- if sequence(default_commandline) then
-- printf(1,"[%s]",{default_commandline})
-- end if
puts(1,":")
if platform()=WINDOWS then
g0_addcr = 0 -- (do not append cr, please)
-- x0 = gets0(r_keyHander,default_commandline,0)
x0 = gets0(r_keyHander,"",0)
-- x0 = gets0(r_keyHander,"",-1)
g0_addcr = 1 -- (reset to default, just in case)
else
x0 = gets(0)
if atom(x0) then
pemit2free()
abort(0)
end if
if length(x0) and x0[$]='\n' then x0 = x0[1..$-1] end if
end if
puts(1,"\n")
-- if not equal(x0,"?\n") then exit end if
if not equal(x0,"?") then exit end if
show_cmd_help()
end while
--trace(1)
-- if atom(x0) then abort(0) end if
-- if atom(x0) then abort(0) end if
x = x0
lenx = length(x)
-- if lenx and x[lenx]='\n' then
-- lenx -= 1
-- x = x[1..lenx]
-- end if
-- if lenx=0 then
-- if atom(default_commandline) then abort(0) end if