Skip to content

Latest commit

 

History

History
107 lines (91 loc) · 4.63 KB

special_cases.txt

File metadata and controls

107 lines (91 loc) · 4.63 KB
 
Oct 15, 1998
Oct 15, 1998
1
APIs that need special handling in the parser/compiler:
May 12, 1999
May 12, 1999
2
Oct 27, 1998
Oct 27, 1998
3
4
5
(Please read name_mangling.txt before this, to see if your special problem
doesn't already have a solution encoded in the function name...)
Nov 30, 1999
Nov 30, 1999
6
7
8
9
10
11
12
13
Are you sure you don't want to be reading vbs_output.txt?
Dec 22, 1998
Dec 22, 1998
14
--------------------------========++++++++++========--------------------------
Oct 15, 1998
Oct 15, 1998
15
PRINT (and print #), with more than one parameter (separated by semicolons)
Dec 4, 1998
Dec 4, 1998
16
must be broken into multiple calls. String concatenations should be done
Oct 15, 1998
Oct 15, 1998
17
18
19
prior to breaking down the API call. That is, PRINT "crack" + "pipe" would
be one call, but PRINT "crack"; "pipe" would be two. ALSO -- Semicolons at
the end of the PRINT statement specify that no newline should be sent to the
Dec 4, 1998
Dec 4, 1998
20
console. This will need to be handled specifically. Solution: the PRINT call
Oct 19, 1998
Oct 19, 1998
21
should, by the parser/compiler, do this: Break down semi-colon separated
Oct 27, 1998
Oct 27, 1998
22
23
24
25
26
fields into strings, if possible, and call vbpS_print(). Otherwise,
convert the argument to a variant, and make a call to vbpV_print(), which
will convert whatever the data was from a variant type to a string, and
print it. If there is no semicolon at the end of the line, the
parser/compiler will generate a call to __printNewLine() (an internal
Dec 4, 1998
Dec 4, 1998
27
function) after all the vbp?_print() calls. Note that the __printNewLine()
Oct 27, 1998
Oct 27, 1998
28
29
30
31
call might be the only call generated, if there are no parameters to the
BASIC PRINT statement. If, for some crazy reason, a programmer has
decided to put a "PRINT ;" statement, the line will not generate any C
code, but will still produce proper line labling and debug/tracing code.
Dec 4, 1998
Dec 4, 1998
32
(The above discussion also applies to vbp?_print_NC() when using PRINT #)
Dec 22, 1998
Dec 22, 1998
33
--------------------------========++++++++++========--------------------------
Oct 15, 1998
Oct 15, 1998
34
35
36
37
OPEN calls should all call one function, with default values for optional
missing values. The OPEN function should determine what action to take
based on the default values. This avoids the need for 18 jazillion overloaded
functions.
Dec 22, 1998
Dec 22, 1998
38
--------------------------========++++++++++========--------------------------
Oct 27, 1998
Oct 27, 1998
39
40
41
42
CLOSE calls need to deal with the optional '#' chars before the numeric
arguments. Lots of the file i/o API have this problem. Things like
PRINT # and LINE INPUT # use this character to differentiate between two
very different functions, too.
Dec 22, 1998
Dec 22, 1998
43
--------------------------========++++++++++========--------------------------
May 12, 1999
May 12, 1999
44
SWAP should be generated inline by the parser/compiler.
Oct 19, 1998
Oct 19, 1998
45
46
"SWAP a, b" becomes "tmp = a; a = b; b = tmp", plus type/range checking and
debug/trace code.
Dec 22, 1998
Dec 22, 1998
47
--------------------------========++++++++++========--------------------------
Oct 26, 1998
Oct 26, 1998
48
49
50
In Qbasic, CHR$(255.4999) does not fail, but CHR$(255.5) throws
ERR_ILLEGAL_FUNCTION_CALL. Do all BASIC functions round floating point values
when used as integer arguments, or do some functions truncate?
Dec 22, 1998
Dec 22, 1998
51
52
53
54
55
56
57
58
59
60
61
62
63
--------------------------========++++++++++========--------------------------
*-----
BASIC code:
*-----
x = 3
On x GOSUB line1, line2, line3
On x GOTO line1, line2, line3
*-----
must become:
*-----
__GOSUBSUPPORT;
__integer x;
__integer tmp;
Oct 26, 1998
Oct 26, 1998
64
Dec 22, 1998
Dec 22, 1998
65
66
67
x = 3;
tmp = x; /* needed in case of function...should run only once. */
if ((tmp < 0) || (tmp > 255)) /* negatives or > 255 are errors. */
May 12, 1999
May 12, 1999
68
__runtimeError(ERR_OUT_OF_RANGE); /* or whatever error... */
Dec 22, 1998
Dec 22, 1998
69
else if (tmp == 1)
May 12, 1999
May 12, 1999
70
__doGosub(line1, endOfOnNumGosub);
Dec 22, 1998
Dec 22, 1998
71
else if (tmp == 2)
May 12, 1999
May 12, 1999
72
__doGosub(line2, endOfOnNumGosub);
Dec 22, 1998
Dec 22, 1998
73
else if (tmp == 3)
May 12, 1999
May 12, 1999
74
75
76
77
__doGosub(line3, endOfOnNumGosub);
endOfOnNumGosub:
Dec 22, 1998
Dec 22, 1998
78
if ((tmp < 0) || (tmp > 255)) /* negatives or > 255 are errors. */
May 12, 1999
May 12, 1999
79
__runtimeError(ERR_OUT_OF_RANGE); /* or whatever error... */
Dec 22, 1998
Dec 22, 1998
80
else if (tmp == 1)
May 12, 1999
May 12, 1999
81
__jumpLabel(line1);
Dec 22, 1998
Dec 22, 1998
82
else if (tmp == 2)
May 12, 1999
May 12, 1999
83
__jumpLabel(line2);
Dec 22, 1998
Dec 22, 1998
84
else if (tmp == 3)
May 12, 1999
May 12, 1999
85
86
87
__jumpLabel(line3);
Dec 22, 1998
Dec 22, 1998
88
89
90
91
92
93
94
95
*-----
This must be generated INLINE, EVERYTIME, by the parser/compiler.
*-----
--------------------------========++++++++++========--------------------------
Refer to on_events.txt and gosub.txt for details on those, and strange
things like ON ERROR RESUME NEXT...
--------------------------========++++++++++========--------------------------
SELECT CASE statements can NOT be converted directly to switch statements,
May 12, 1999
May 12, 1999
96
since they are more flexible. You'll have to use "if/else if/else" constructs.
Dec 22, 1998
Dec 22, 1998
97
98
99
100
101
102
--------------------------========++++++++++========--------------------------
RESUME and RESUME 0 should both translate into a __resumeZero() call.
RESUME NEXT should become a __resumeNext() call.
--------------------------========++++++++++========--------------------------
What to do about CHOOSE?
--------------------------========++++++++++========--------------------------
Oct 15, 1998
Oct 15, 1998
103
Ugh.
Dec 22, 1998
Dec 22, 1998
104
--------------------------========++++++++++========--------------------------
Oct 26, 1998
Oct 26, 1998
105
106
/* end of special_cases.txt ... */