Commit graph

3913 commits

Author SHA1 Message Date
Bill Currie
8b1e4eea58 [qfcc] Bring back the core of type aliasing
No aliasing is done yet, but most of the infrastructure is there again.
2020-03-27 12:27:46 +09:00
Bill Currie
58ebbb147d [ruamoko] Add some new string builtins
Wrappers for hold, valid and mutable. I have no idea why I didn't think
of wrapping string validation years ago.
2020-03-26 16:39:21 +09:00
Bill Currie
1586df4dfc [gamecode] Make it possible to check string mutability 2020-03-26 16:38:09 +09:00
Bill Currie
ec82d6b027 [gamecode] Add support for holding ephemeral strings
PR_HoldString converts ephemeral (temp and return) strings to dynamic
strings. This makes dealing with strings in progs a little easier.
2020-03-26 16:36:29 +09:00
Bill Currie
b4874f7d9b [gamecode] Make PR_FreeString a little more forgiving
It treats only strings that are actually invalid as invalid. That is,
now it is safe to "free" a static string: it's just a no-op.
2020-03-26 15:48:04 +09:00
Bill Currie
22e2695f80 [gamecode] Add VISIBLE to some missed functions 2020-03-26 15:36:46 +09:00
Bill Currie
6e473dc8f2 [ruamoko] Return nil IMP for nil method
Fixes a segfault.
2020-03-26 14:13:05 +09:00
Bill Currie
2d5df34234 [gamecode] Add VM enter/exit events
And rename prd_exit to prd_terminate (the idea is the host will
terminate the VM). This makes it possible for the debugger to pause the
VM before any code, even a builtin function, is executed. Breaks the
debugger source window, but only because it's not updating on file
change (I think).
2020-03-26 12:30:32 +09:00
Bill Currie
1bd8e2ee85 [gamecode] Add a param pointer to debug_handler
I decided I want events for VM enter/exit but enter needs to somehow
pass the function which will be executed (even if a builtin). A generic
void * param seemed the best idea, which meant the error string could be
passed via the param instead of a "global" string in the progs struct.
2020-03-26 11:44:02 +09:00
Bill Currie
4cef9792f4 [util] Make hash-tables semi-thread-safe
They take a pointer to a free-list used for hashlinks so the hashlink
pools can be per-thread. However, hash tables that are not updated are
always thread-safe, so this affects only updates. progs_t has been set
up such that it is easy for multiple progs within one thread can share
hashlinks.
2020-03-25 15:43:16 +09:00
Bill Currie
0ad9f559ea [ruamoko] Move some string functions
sprintf, vsprintf and strlen now in rua_strings, and strlen now returns
int like it should.
2020-03-25 00:04:20 +09:00
Bill Currie
c945c42989 [gamecode] Fix some silly errors
I forgot to compile-test :(
2020-03-24 23:16:25 +09:00
Bill Currie
d867a1a9f1 [gamecode] Allow watch-point to be updated
With the watch-point address cached in a local var, it was not possible
to update the watch-point while the progs were executing.
2020-03-24 19:45:39 +09:00
Bill Currie
713150b41a [gamecode] Add debug hooks to the VM engine
While there was a breakpoint hook, it was for only breakpoints and more
was needed. Now there's a generic hook that is called for tracing,
breakpoints, watch points, runtime errors and VM errors, with the
"event" type passed as the first parameter and a data pointer in the
second.
2020-03-24 19:45:10 +09:00
Bill Currie
1d6843d7f0 [gamecode] Improve watchpoint handling a little
Mostly just update the old value if the condition didn't trigger.
2020-03-24 13:26:35 +09:00
Bill Currie
753d183d82 [gamecode] Be more informative with function calls
PR_EnterFunction and PR_LeaveFunction now print the
entered/left/returned function when tracing. Makes debugging obj code
much easier.
2020-03-24 13:24:55 +09:00
Bill Currie
d0c8d75e92 Clean up unnecessary includes of signal.h 2020-03-23 16:18:08 +09:00
Bill Currie
9986b57a77 [console] Use sig_atomic_t for SIGWINCH
If it's not defined on other platforms, something can be done in
config.h
2020-03-23 16:16:50 +09:00
Bill Currie
178c8dec85 [console] Fix server console resize
I goofed when doing the win32 fixes
2020-03-23 16:01:07 +09:00
Bill Currie
eb386826d3 [util] Fix some missed signal calls
*sigh*
2020-03-23 15:28:12 +09:00
Bill Currie
a9c6974fc7 [audio] Quieten jack about xruns
They messages are annoying at the moment, but I will want them when I
get around to chasing down the root cause, so hidden behind a developer
mask.
2020-03-23 15:19:05 +09:00
Bill Currie
4a61ff0d35 [util] Switch to using sigaction for signal handling
This allows for much more consistent semantics when dealing with
signals.
2020-03-23 15:15:39 +09:00
Bill Currie
4dbf280012 [util] Add a means to open a gap in a text buffer
for loading files into the buffer.
2020-03-22 20:19:25 +09:00
Bill Currie
28f50d2719 Add function key defs up to F48
This allows for the four combinations of shift and control. Not
bothering with alt because alt-f4 closes my xterm (bbkeys from the looks
of it: it grabs a bunch of Mod1-* keys).
2020-03-22 13:46:27 +09:00
Bill Currie
88b4046632 [util] Pass a data pointer to shutdown functions
And clean up the mess.
2020-03-22 00:57:54 +09:00
Bill Currie
d2f03e8a64 [util] Fix darray test for gcc purity 2020-03-20 12:59:25 +09:00
Bill Currie
966bd267c5 Add a set of macros for dynamic arrays
Includes docs and test cases.
2020-03-20 12:59:25 +09:00
Bill Currie
0cbe438ac1 [util] Make va slight robust against chained use
va now cycles through a set of four dstrings rather than using just the
one. This allows for some simple chaining of va usage.
2020-03-17 15:05:58 +09:00
Bill Currie
b544a052bf [gamecode] Bail if PR_SearchDefs is given 0 defs
Fixes the hang when searching for a field in progs that don't have any.
2020-03-16 14:24:48 +09:00
Bill Currie
e3a1413ad3 [gamecode] Tweak output for lea 2020-03-15 10:06:37 +09:00
Bill Currie
99f89840f9 [gamecode] Show containing def and relative offset
No more guessing when accessing structure field members. Next is ivars,
I guess.
2020-03-15 02:51:29 +09:00
Bill Currie
3d62a7f253 [gamecode] Use fuzzy bsearch to find defs by address
The idea is to find th def that contains the address. Had to write my
own bsearch (well... lifted from wikipedia) because libc's is exact. The
defs are assumed to be sorted (which qfcc now ensures when it writes
progs and sym files).
2020-03-15 02:48:13 +09:00
Bill Currie
2f9f6d3aa9 [gamecode] Relocate aux function return types
They are written with offsets relative to the type encodings base.
2020-03-14 23:39:14 +09:00
Bill Currie
9492f08536 [gamecode] Print structs as well as unions
Much better :)
2020-03-14 21:03:01 +09:00
Bill Currie
fea6381574 [gamecode] Rework debug type handling a little
Type encodings are used whenever they are available. For now, if they
are not, then everything is treated as void (which prints <void>, not
very useful). Most return statements and references to .return are now
very readable (excluding structs), and only params going through "..."
are a messy union.
2020-03-14 20:44:43 +09:00
Bill Currie
a069fad41e [gamecode] Print only entity address when no edicts
If the edicts pointer is null, it's not possible to convert the entity
address to an index.
2020-03-13 20:16:06 +09:00
Bill Currie
a0d85e33c2 [gamecode] Rework implementation of memset*
The memset instructions now match the move* instructions other than the
first operand (always int). Probably breaks much, but fixed in next few
commits.
2020-03-13 17:50:57 +09:00
Bill Currie
087cee06be [gamecode] Use full precision for floating point values 2020-03-13 14:57:33 +09:00
Bill Currie
6dfe37635d [gamecode] Dump union contents
The output is messy, but better than <union>
2020-03-13 14:56:56 +09:00
Bill Currie
08b7064a3f [ruamoko] Set pr_argc before calling error methods
Builtins calling ruamoko code need to be careful of the arg count in
case the ruamoko function uses varargs.
2020-03-12 19:40:17 +09:00
Bill Currie
6ca85d770d [gamecode] Add memset instructions 2020-03-11 22:48:55 +09:00
Bill Currie
023a920a51 [gamecode] Replace lost parameter auto-reset
rcallN messes with the progs parameter pointers and not resetting them
can cause incorrect data to be copied into the called function.
2020-03-11 19:38:50 +09:00
Bill Currie
694ad2e840 [ruamoko] Add str_char builtin
This returns the character (as an int) at the index. Equivalent to
string[index], but qc code doesn't have char-level access and not having
it means that strings can internally change to wchar without too much
fuss (maybe).
2020-03-10 18:16:55 +09:00
Bill Currie
1b1249bdb0 [ruamoko] Add vsprintf builtin 2020-03-10 18:16:07 +09:00
Bill Currie
6c56e93fc8 [gamecode] Be more careful with temp strings
If a temp string is found in the return slot, PR_FreeTempStrings won't
delete the string. However, PR_PopFrame was blindly stomping on the
possibly surviving temp string with the push strings, which would cause
a leak.
2020-03-10 03:24:31 +09:00
Bill Currie
21b64421c3 [ruamoko] Copy ALL the params to the args block
*sigh*
2020-03-10 03:09:21 +09:00
Bill Currie
4b7d5447bb [ruamoko] Correct obj_msg_sendv for __obj_forward
Until I implemented forwarding, I didn't know how obj_msg_sendv was
meant to be used, so no surprise I got the implementation wrong.
2020-03-10 02:56:37 +09:00
Bill Currie
2a152e6356 [ruamoko] Add builtin __obj_responds_to
Fast dtable-based messages response test. However, it does not handle
forwarding.
2020-03-10 00:08:30 +09:00
Bill Currie
af37b660e8 [ruamoko] Push the forwarded args block
This causes the block to be freed when the forward: handler returns
(assuming it's not yet another builtin). This is necessary so calling a
lot of forwarded messages in a loop doesn't leak memory (though it will
get freed eventually).
2020-03-09 23:38:27 +09:00
Bill Currie
f290b115a5 [gamecode] Add function PR_PushTempString
This "pushes" a temp string onto the callee's stack frame after removing
it from the caller's stack frame. This is so builtins can pass
auto-freed memory to called progs code. No checking is done, but mayhem
is likely to ensue if a string is pushed that was allocated in an
earlier frame.
2020-03-09 23:36:09 +09:00