Commit graph

10244 commits

Author SHA1 Message Date
Bill Currie
fa0a74efdf [ruamoko] Finish implementation of __obj_forward
With this, object's implementing forward:: seem to accept the message
well, including receiving all the original args (not quite sure how to
deal with them in ruamoko code just yet, though).
2020-03-09 22:20:11 +09:00
Bill Currie
7d43bd5c66 [gamecode] Add function PR_AllocTempBlock()
PR_AllocTempBlock() works the same way as PR_SetTempString(), except
that it takes a size parameter and always allocates (never tries to
merge). This is, in a way, abusing the string system, but I needed a way
to allocate a block of progs memory that would be automatically freed
when the current frame ended. The biggest abuse is the need to cast away
the const of PR_GetString()'s return value.
2020-03-09 22:16:19 +09:00
Bill Currie
e3fe93c586 [gamecode] Implement most of message forwarding
All that's left is the parameter setup of forward::.
2020-03-09 20:41:17 +09:00
Bill Currie
a487595149 [ruamoko,libr] Begin implementation of __obj_forward
libr supplies an __obj_forward definition that links to a builtin, but
as it is the only def in its object file, it is readily replaceable by
an alternative Ruamoko implementation.

The builtin version currently simply errors out (rather facetiously),
but only as a stub to allow progs to load.
2020-03-09 19:09:08 +09:00
Bill Currie
e2f4c189f9 [ruamoko] Install and use dispatch tables
This should speed up ruamoko code somewhat as hash table lookups have
been replaced with direct array indexing. As a bonus, support for
message forwarding has been added (though not tested).
2020-03-09 18:11:36 +09:00
Bill Currie
1ccdd76780 [ruamoko] Clean up runtime init and cleanup
Move the semi-permanent resource initialisation into the module init and
the cleanup of those resources into cleanup. Makes actual runtime init
much easier to read.
2020-03-09 18:09:03 +09:00
Bill Currie
98756df9f7 [gamecode] Set final resource map free list pointer
The sub-tables were being properly linked together, but the very final
table was not properly terminated.
2020-03-09 18:03:25 +09:00
Bill Currie
0780cca496 [qwaq] Fixed swapped method implementations
That was fun
2020-03-08 22:21:15 +09:00
Bill Currie
8fc007648c [qwaq] Add missed command enum string 2020-03-08 22:20:46 +09:00
Bill Currie
89cf9f9523 [qwaq] Use Sys_Printf for load error messages
It gets them into the log file.
2020-03-08 22:19:37 +09:00
Bill Currie
bb0e65e9d4 [cl_menu] Silence some debug output 2020-03-08 21:45:51 +09:00
Bill Currie
67ec9bfb47 [vid] Initialize x event before sending
Quietens valgrind nicely (though it gave a weird source of the memory).
2020-03-08 21:30:08 +09:00
Bill Currie
5f299cbac7 [gamecode] Ensure static string refs are initialized
That was a fun one to track down :P
2020-03-08 21:29:31 +09:00
Bill Currie
a013714bd0 [qfcc] Add missing header file changes
Oops
2020-03-08 20:11:21 +09:00
Bill Currie
c726d77e7d [gamecode] Respect the @float_promoted@ magic string
Rather than relying on progs code version, use the string to determine
whether PR_Sprintf should behave as if floats have been promoted through
... I imagine I'll get to the rest of the server code at some stage.

With these two changes, nq-x11 works again (teleporters were the
symptom).
2020-03-08 19:19:15 +09:00
Bill Currie
89ec86f77f [qfcc] Add option to promote of float through ...
The server code is not yet ready for doubles, especially in its varargs
builtins: they expect only floats. When float promotion is enabled
(default for advanced code, disabled for traditional or v6only),
"@float_promoted@" is written to the prog's strings.
2020-03-08 19:13:57 +09:00
Bill Currie
bcf75b541a [qfcc] Build movep dest pointer correctly
This fixes the mangled pointer in struct-init-param.r.
2020-03-08 17:40:38 +09:00
Bill Currie
5020966be3 [qfcc] Fix ud-chain alias handling
That was a fair bit trickier than I thought, but now .return and .paramN
are handled correctly, too, especially taking call instructions into
account (they can "kill" all 9 defs).
2020-03-08 16:57:12 +09:00
Bill Currie
3d9410c66d [qfcc] Force overlap to 0 for non-alias def/temops
Make the code behave as intended: visiting all aliases when starting
with the real def/tempop regardless of the overlap setting.
2020-03-08 16:53:28 +09:00
Bill Currie
035da472ec [qfcc] Offset alias tempop offsets
Alias tempop offsets are relative to the real tempop. This fixes alias
tempops never overlapping the real tempop.
2020-03-08 16:51:01 +09:00
Bill Currie
695b3ba0d0 [qfcc] Rearrange vecexpr.r for easier debugging
Putting the most likely function to have problems at the top reduces
break-point shenanigans.
2020-03-08 16:50:39 +09:00
Bill Currie
d9d321f65b [qfcc] Check for previous errors in vector exprs
Fixes a segfault when one of the expressions used to construct the
vector was the result of an error.
2020-03-08 15:40:07 +09:00
Bill Currie
b81d58c795 Revert "[qfcc] Correct a comment"
This reverts commit a2f203c840.

There is indeed a world of difference between "any" and "only", and it
helps if I read the rest of the docs AND the code :P.
2020-03-08 14:58:57 +09:00
Bill Currie
8696e76a25 [qfcc] Handle aliases when setting use and def
As expected, this does not fix the mangled pointer problem in
struct-init-param.r, but it does improve the ud-chains. There's still a
problem with .return, but it's handling in flow_analyze_statement is a
bit "special" :P.
2020-03-08 12:17:56 +09:00
Bill Currie
a2f203c840 [qfcc] Correct a comment
There's a world of difference between "any" and "only".
2020-03-08 12:10:12 +09:00
Bill Currie
b2faca16a7 [qfcc] Rename the kill alias functions
Having "visit" in the name felt redundant in the end.
2020-03-08 12:08:56 +09:00
Bill Currie
c2ed6d41bd [qfcc] Finish struct-init-param test
When the bug is fixed, it will pass now (does without optimization).
2020-03-08 03:55:08 +09:00
Bill Currie
e4c87091a3 [qfcc] Lots of flow analysis docs
And some function shuffling for grouping. I'm not satisfied with the
docs, but they're a lot more helpful than they were.
2020-03-08 03:53:53 +09:00
Bill Currie
809c103fd1 [qfcc] Shuffle some code around to be clearer
Doing the same thing at the end of two branches of an if/else seems off.

And doing an associative(?) set operation every time through a loop is
wasteful.
2020-03-08 03:46:52 +09:00
Bill Currie
7338689146 [qfcc] Treat offset real tempops as an error
tempops always have an offset field, but only those that are aliases
should ever have a non-zero offset.
2020-03-08 03:42:18 +09:00
Bill Currie
d44d956038 [qfcc] Remove a long dead function 2020-03-08 03:39:24 +09:00
Bill Currie
f56de00c21 [qfcc] Rename a field
depth_first is much clearer than dfo. I had to check what dfo meant too
many times in one night.
2020-03-08 03:38:45 +09:00
Bill Currie
2b15e61b28 [qfcc] Remove obsolete structure fields
init_vars hasn't been used for a long time.
2020-03-08 03:33:01 +09:00
Bill Currie
e524db1fc1 [qfcc] Set op type when aliasing a value
This fixes the ICE when attempting to compile address-cast without
optimization (just realized why, too: the assignment was optimized out
of existence).
2020-03-08 03:11:46 +09:00
Bill Currie
777ce56cf3 [doc] Enable MathJax
Nice. Very nice.
2020-03-07 17:48:19 +09:00
Bill Currie
6ada20f685 [qfcc] Show offset for op_x_def_ofs relocs 2020-03-07 02:06:33 +09:00
Bill Currie
48514ba2f3 [qfcc] Create alias def for defs accessed via pointer
This the fixes the incorrect flow analysis caused by the def being seen
to have the wrong size (structure field of structure def seen through a
constant pointer). Fixes the ICE, but the pointer constant is broken
somewhere in dags, presumably.
2020-03-07 01:30:36 +09:00
Bill Currie
faa6eabfbe [qfcc] Add a failing test for struct init to param
This actually took a bit to reproduce.
2020-03-06 22:28:04 +09:00
Bill Currie
f7757cf894 [qfcc] Add filename to dot output
It makes things so much easier when viewing the graphs
2020-03-06 21:05:53 +09:00
Bill Currie
f0ecf7b30a [qwaq] Clean out log file with make clean 2020-03-06 20:43:38 +09:00
Bill Currie
de06efa604 [qfcc] Fix handling of nil for static initializers
nil is most definitely constant.
2020-03-06 20:38:40 +09:00
Bill Currie
9dbc81432a [qfcc] Use full type for differentiating values
This fixes the problem of using nil for two different compound types
within the one expression. The problem is all compound types have the
same low-level type (ev_invalid) and this caused the two different nils
to have the same type when taken back up to expression level.
2020-03-06 20:33:47 +09:00
Bill Currie
07e6baf32f [qfcc] Support { } as nil in nested initializers
Did top-level earlier, but forgot to add support for deeper nestings.
2020-03-06 20:32:37 +09:00
Bill Currie
1250fe7446 [qwaq] Use a log file instead of stderr
Now I don't have to worry about remembering to redirect the output, but
debugging is still easy.
2020-03-06 18:29:16 +09:00
Bill Currie
b8b74fc074 [qwaq] Implement missing addch
I either forgot about it, or just didn't need it at the time, but I'm
sure it will be useful later when more stuff is implemented.
2020-03-06 17:57:33 +09:00
Bill Currie
9a96a9b2c9 [qwaq] Use own version of positional drawing in Window
Double offsetting the prints doesn't quite look right ;)
2020-03-06 17:46:36 +09:00
Bill Currie
d0a249590c [qwaq] Use self where possible for drawing in Window 2020-03-06 17:45:58 +09:00
Bill Currie
bea64838cc [qwaq] Use new TextContext
Not quite right yet, but it worked first try (once I got another
compiler bug sorted).
2020-03-06 17:38:27 +09:00
Bill Currie
9b269c2f8e [qfcc] Fix mangled method parameters
Method parameters (ie, extra parameters without selector names) were
getting reversed during function type construction.
2020-03-06 17:37:58 +09:00
Bill Currie
a2cebe3cac [qfcc] Add failing test for method parameters 2020-03-06 17:36:23 +09:00