Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6446 GerdtR 1
#define _ERRORS_
2
 
3
4
 
5
 
6
 
7
	warningprint,1,warningprint,1,warningprint,1,warningprint,1,warningprint,1,
8
 
9
10
 
11
12
 
13
unsigned char mapfile=FALSE;
14
 
15
16
 
17
 
18
 
19
/* ================== error messages start =========================== */
20
 
21
 
22
 
23
//	while(tok!=tk_eof&&itok2.type!=tp_stopper/*tok2!=tk_semicolon&&tok2!=tk_camma*/){
24
 
25
		nexttok();
26
 
27
//	}
28
 
29
 
30
 
31
{
32
 
33
	inptr=inptr2;
34
 
35
 
36
 
37
	linenum2=linenumber;
38
 
39
 
40
 
41
void FindEndLex()
42
 
43
	while(tok2!=tk_semicolon&&tok!=tk_eof)nexttok();
44
 
45
46
 
47
{
48
 
49
}
50
 
51
void  preerror3(char *str,unsigned int line,unsigned int file)//error message at a different than current line
52
 
53
	if(error
54
 
55
		sprintf((char *)string3,"%s(%d)#%d> %s.\n",startfileinfo==NULL?"":(startfileinfo+file)->filename,line,error,str);
56
 
57
 
58
 
59
	}
60
 
61
}
62
 
63
void internalerror (char *str)// serious internal compiler error message
64
 
65
char buf[200];
66
 
67
	preerror(buf);
68
 
69
	printf("TOK:%d SEGM:%d POST:%d RM:%d number:%ld\n",tok,itok.segm,itok.post,itok.rm,itok.number);
70
 
71
	printf("TOK2:%d SEGM2:%d POST2:%d RM2:%d number2:%ld\n",tok2,itok2.segm,itok2.post,itok2.rm,itok2.number);
72
 
73
	exit(e_internalerror);
74
 
75
76
 
77
{
78
 
79
 
80
 
81
		case 1:
82
 
83
			break;
84
 
85
			strcpy(buferr,"2-nd ");
86
 
87
		case 3:
88
 
89
 
90
 
91
			sprintf(buferr,"%d-th ",type%256);
92
 
93
	}
94
 
95
	return buferr;
96
 
97
98
 
99
 
100
 
101
	sprintf(holdstr,"'%c' expected",ch);
102
 
103
}
104
 
105
void numexpected(int type)
106
 
107
char buf[40];
108
 
109
	preerror(buf);
110
 
111
112
 
113
{
114
 
115
	sprintf(buf,"%svariable expected",getnumoperand(type,"operand "));
116
 
117
}
118
 
119
void stringexpected()
120
 
121
	preerror("string expected");
122
 
123
 
124
 
125
{
126
 
127
}
128
 
129
void wordvalexpected()
130
 
131
	preerror("word value expected");
132
 
133
134
 
135
{
136
 
137
}
138
 
139
void qwordvalexpected()
140
 
141
	preerror("qword value expected");
142
 
143
144
 
145
{
146
 
147
}
148
 
149
 
150
 
151
	preerror("operator identifier expected");
152
 
153
154
 
155
{
156
 
157
}
158
 
159
void swaperror()
160
 
161
	preerror("invalid or incompatable swap item");
162
 
163
164
 
165
{
166
 
167
}
168
 
169
void idalreadydefined()
170
 
171
char holdstr[80];
172
 
173
	preerror(holdstr);
174
 
175
//	nexttok();
176
 
177
178
 
179
{
180
 
181
char buf[80];
182
 
183
	strlwr(smalltype);
184
 
185
	preerror3(buf,line);
186
 
187
188
 
189
{
190
 
191
}
192
 
193
 
194
 
195
	preerror("maximum output code size exceeded");
196
 
197
}
198
 
199
void unableopenfile(char *name)
200
 
201
char holdstr[256];
202
 
203
	preerror(holdstr);
204
 
205
206
 
207
 
208
 
209
}
210
 
211
void thisundefined(char *str,int next)
212
 
213
char holdstr[80];
214
 
215
	preerror(holdstr);
216
 
217
	if(next)FindStopTok();
218
 
219
220
 
221
 
222
 
223
	sprintf(buf,"%smemory variable expected",getnumoperand(type,"operand "));
224
 
225
	FindStopTok();
226
 
227
228
 
229
{
230
 
231
}
232
 
233
void tobigpost()
234
 
235
 
236
 
237
}
238
 
239
void unuseableinput()
240
 
241
	preerror("unuseable input");
242
 
243
}
244
 
245
 
246
 
247
	preerror("to many use logic compare");
248
 
249
250
 
251
{
252
 
253
}
254
 
255
 
256
 
257
	preerror("maximum output data size exceeded");
258
 
259
}
260
 
261
void errorreadingfile(char *name)
262
 
263
char buf[256];
264
 
265
 
266
 
267
268
 
269
{
270
 
271
	sprintf(buf,"bad input file '%s'",name);
272
 
273
}
274
 
275
 
276
 
277
char buf[64];
278
 
279
	sprintf(buf,"error declare %sparameters in function",getnumoperand(num,""));
280
 
281
}
282
 
283
void CompareOr()
284
 
285
 
286
 
287
288
 
289
{
290
 
291
}
292
 
293
void OnlyComFile()
294
 
295
 
296
 
297
298
 
299
{
300
 
301
	sprintf(buf,"error redeclare function \"%s\"",name);
302
 
303
}
304
 
305
 
306
 
307
	preerror("function has return type of void");
308
 
309
310
 
311
{
312
 
313
	sprintf(buf,"extra parameter in function %s",name);
314
 
315
 
316
 
317
void blockerror()
318
 
319
	preerror("illegal syntax within [ ]");
320
 
321
322
 
323
{
324
 
325
 
326
 
327
void notstructname()
328
 
329
	preerror("unique struct name expected");
330
 
331
332
 
333
{
334
 
335
 
336
 
337
		preerror(buf);
338
 
339
}
340
 
341
void expectederror(char *str)
342
 
343
char holdstr[80];
344
 
345
		sprintf(holdstr,"%s expected",str);
346
 
347
	}
348
 
349
350
 
351
{
352
 
353
 
354
 
355
void declareunion()
356
 
357
	preerror("Error declare union");
358
 
359
/*
360
 
361
{
362
 
363
} */
364
 
365
void segoperror()
366
 
367
	preerror("only '=' or '><' operands valid with segment register");
368
 
369
370
 
371
{
372
 
373
 
374
 
375
void regmathoperror()
376
 
377
	preerror("invalid operation for non-AX register math");
378
 
379
380
 
381
{
382
 
383
 
384
 
385
void negregerror()
386
 
387
	preerror("negative non-constant invalid for non-AX register math");
388
 
389
390
 
391
{
392
 
393
}
394
 
395
 
396
 
397
	preerror("specified 16 bit operand invalid for non-AL register math");
398
 
399
400
 
401
{
402
 
403
}
404
 
405
void regmatherror()
406
 
407
	preerror("invalid operand for non-AX register math");
408
 
409
 
410
 
411
{
412
 
413
}
414
 
415
void wordnotoper()
416
 
417
	preerror("word or int operands invalid for non-EAX register math");
418
 
419
 
420
 
421
{
422
 
423
	sprintf(buf,"%sword register expected",getnumoperand(type,"operand "));
424
 
425
}
426
 
427
void bytevalexpected(int type)
428
 
429
char buf[50];
430
 
431
 
432
 
433
434
 
435
{
436
 
437
 
438
 
439
void invalidfarjumpitem()
440
 
441
	preerror("invalid operand for FAR jump");
442
 
443
444
 
445
{
446
 
447
}
448
 
449
void begexpected(int type)
450
 
451
char buf[50];
452
 
453
 
454
 
455
456
 
457
{
458
 
459
	sprintf(buf,"%s32 bit register expected",getnumoperand(type,"operand "));
460
 
461
}
462
 
463
 
464
 
465
char buf[50];
466
 
467
	preerror(buf);
468
 
469
470
 
471
{
472
 
473
}
474
 
475
 
476
 
477
	preerror("byte constant or DX expected");
478
 
479
480
 
481
{
482
 
483
}
484
 
485
void invalidoperand(int type)
486
 
487
 
488
 
489
	preerror(buf);
490
 
491
492
 
493
{
494
 
495
	sprintf(buf,"%sMMX register expected",getnumoperand(type,"operand "));
496
 
497
 
498
 
499
void xmmregexpected(int type)
500
 
501
char buf[50];
502
 
503
	preerror(buf);
504
 
505
506
 
507
 
508
 
509
	sprintf(buf,"%sXMM register or memory varible expected",getnumoperand(type,"operand "));
510
 
511
}
512
 
513
void mmxregordwordexpected(int type)
514
 
515
char buf[60];
516
 
517
	preerror(buf);
518
 
519
 
520
 
521
{
522
 
523
}
524
 
525
void fpuvarexpected(int type)
526
 
527
char buf[70];
528
 
529
	preerror(buf);
530
 
531
532
 
533
 
534
 
535
	sprintf(buf,"%sexpected FPU register",getnumoperand(type,"operand "));
536
 
537
}
538
 
539
void fpu0expected()
540
 
541
	preerror("2-nd expected only st(0) fpu register");
542
 
543
544
 
545
{
546
 
547
 
548
 
549
void errstruct()
550
 
551
	preerror("illegal use of struct");
552
 
553
554
 
555
{
556
 
557
}
558
 
559
void ErrWrite()
560
 
561
	//fprintf(stderr,"unable to write output file.\n");
	printf("unable to write output file.\n");
562
 
563
 
564
 
565
{
566
 
567
}
568
 
569
void InvOperComp()
570
 
571
	preerror("invalid operation for compare");
572
 
573
 
574
 
575
{
576
 
577
	sprintf(buf,"%sexpected mmx register or memory variable",getnumoperand(type,"operand "));
578
 
579
}
580
 
581
void reg32orword(int type)
582
 
583
 
584
 
585
	preerror(buf);
586
 
587
588
 
589
{
590
 
591
	sprintf(buf,"Base class '%s' not defined",name);
592
 
593
 
594
 
595
void unknowntype()
596
 
597
	preerror("unknown type");
598
 
599
600
 
601
{
602
 
603
}
604
 
605
void unknownstruct (char *name,char *sname)
606
 
607
 
608
 
609
	preerror(buf);
610
 
611
612
 
613
{
614
 
615
	sprintf(buf,"unknown tag '%s'",name);
616
 
617
 
618
 
619
void unknownobj(char *name)
620
 
621
char buf[IDLENGTH+32];
622
 
623
	preerror(buf);
624
 
625
void q();
626
 
627
{
628
 
629
	sprintf(buf,"unknown parametr for #pragma %s",name);
630
 
631
 
632
 
633
/*-----------------08.08.00 22:49-------------------
634
 
635
	--------------------------------------------------*/
636
 
637
void warningoptnum()
638
 
639
	if(wact[0].usewarn)wact[0].fwarn("Optimize numerical expressions",linenumber,currentfileinfo);
640
 
641
 
642
 
643
{
644
 
645
	if(wact[1].usewarn){
646
 
647
	}
648
 
649
650
 
651
 
652
 
653
	if(wact[2].usewarn){
654
 
655
		wact[2].fwarn(buf,line,file);
656
 
657
}
658
 
659
void warningstring()
660
 
661
 
662
 
663
		wact[3].fwarn((char *)string2,linenumber,currentfileinfo);
664
 
665
}
666
 
667
void warningexpand()
668
 
669
	if(wact[4].usewarn)wact[4].fwarn("Expansion variable",linenumber,currentfileinfo);
670
 
671
672
 
673
{
674
 
675
}
676
 
677
void warningprint(char *str,unsigned int line,unsigned int file)
678
 
679
 
680
 
681
		//	if((wartype.file=fopen(wartype.name,"w+t"))==NULL)wartype.file=stdout;
682
 
683
		//fprintf(wartype.file,"%s(%d)> Warning! %s.\n",startfileinfo==NULL?"":(startfileinfo+file)->filename,line,str);
		printf("%s(%d)> Warning! %s.\n",startfileinfo==NULL?"":(startfileinfo+file)->filename,line,str);
684
 
685
}
686
 
687
void  warningdefined(char *name)
688
 
689
char buf[IDLENGTH+30];
690
 
691
		sprintf(buf,"'%s' defined above, therefore skipped",name);
692
 
693
	}
694
 
695
696
 
697
 
698
 
699
char *typenames[]={"Variable","Structure","Function","Local variable",
700
 
701
	if(wact[7].usewarn){
702
 
703
		wact[7].fwarn(buf,linenumber,currentfileinfo);
704
 
705
}
706
 
707
 
708
 
709
char buf[IDLENGTH+50];
710
 
711
		sprintf(buf,"Non-initialized variable '%s' may have been used",name);
712
 
713
	}
714
 
715
716
 
717
{
718
 
719
}
720
 
721
void warningunreach()
722
 
723
	if(wact[10].usewarn)wact[10].fwarn("Code may not be executable",linenumber,currentfileinfo);
724
 
725
726
 
727
 
728
 
729
}
730
 
731
void warnsize()
732
 
733
	if(wact[12].usewarn)wact[12].fwarn("Sources size exceed destination size",linenumber,currentfileinfo);
734
 
735
736
 
737
 
738
 
739
char buf[IDLENGTH+50];
740
 
741
	warningprint(buf,linenumber,currentfileinfo);
742
 
743
}
744
 
745
void waralreadinitreg(char *reg,char *reg2)
746
 
747
 
748
 
749
	sprintf(buf,"Register %s same as %s",reg,reg2);
750
 
751
#endif
752
 
753
754
 
755
{
756
 
757
 
758
 
759
void missingpar(char *name)
760
 
761
char buf[120];
762
 
763
		sprintf(buf,"Missing parameter in function %s",name);
764
 
765
	}
766
 
767
 
768
 
769
void warreplasevar(char *name)
770
 
771
char buf[120];
772
 
773
	if(displaytokerrors){
774
 
775
		warningprint(buf,linenumber,currentfileinfo);
776
 
777
 
778
 
779
}
780
 
781
void waralreadinitvar(char *name,unsigned int num)
782
 
783
char buf[120];
784
 
785
	if(displaytokerrors){
786
 
787
 
788
 
789
//	}
790
 
791
}
792
 
793
void warcompneqconst()
794
 
795
	warningprint("Comparison not equal constant. Skipped code",linenumber,currentfileinfo);
796
 
797
 
798
 
799
{
800
 
801
}
802
 
803
void warpointerstruct()
804
 
805
	warningprint("Compiler not support pointers on structure",linenumber,currentfileinfo);
806
 
807
 
808
 
809
{
810
 
811
}
812
 
813
/* *****************   map file *************** */
814
 
815
void OpenMapFile()
816
 
817
 
818
 
819
	hmap=fopen(buf,"w+t");
820
 
821
822
 
823
{
824
 
825
	if(flag&f_interrupt)return "";
826
 
827
 
828
 
829
			retcode="byte ";
830
 
831
		case tk_charvar:
832
 
833
			retcode="char ";
834
 
835
		case tk_wordvar:
836
 
837
 
838
 
839
		case tk_longvar:
840
 
841
			retcode="long ";
842
 
843
		case tk_dwordvar:
844
 
845
			retcode="dword ";
846
 
847
		case tk_doublevar:
848
 
849
			retcode="double ";
850
 
851
 
852
 
853
			break;
854
 
855
		case tk_float:
856
 
857
			break;
858
 
859
		case tk_qword:
860
 
861
			break;
862
 
863
			retcode="void ";
864
 
865
 
866
 
867
			retcode="int ";
868
 
869
		case tk_structvar:
870
 
871
			break;
872
 
873
			retcode="int ";
874
 
875
 
876
 
877
}
878
 
879
char *GetTypeProc(int flag)
880
 
881
char *retcode;
882
 
883
	string2[0]=0;
884
 
885
 
886
 
887
	if(flag&f_export)strcat((char *)string2,"_export ");
888
 
889
	if(flag&f_static)strcat((char *)string2,"static ");
890
 
891
		t="";
892
 
893
			case tk_overflowflag:
894
 
895
 
896
 
897
				t="NOTOVERFLOW ";
898
 
899
			case tk_carryflag:
900
 
901
				break;
902
 
903
				t="NOTCARRYFLAG ";
904
 
905
			case tk_zeroflag:
906
 
907
				break;
908
 
909
 
910
 
911
			case tk_minusflag:
912
 
913
				break;
914
 
915
				t="PLUSFLAG ";
916
 
917
		}
918
 
919
	}
920
 
921
		case tp_pascal:
922
 
923
 
924
 
925
			t="cdecl ";
926
 
927
		case tp_stdcall:
928
 
929
			break;
930
 
931
			t="fastcall ";
932
 
933
	}
934
 
935
	return (char *)string2;
936
 
937
 
938
 
939
{
940
 
941
		case 'B':
942
 
943
			return "byte";
944
 
945
			if(c2>=0x30&&c2<=0x37)return regs[0][c2-0x30];
946
 
947
 
948
 
949
			return "dword";
950
 
951
		case 'I': return "int";
952
 
953
		case 'F': return "float";
954
 
955
		case 'Q':
956
 
957
 
958
 
959
			}
960
 
961
		case 'E': return "double";
962
 
963
			if(c2>=0x30&&c2<=0x37){
964
 
965
				return (char *)string2;
966
 
967
 
968
 
969
		case 'U': return "void";
970
 
971
	return "";;
972
 
973
974
 
975
{
976
 
977
char iname[IDLENGTH];
978
 
979
	if((tn=strchr(iname,'@'))!=NULL)*tn=0;
980
 
981
 
982
 
983
	else strcpy((char *)string3,iname);
984
 
985
}
986
 
987
char *GetSizeVar(int type,int adr)
988
 
989
char *reg;
990
 
991
	if(type==tp_postvar||type==tp_gvar)return "DS:???";
992
 
993
		if(ESPloc)reg="ESP";
994
 
995
 
996
 
997
	if(adr<0)sign="";
998
 
999
	sprintf((char *)string2,"%s%s%d",reg,sign,adr);
1000
 
1001
}
1002
 
1003
void GetRangeUsed(char *buf,localinfo *ptr)
1004
 
1005
	if(ptr->count==0)buf[0]=0;
1006
 
1007
	else sprintf(buf,"%d-%d",ptr->usedfirst,ptr->usedlast);
1008
 
1009
 
1010
 
1011
{
1012
 
1013
struct localrec *ptr;
1014
 
1015
char buf[32];
1016
 
1017
	if(hmap){
1018
 
1019
		for(i=0;;i++){
1020
 
1021
			if(c==0)break;
1022
 
1023
 
1024
 
1025
			unsigned char c3=string[i+2];
1026
 
1027
		}
1028
 
1029
		fprintf(hmap,"\nlocation: line %d-%d file %s",line,linenumber,startfileinfo==NULL?"":(startfileinfo+currentfileinfo)->filename);
1030
 
1031
	}
1032
 
1033
	for(ftlr=btlr;ftlr!=NULL;ftlr=ftlr->next){
1034
 
1035
			i=ptr->rec.type;
1036
 
1037
 
1038
 
1039
					fputs("\n----------------------------------------------",hmap);
1040
 
1041
				}
1042
 
1043
				fprintf(hmap,"\n%-8s%-10s%-12s%-4d%-8d",GetRetType(ptr->rec.rectok,0),GetSizeVar(ptr->rec.type,ptr->rec.recnumber),buf,ptr->li.count,ptr->rec.recsize);
1044
 
1045
				fputs(ptr->rec.recid,hmap);
1046
 
1047
 
1048
 
1049
	fputs("\n",hmap);
1050
 
1051
>
1052
 
1053
>
1054
 
1055
>
1056