Commit graph

10164 commits

Author SHA1 Message Date
Bill Currie
269a8a558a [qfcc] Allow bare enum and named struct declarations
Got a little overzealous there
2020-03-04 18:39:41 +09:00
Bill Currie
f532780dbe [qfcc] Treat opaque structs as not anonymous
I don't know why the segfault happened where it did, but
forward-declared structs certainly can't be used as anonymous structs.
2020-03-04 18:38:04 +09:00
Bill Currie
7a2335e9f4 [qfcc] Catch useless specifiers in function scope 2020-03-04 18:07:10 +09:00
Bill Currie
4c82114547 [qfcc] Catch several useless specifier expressions 2020-03-04 17:40:49 +09:00
Bill Currie
597890dda1 [qfcc] Catch duplicate field definitions 2020-03-04 16:32:04 +09:00
Bill Currie
e298904dc0 [qfcc] Implement anonymous structs and unions
For struct/union scope
2020-03-04 16:31:28 +09:00
Bill Currie
4fa203852a [qfcc] Use offset alias offset when creating alias of offset alias
Yes, that's correct. It happens when casting the address of a structure
field (for the test case this fixes, vector field).
2020-03-04 00:55:31 +09:00
Bill Currie
57b2751732 [qfcc] Add failing vector element address test
It's an evil thing to do, but it should at least work.
2020-03-04 00:37:10 +09:00
Bill Currie
de01cff70e [build] Install QF/keys.h into qfcc's include directory
As well as $prefix/include, of course. This fixes the problem with
external ruamoko builds failing due to keys.h and qfcc's "lockdown" on
system headers.
2020-03-03 22:22:53 +09:00
Bill Currie
c58cf2c2d0 [qwaq] Fail at object oriented design 101
This is horrible, doesn't work, isn't really the direction I want to go
(that became apparent while implementing Screen's handleEvent) and
crashes anyway (Array and not-id...)

*sigh*

Still, this does have some good stuff in it, and it pushed qfcc along
some more.
2020-03-03 21:32:19 +09:00
Bill Currie
7976eec2ce [scheme] Clean up a pile of rotten bits 2020-03-03 17:35:14 +09:00
Bill Currie
b186332da0 [qfcc] Make initialization of external vars an error 2020-03-03 17:33:56 +09:00
Bill Currie
051a572bcc [build] Dependency checking for all ruamoko code
Including dependency on qfcc itself. Getting automake to chooch the way
I want it to chooch can be a pain in the... see AvE
2020-03-03 17:24:53 +09:00
Bill Currie
6def1fc01c [qfcc] Fix a bootstrap warning 2020-03-03 15:26:33 +09:00
Bill Currie
cdc1f0c5e7 [libr] Treat ruamoko headers as system headers
Now that qfcc actually supports them properly.
2020-03-03 15:24:41 +09:00
Bill Currie
b8984e5f66 [qfcc] Fix another infinite loop in the linker
I think this should be it for infinite loops caused by undefined
symbols. I don't know why I didn't remove this continue when I removed
the other.
2020-03-03 13:39:24 +09:00
Bill Currie
c7cde5f409 [qfcc] Pass gcc's purity test
*sigh*
2020-03-03 10:59:01 +09:00
Bill Currie
bb25057feb [qwaq] Quickly Workaround Access Qualifications
:)
2020-03-03 10:47:34 +09:00
Bill Currie
c2138183dd [libr] Initialize SetIterator the right way
I'd written Set.[rh] after the big rewrite so never noticed the access
error.
2020-03-03 10:43:29 +09:00
Bill Currie
16223098e5 [qfcc] Fix ivar visibility
It was broken by the big rewrite and I forgot to fix it.
2020-03-03 10:42:05 +09:00
Bill Currie
50d39d64cb [qwaq] Link against build ruamoko libs, not installed 2020-03-03 09:30:20 +09:00
Bill Currie
ed04e6fc23 [qfcc] Merge method lists instead of copying
This is for adding methods to classes and protocols via their interface,
not for adding methods by adding protocols (they still get copied).
Slightly more memory efficient.
2020-03-03 00:11:54 +09:00
Bill Currie
679744fc7d [libr] Fix incorrect bounds check on array insert 2020-03-03 00:11:07 +09:00
Bill Currie
f025bd96d4 [qfcc] Copy self param when copying methods
Copying methods is done when adding protocols to classes (the current
use for adding regular methods is an incorrect solution to a different
problem). However, when a method is added to a class, the type of its
self parameter is set to be a pointer to the class. Thus, not only does
the method need to be copied, the self parameter does too, otherwise
the self parameter of methods added via protocols will have their type
set to be a pointer to the last class seen adding the protocol.

That is, if, while compiling the implementation for class A, but the
interface for class B is comes after the interface for class A, and both
A and B add protocol P, then all methods in protocol P will have self
pointing to B rather than A.

@protocol P
-method;
@end

@interface A <P>
@end

@interface B <P>
@end

@implementation A
-method	{} // self is B, not A!
@end
2020-03-02 23:46:26 +09:00
Bill Currie
8a4de6fea6 [qfcc] Fix segmentation fault for parameter errors 2020-03-02 22:38:12 +09:00
Bill Currie
f6d650d473 [qfcc] Merge duplicate methods in interfaces
Duplicate methods in an interface (especially across protocols and
between protocols and the interface) are both harmless and even to be
expected. They certainly should not cause the compiler to demand
duplicate method implementations :)
2020-03-02 21:15:21 +09:00
Bill Currie
e33d83fc9e [qfcc] Accept "struct foo; struct foo { ... };"
That is, do not treat structure definition after declaration to be a
redefinition.
2020-03-02 20:16:29 +09:00
Bill Currie
d91289ea1b [qwaq] Remove unnecessary wrefresh calls 2020-03-02 18:43:27 +09:00
Bill Currie
33a07c0f6b [qwaq] Make command buffer larger for now
A small one should be fine once threading is working.
2020-03-02 18:30:58 +09:00
Bill Currie
6f1386fa0d [qwaq] Test out acs chars and the classes
Crashes due to flooding the command buffer, but otherwise works (with
larger buffer).
2020-03-02 18:29:31 +09:00
Bill Currie
b9ab30ff59 [qwaq] Add mvwaddch and ACS support 2020-03-02 18:27:08 +09:00
Bill Currie
a0c4d56668 [qwaq] Continue processing on void commands
If the last command in the buffer had no parameters, its length would be
only 2 and thus processing would stop before reading the command from
the buffer.
2020-03-02 18:19:41 +09:00
Bill Currie
fa66e9fc2f [qwaq] Move queue handling into separate functions
This makes it so I need to edit only one place when I get threads
working. Also, it fixes some bugs (eg, panel creation wasn't implemented
correctly).
2020-03-02 18:15:31 +09:00
Bill Currie
d88a091fc6 [qwaq] Use protocols to distinguish object abilities
Well, that took a fair bit more than it should have to get working: had
to implement the protocol support in qfcc and engine-side ruamoko.
2020-03-02 15:22:54 +09:00
Bill Currie
0e40366c7f [ruamoko] Implement class conformsToProtocol
Seems to work nicely, too :)
2020-03-02 15:21:10 +09:00
Bill Currie
a906efac47 [ruamoko] Register protocols and their selectors 2020-03-02 15:20:34 +09:00
Bill Currie
5893bd7501 [qfcc] Catch erroneous negative builtin numbers
Setting a builtin number negative makes it a non-builtin function, but
possibly in the middle of another function. Not good.
2020-03-02 13:47:46 +09:00
Bill Currie
0db617719e [qfcc] Improve error messages for bad qc builtins
While global quakec functions could not be initialized to another
function, the error messages were rather obscure.
2020-03-02 13:47:46 +09:00
Bill Currie
78f552aa87 [ruamoko] Initialize static instances
This is one step closer to implementing conformsToProtocol. However,
protocols are not yet initialized correctly: they are not registered,
nor are their selectors.

While the static initializer list pointer was not written previously,
the module struct always came immediately after the symbols struct, and
the module version has so far always been 0. Thus, the list pointer is
correctly 0 for older progs and there's no need for a version bump.
2020-03-02 13:45:47 +09:00
Bill Currie
bc4bea79cb [ruamoko] Remove a stale FIXME
This was fixed when pr_def_t was introduced. I missed the comment at the
time.
2020-03-02 13:00:33 +09:00
Bill Currie
9ccff74fcf [qfcc] Emit only one instance per protocol per module
This is actually a double issue: when a class implementing a protocol
used the protocol in @protocol(), not only would the protocol get
emitted as part of the class data specifying that the class conforms to
the protocol, a second instance would be emitted again when @protocol()
was used. On top of that, only the instance referenced by @protocol()
would be initialized. Now, both class emission and @protocol() get their
protocol def from the same place and thus only one, properly
initialized, protocol instance is emitted.
2020-03-02 10:55:46 +09:00
Bill Currie
8021613b79 [qfcc] Fix missing protocol method lists
The problem was an erroneous assumption that the methods had to be
defined. Any class implementing a protocol must implement (and thus
define) the methods, but a protocol declaration cannot: it merely
declares the methods, and it's entirely possible for a module to see
only the protocol definition and not any classes implementing the
protocol.
2020-03-02 10:52:09 +09:00
Bill Currie
b6b7f9675f [qfcc] Emit static instance lists
For now, only protocols are in the list (gcc adds only static string
objects and qfcc doesn't do those yet, so not so far behind). qfprogs
dumps them.
2020-03-02 10:48:51 +09:00
Bill Currie
544d7de1ec [qfcc] Implement @protocol(foo)
Unlike gcc, qfcc requires foo to be defined, not just declared (I
suspect this is a bug in gcc, or even the ObjC spec), because allowing
forward declarations causes an empty (no methods) protocol to be
emitted, and then when the protocol is actually defined, one with
methods, resulting in two different versions of the same protocol, which
comments in the gnu objc runtime specifically state is a problem but is
not checked because it "never happens in practice" (found while
investigating gcc's behavior with @protocol and just what some of the
comments about static instance lists meant).
2020-03-02 10:42:26 +09:00
Bill Currie
254bf29bd4 [qfcc] Handle protocol forward declarations 2020-03-01 19:37:40 +09:00
Bill Currie
92cb3a5285 [qwaq] Flatten the hierarchy and do some cleanup 2020-03-01 18:25:02 +09:00
Bill Currie
80d9401eee [qfcc] Report errors for objects in function decls
The number of time's I've forgotten the * in a declaration in objective
code (probably thanks to C#'s lack of them).
2020-03-01 17:44:13 +09:00
Bill Currie
b544321609 [qfcc] Catch deferences to incomplete types
Reporting an error is so much more helpful than segmentation fault.
2020-03-01 17:43:28 +09:00
Bill Currie
277c64a460 [qfcc] Correct a typo 2020-03-01 17:28:51 +09:00
Bill Currie
4e4b553cc3 [gamecode] Take care of missed type alias stuff 2020-03-01 16:20:23 +09:00