Commit Graph

2938 Commits

Author SHA1 Message Date
Bill Currie d3d88290b5 Mostly satisfactory output of nested regions.
It turns out dot does not like cyclic graphs (thus some of the weird
layouts), but fixing it by flipping back-edges requires proper recording of
edge info (I guess that's what T is for in the dragon book).
2012-11-15 13:44:07 +09:00
Bill Currie 8c5a2b3d11 Implement depth-first searching for flow graphs.
This fixes the bogusly irreducible graphs.
2012-11-15 13:44:07 +09:00
Bill Currie 53622dbb99 Perform graph reduction on the function's flow graph.
The reduction is performed itteratively until the graph is irreducible, but
such that each reduction wraps the previous graph. Unfortunately, due
depth-first searching not being implemented, graphs that should be reduced
(ie, those with natural loops).
2012-11-15 13:44:07 +09:00
Bill Currie 388b6e6e8f Add set_size ().
Return the number of members in the set.
2012-11-15 13:44:07 +09:00
Bill Currie 8567508963 Rewrite set_first() and add set_next().
set_first() now returns a pointer to a setstate_t struct that holds the
state necessary for scanning a set. set_next() will automatically delete
the state block when the end of the set is reached. set_delstate() is also
provided to allow early termination of the scan.
2012-11-15 13:44:07 +09:00
Bill Currie 2da038ce0f Bring back dot_flow.c.
However, it produces simplified flow graphs (ie, just nodes and edges, no
statements, though later on data flow information will be added).
2012-11-15 13:44:07 +09:00
Bill Currie 8b374305d2 Rename dot_flow.c and print_flow.
They're now dot_sblock.c and print_sblock. The new names both better
reflect their purpose and free up "flow" for outputting the real flow
analysis graphs.
2012-11-15 13:44:07 +09:00
Bill Currie c483770121 Rework flow.c with the aim of graph reduction.
Much of the data recently added to sblock_t has been moved to flownode_t.
No graph reduction is carried out yet, but the initial (innermost level)
graph has been built.
2012-11-15 13:44:07 +09:00
Bill Currie da446fd343 Detect natural loops.
Non-nested loops that have the same head-node are merged into one loop.
However, loop nesting is not currently detected (next step).
2012-11-15 13:44:07 +09:00
Bill Currie 8fb958603c Add set_first.
It returns the first element of a set. If the set is empty, -1 (unsigned)
is returned.
2012-11-15 13:44:07 +09:00
Bill Currie 4cc8d4a04b Fix an apparent snafu in set_test.
It looks like a bit of case&paste where I forgot to change != to &.
2012-11-15 13:44:07 +09:00
Bill Currie 1fead50f4e Calculate the dominators of each node in the flow graph.
The dominators are represented by sets using the node numbers.
2012-11-15 13:44:07 +09:00
Bill Currie 964ea7f9fe Add set_as_string for debug output. 2012-11-15 13:44:07 +09:00
Bill Currie d2fab28d01 Implement set_is_member.
Oops, forgot that one.
2012-11-15 13:44:06 +09:00
Bill Currie 7853bf1859 Calculate a node's successors and predecessors.
The dot graphs are a little odd (arrow heads on the wrong end of the
predecessor edges), but things seem to be correct.
2012-11-15 13:44:06 +09:00
Bill Currie 739ebc522c Begin working on flow analysis.
For now, variable and flow graph node maps are built.
2012-11-15 13:44:06 +09:00
Bill Currie f30010b367 Add some docs to function.h 2012-11-15 13:44:06 +09:00
Bill Currie 5acf474882 Double quote dag labels.
Dot interprets escape sequences in non-html string, and needs the quotes to
be escaped, so quote the result of operand_string. Unfortunately,
operand_string uses quote_string and quote_string returns a static pointer,
so some hoop-jumping is necessary.
2012-11-15 13:44:06 +09:00
Bill Currie cdc790d0c8 Add a set type and support code. 2012-11-15 13:44:06 +09:00
Bill Currie 60d03dbdd9 Fix the naive opcode checks.
Confusing . with .=, and < and <= with more <MOVE etc isn't good.
2012-11-15 13:44:06 +09:00
Bill Currie dc9d2a982e Make the returned dag a linked list of root-nodes.
A dag can have mulitple "root" nodes (ie, nodes with no parents).
2012-11-15 13:44:06 +09:00
Bill Currie a22260030a Use value for pointer operands.
This allows daglabels on pointer operands without a redundant daglabel
pointer.
2012-11-15 13:44:06 +09:00
Bill Currie 0c58cd9067 Generate only one daglabel for value operands.
As each value is now unique, their labels can also be unique, which will
improve CSE.
2012-11-15 13:44:06 +09:00
Bill Currie 16869cabd1 Fix a slew of uninitialized data problems.
Bah, structs on stacks... good fun :P
2012-11-15 13:44:06 +09:00
Bill Currie 01c8aaae8c Add some error checking for attaching identifiers. 2012-11-15 13:44:06 +09:00
Bill Currie 0ccf4093e4 Handle attached identifier labels correctly.
I'd forgotten I had the prev field. Makes for much cleaner code.
2012-11-15 13:44:06 +09:00
Bill Currie 0cedf0d13a Fix a bunch of mis-uses of an expressions's value.
The value field really should be treated as constant.
2012-11-15 13:44:06 +09:00
Bill Currie 28ce35f1c1 Make values independent objects.
values are now uniquely allocated (for the current object file). With
this, constants in dags will work.
2012-11-15 13:44:06 +09:00
Bill Currie c57df8b5f3 Print all dag nodes in a dag.
Dags can have multiple roots, so only recursing once could miss much of the
dag.
2012-11-15 13:44:06 +09:00
Bill Currie dbf1aa8f72 Attach dags to statement blocks.
Now, if a dag is attached to a statement block, it will be included in the
flowgraph with that statement block.
2012-11-15 13:44:06 +09:00
Bill Currie 39506881c0 Fix the completely bogus handling of "x" in dag creation.
That made a complete mashup of attached identifiers :P
2012-11-15 13:44:06 +09:00
Bill Currie 24553867a4 Use dashed lines for attached identifiers in dags. 2012-11-15 13:44:06 +09:00
Bill Currie aa72f263ec Use an extra temp for v6 float modulo.
It seems the dag creation algorithm doesn't like "a = a op a", so use
"b = a op a" instead. Since I plan on fixing temp leaks anyway, this won't
be a problem (also, few people even use qfcc's v6 float modulo :P).
2012-11-15 13:44:06 +09:00
Bill Currie d9354255a3 Avoid double-printing dag nodes. 2012-11-15 13:44:05 +09:00
Bill Currie 7b2e426545 Support temp operands in dags. 2012-11-15 13:44:05 +09:00
Bill Currie 9bc65ffedb Start actually trying to build dags.
Temporary variables aren't being handled correctly (treated as constants),
but it looks like a good start.
2012-11-15 13:44:05 +09:00
Bill Currie b7b6294d87 Fix some dag printing goofs.
Typo and no node recursion.
2012-11-15 13:44:05 +09:00
Bill Currie 8015e1b1e9 Put the dags stuff into a qfcc sub-section.
Not much point writting docs if they can't be found.
2012-11-15 13:44:05 +09:00
Bill Currie aa2943709e Start work on building dags from basic blocks.
Doesn't compile and the design is in flux anyway, but I want to get back to
iqm.
2012-11-15 13:44:05 +09:00
Bill Currie 60108c688c Change dags from binary to trinary.
I'd forgotten some instructions take three inputs that can benefit from
CSE.
2012-11-15 13:44:05 +09:00
Bill Currie 0fefeb73fe Initial support for basic block dags.
Currently, only dumping to dot, but that seems to be a very sensible place
to start: debug support.
2012-11-15 13:44:05 +09:00
Bill Currie d5c831b6da Add a little test case for accessing types.
Using ruamoko to access ruamoko type encodings is actually quite pleasant
:)
2012-11-15 13:40:11 +09:00
Bill Currie ee8247ec61 Support using enums as array indices. 2012-11-15 13:39:23 +09:00
Bill Currie f18a4d3c4a Support pointer - pointer. 2012-11-15 13:38:57 +09:00
Bill Currie 552142497e Support progs.dat when dumping type encodings.
Knock up a quick and dirty progs-to-qfo "converter" (strings and types
only) to re-use the qfo types dumper.
2012-11-15 11:58:13 +09:00
Bill Currie 9691b50f0f Make .type_encodings more useful.
Rather than just a pointer, it is now a struct with a pointer and size
indicating the extent of the type encodings block.
2012-11-15 11:57:16 +09:00
Bill Currie 74ac4ee142 Fix a misplaced line. 2012-11-15 11:00:51 +09:00
Bill Currie 39c1034afb Relocate the data in the type encodings space.
Because of the way it is used, the data in the type encodings space needs
to always be correct (ie, relocated), even for partially linked object
files.
2012-11-14 20:37:19 +09:00
Bill Currie 453ac11bc3 Correct some comments. 2012-11-14 17:13:14 +09:00
Bill Currie 2685d38059 More paranoia when dumping qfo type encodings. 2012-11-14 16:32:41 +09:00
Bill Currie 3b3e013d4a Do not demand a defined def is actually global.
Rather, only that it is neither external nor local. The idea was to catch
myself swapping the arguments to resolve_external_def, but for some reason
I decided type encoding defs would not be global (save game reasons?).
2012-11-14 15:50:55 +09:00
Bill Currie acc188d62b Ressurect the builtin symbol type fixup.
I was a little overzealous when gutting process_type_space :P
2012-11-14 15:49:19 +09:00
Bill Currie 9d7b8a4cf2 Add optional arguments to the todo list.
Interesting alternative to overloaded functions.
2012-11-14 14:55:36 +09:00
Bill Currie 33eb3f2418 A bit of pointer saftey in add_defs.
Directly accessing odef after can be dangerous (probably not here, but
hey), so use the defref instead.
2012-11-14 13:25:30 +09:00
Bill Currie 00c87434bf A touch of whitespace. 2012-11-14 13:25:03 +09:00
Bill Currie 281e203545 Make process_data_def use the correct def tables.
Fixes the bogus redefined errors when entity fields are used.

Also, rename extern_defs and defined_defs to extern_data_defs and
defined_data_defs (more consistent with the other tables).
2012-11-14 13:14:54 +09:00
Bill Currie e05c12e16d Make linker_add_def take a pointer for the value.
While it looks like I might not use it for the type encodings, it should be
useful in the future.
2012-11-14 13:12:58 +09:00
Bill Currie 51236b0693 Fix the incorrect type space reloc offsets.
The problem was caused by add_relocs and process_loose_relocs adjusting the
reloc offset based on the reloc's space's base address. This is fine for
most relocs, but as relocs for the type space have already been adjusted by
process_type_space, those relocs must be left alone by add_relocs and
process_loose_relocs. As a bonus, the duplicate code has been refactored
into a separate function :)
2012-11-14 10:29:45 +09:00
Bill Currie 31739f4dbf Rewrite the type_space processing.
Now each encoding is copied across def by def using memcpy, with the
expectation that any references to other types will be handled via the
reloc system. Unfortunately, it seems there's an off-by-4 (hmm, suspicious
number...) in the reloc offsets, but I'll look into that after I get some
sleep.
2012-11-13 21:55:54 +09:00
Bill Currie 8625964634 Fix some careless inernal_error changes.
Back when I did the abort->internal_error change, I wasn't paying attention
and forgot I should use linker_internal_error in linker.c.
2012-11-13 21:51:16 +09:00
Bill Currie f80a74228c Add (and use) alloc_data for work qfo data allocations.
defspace_alloc_loc can cause a realloc which will break the work qfo space
data pointers, so wrap it with alloc_data, which updates the appropriate
pointers and sizes.
2012-11-13 21:48:46 +09:00
Bill Currie 5b7b49b100 Add a QFO_TYPE macro to get a qfot_type_t pointer.
In the end, it wasn't used, but it could be handy in the future.
2012-11-13 21:45:54 +09:00
Bill Currie d782622e74 Be more paranoid when dumping qfo type encodings. 2012-11-13 21:24:48 +09:00
Bill Currie f002f3ad7a Escape strings for reloc dumps.
Line feeds messing up the output wasn't nice :P.
2012-11-13 21:14:51 +09:00
Bill Currie 1dd8f34190 Refactor process_def.
The field/data def handling has been moved into process_data_def and
process_field def. The code for handling external defs has been moved into
its own function (extern_def()),

In passing, rename add_space to add_data_space, since it is limited to
handling data spaces.
2012-11-13 13:16:45 +09:00
Bill Currie ba6fb5802d Make add_defs take a function to process the defs.
For now, no other change has been made, but I'll be able to split up
process_def for data def vs field def processing and add a function for
processing type encoding defs.
2012-11-13 12:40:40 +09:00
Bill Currie 93b007b1f8 Take care of relocs when defining external defs.
For most of the cases, some relocs may have been lost, but they were
certainly lost for type encodings. Now that all seems to be fixed.
2012-11-12 16:14:09 +09:00
Bill Currie eb5581c7bd Fix class type encoding.
First, the class def needed to be created before the class type, then the
def space indices had to be set early, otherwise the relocs wound up with
space 0 instead of the correct space.
2012-11-12 12:46:15 +09:00
Bill Currie c96718493a A bit of a cleanup before fixing class type defs.
All internal structs now have "proper" names, and fit the naming convention
(eg, obj_module (like objective-c's types, but obj instead of objc). Some
redundant types got removed (holdovers from before proper struct tag
handling).

Also, it has proven to be unnecessary to build internal classes, so
make_class and make_class_struct are gone, too.
2012-11-12 11:12:33 +09:00
Bill Currie 6ec5bb1884 Change the FIXME to a comment as to why nothing is done.
Of course, the relocation record still needs to be written (don't know why
it isn't), but that's next :)
2012-11-11 20:36:25 +09:00
Bill Currie d13ce81b4f Ensure the type's encoding string is valid.
When encoding a type to a qfo file, the type's encoding string is written
and thus needs to be valid prior to actually doing the encoding. The
problem occurs mostly in self-referential structs (particularly, obj_class)
because the struct is being encoded prior to the pointer to the struct.
2012-11-11 20:22:48 +09:00
Bill Currie 8710977323 Rework transfer_type to avoid infinite recursion.
This is similar to the problem with infinite recursion when encoding types.
The problem is with structs with self-referential pointers (eg, struct foo
{struct foo *bar}). The solution is to copy the type data to a buffer and
mark the buffer as transfered before actually processing the type. Further
processing of the type is done via the buffer.
2012-11-11 20:20:07 +09:00
Bill Currie edd381931e Create obj_object after obj_class.
obj_class is self-referential,but obj_object refers to obj_class. This gets
obj_class encoded properly.
2012-11-11 19:08:15 +09:00
Bill Currie 96110a0f54 Treat messages to id and Class separately.
As id and Class do not point to real objects as such, trying to get the
class from their types doesn't work, so instead send the message to a
"null" class that skips the method checks.
2012-11-11 17:39:12 +09:00
Bill Currie ee28f3869c Fix the checking for assignments between id and Class.
With Class now being struct obj_class rather than an actual class or
object, checking for Class now needs to be explicit.
2012-11-11 17:24:33 +09:00
Bill Currie 694b268f53 Correct the type of id.
It should be struct obj_object * rather than Object *.
2012-11-11 17:22:57 +09:00
Bill Currie 35a88d873c Rework the builtin class creation once again.
Now the classes are built "properly" (using the same tools as the parser
itself), and the structs (obj_object, obj_class and obj_protocol) are built
separately, but using the class ivars.
2012-11-11 16:23:04 +09:00
Bill Currie b36bd3a988 Remove the list offsets from the class ivars.
Even just before, type_obj_object, type_obj_class and type_obj_protocol
were a bit bogus (still are), but now the arrays used to list their ivars
are correct. I plan to create the above mentioned types using
class_to_struct to do it properly.
2012-11-11 09:52:55 +09:00
Bill Currie 0cf16ac558 Make _OBJ_CLASS_foo the correct type.
It needs to be type_obj_class, but I had gotten confused earlier when
rearranging the type names as I was having trouble with "not a class"
errors.
2012-11-10 13:45:38 +09:00
Bill Currie 06fd912a09 Make super_class for the internal Protocol and Class objects.
They're based on Object, and that needs to be represented properly.
2012-11-10 13:01:56 +09:00
Bill Currie 86091856be Revamp the static class creation.
Type names are cleaned up, as is the creation. Also, the class pointer in
the type encoding now gets emitted. However, Still need to actually create
_OBJ_CLASS_Class and fix the type encoding reloc handling in the linker.
2012-11-10 12:56:19 +09:00
Bill Currie d33d062bd1 Rearrange class_message_response.
Even if an object doesn't seem to respond to a message, return the message
so unrelated warnings or errors don't occur.
2012-11-09 19:18:09 +09:00
Bill Currie fd8c639773 Initialize current_symtab early, with pr.symtab.
This (with the previous commit) fixes the problems with the tags for
builtin structs.
2012-11-09 14:37:28 +09:00
Bill Currie 9cb0ca6fed Catch symtab operations with an invalid symtab.
Just via a simple segfault, but it's better than silently missing incorrect
usage.
2012-11-09 14:36:19 +09:00
Bill Currie 49cc4fed0c Give the builtin structures proper tags.
With the previous commit, the structures were being created before a valid
source file name was available and thus qfcc would segfault when trying to
generate a tag. Now, the tags look better anyway :).
2012-11-09 14:00:10 +09:00
Bill Currie 9fd8741b4f Move the state clearing into InitData.
Now, for each compilation, or before linking, only InitData needs to be
called. Fixes the double chaining internal error when compiling and linking
in the same command.
2012-11-09 13:56:45 +09:00
Bill Currie f307c7bebc Rework the unary_expr grammar to allow ++*foo.
This required throwing out the primary rules that snax did up to help me
with conflicts many years ago, but they were now getting in the way. Now
the productions from primary are merged in with unary_expr.
2012-11-09 12:32:38 +09:00
Bill Currie 6ff2644ab5 Fix simple pointer dereferences.
It turns out no code was being generated for x = *y. Ouch. I suspect I need
to take a better look at expr_deref at some time in the not too distant
future.

Conflicts:
	tools/qfcc/source/statements.c
2012-11-09 12:32:35 +09:00
Bill Currie 7a2f7e8982 Add some safety checks to progs global dumping.
Getting segfaults in the debug tools is not fun :P

Conflicts:
	tools/qfcc/source/dump_globals.c
2012-11-09 12:30:14 +09:00
Bill Currie cc24e2e67e Initialize global string vars correctly.
Ouch, I'd fixed that for arrays, but not normal vars.
2012-11-09 12:23:04 +09:00
Bill Currie 9095e1eabc Rework build_switch to use initialize_def.
This required support for label reference expressions, whose purpose is to
represent the address of a label.
2012-11-09 12:22:34 +09:00
Bill Currie 48fe9f729d Add partial support for pointer arithmetic.
Only pointer +/- integral is supported. pointer - pointer will come later.
2012-11-09 12:21:45 +09:00
Bill Currie afbab60c25 Create linker_find_def.
It turns out I didn't need it, but it could be useful in the future, so
I'll leave it in.
2012-11-09 11:57:06 +09:00
Bill Currie 4ef4711c3b Make the type encodings findable.
The base of the type encodings block is given by the .type_encodings def.
The block begins with a "null" type (4 words of 0), followed by the first
type encoding.

At some stage, I will need to add information for extended def information
(32 bit offset, type encoding, other?), but this is good for initial
testing.
2012-11-09 11:43:19 +09:00
Bill Currie 1d060d1ac1 Quote string values when dumping globals.
Much nicer :)
2012-11-08 21:13:24 +09:00
Bill Currie eb86a66ce5 Do some class object type renaming.
type_object -> type_obj_object
type_Class -> type_obj_class
type_ClassPtr -> type_Class

In the process, one more FIXME is gone :)
2012-11-08 20:58:48 +09:00
Bill Currie 377f8f9d56 Use an explicit flag for class initialization.
Much cleaner than messing with class_Class, which is about to go away.
2012-11-08 17:14:33 +09:00
Bill Currie 7e293a38e8 Check for double-chaining of types.
Chaining a type twice will form a loop in the type list, causing find_type
to go into an infinite loop.
2012-11-08 17:14:33 +09:00
Bill Currie 950a3aa83d Avoid infinite recursion when encoding struct types.
Structures (especially hard-coded ones) can be really nasty as they can
refer to themselves. Avoid the recursion by setting the type_def field of
the type before doing the recursive encodings in the structure encoder.
2012-11-08 17:06:38 +09:00
Bill Currie 7a25283beb Clear out the type encoding def from all types.
The encodings of static types were getting corrupted because their defs
were not necessarily in the same places between compilations when compiling
multiple files.
2012-11-08 17:06:38 +09:00
Bill Currie a3a22f2a1b Add the ability to dump qfo type encoding. 2012-11-08 17:06:38 +09:00
Bill Currie 09d1cd61f3 Don't convert a qfo to progs unnecessarily.
This avoids segfaults on reloctions for external defs.
2012-11-08 17:06:29 +09:00
Bill Currie 61ef901254 Tweak some FIXMEs. 2012-11-08 17:03:02 +09:00
Bill Currie ed4018fd8d Clear out the function overloading tables between compiles.
Fixes some issues with multiple compiles (especially mixed languages!).
2012-11-01 20:53:33 +09:00
Bill Currie ea34a5b753 Fix some nasty memory errors.
Three cheers for valgrind!!!
2012-11-01 20:53:28 +09:00
Bill Currie 5c79953a7e Put quotes around strings for statement operands.
This makes reading output a bit easier (especially if the string is empty
or just whitespace).
2012-10-30 12:31:28 +09:00
Bill Currie f8bdd909cc Separate out C and html quoting into separate functions.
Dot sometimes wants normal C quotes, othertimes html. Quite annoying,
really, but this is cleaner anyway.
2012-10-30 12:31:22 +09:00
Bill Currie f680521e0f Escape unprintable chars. 2012-10-27 11:45:51 +09:00
Bill Currie ec42bde527 Make hash tables more const correct.
And clean up the resulting mess :/
2012-10-27 11:44:31 +09:00
Bill Currie 034139b806 Move some code around so it's more accessible. 2012-10-27 11:43:29 +09:00
Bill Currie 7519ec7bbd Fix the bogus missing return warning.
Pascal's return mechanism is such that void return is always used.
2012-10-26 20:11:38 +09:00
Bill Currie 3f351a5c88 Fix a printf format goof.
Forgot to compile test :/
2012-10-26 19:38:59 +09:00
Bill Currie 52b9721027 Add the COMMA token to the pascal parser.
I guess I forgot I needed to keep token numbers in sync between pascal and
qc/ruamoko.
2012-10-26 19:06:10 +09:00
Bill Currie 72045f1a5b Delay storage setting for pascal functions.
The function def must not be local. This fixes the null function call in
gcd.pas.
2012-10-26 19:03:00 +09:00
Bill Currie 27b83a8d65 Clean up all extra aborts, using internal_error instead.
Some internal_error calls have no message, but at least things will be more
consistent.
2012-10-26 19:02:02 +09:00
Bill Currie 5530e84ada Call find_type for pascal functions/procedures.
The result of parse_params needs to be passed through find_type before
actually being used. I guess I'd missed this back when I got things working
for qc.
2012-10-26 16:20:57 +09:00
Bill Currie 144387c3e3 Add shared.h to the dist files. 2012-10-26 16:16:46 +09:00
Bill Currie f14d8060e0 Merge qfpc into qfcc.
Since gnu bison and flex are required anyway, no harm in using their api
prefix options. Now, qfcc can compile both QC/Ruamoko and Pascal files
(Pascal is (currently?) NOT supported in progs.src mode), selecting the
language based on the extension: .r, .qc and .c select QC/Ruamoko, .pas and
.p select Pascal, while anything else is treated as an object file (as
before).
2012-10-26 16:01:41 +09:00
Bill Currie 50b22ab163 Fix a rather silly snafu with smart-leak.
I blame this fever :P

Now smart-leak actually makes sense.
2012-09-18 07:48:39 +09:00
Bill Currie 45fd312133 Merge branch 'master' into mapedit 2012-09-17 07:52:42 +09:00
Bill Currie 156f3382a5 Emit the points in the expected order.
Associating p1 with n2 and p2 with n1 was a bit confusing. Makes for a
more-sensible points output file, too.
2012-09-16 13:51:42 +09:00
Bill Currie 0ed535214e Import leak points files. 2012-09-16 12:57:17 +09:00
Bill Currie d6476d4f93 Make some improvements to the leak files.
smart leak files now produce many points, not just one per portal. Normal
leak files now center the trail on the portal (instead of some weird
weighted average).
2012-09-16 12:38:55 +09:00
Bill Currie 4fc9316320 Add very preliminary support for map exporting.
There is no error checking, texture alignment or support for non-point
lights, but it's a start. Also, it's assumed all brushes are convex and
manifold.
2012-09-16 10:59:47 +09:00
Bill Currie 6b8df7f42a Give EntityClassDict mapping access functions.
They just redirect to the actual entity class dictionary, but it saves a
lot of unnecessary code elsewhere.
2012-09-16 10:55:06 +09:00
Bill Currie 8416276cee Remove a debug print. 2012-09-13 18:14:29 +09:00
Bill Currie 2760055a0f Try to speed up entity relationship drawing a little. 2012-09-13 13:14:32 +09:00
Bill Currie 559add50cb Fix some snafus. 2012-09-13 12:22:05 +09:00
Bill Currie f18a926616 Add support for RMQs QUAKED comments.
RMQ just leaves out the entity size instead of using ? for brush entities.
2012-09-13 12:21:06 +09:00
Bill Currie 225cb4b364 Create an idquake character encoding.
It just does a 1:1 charmap conversion of quake text, purely to allow python
to read arbitrary qc code.
2012-09-13 12:19:26 +09:00
Bill Currie bcda96a445 Report the source line of the entity in messages.
For now, just when PrintEntity is used to print the message, but having the
first line of the entity sure makes life easier.
2012-09-12 08:33:44 +09:00
Bill Currie db25d5597d Handle quest format brushes.
Bah, I forgot I needed to fix the vertex count parsing when I did the
script lexing change.
2012-09-12 08:24:17 +09:00
Bill Currie b764cad483 Add buttons to re-scan or re-parse entity class data. 2012-09-12 08:14:10 +09:00
Bill Currie 592222aba8 Don't attempt to draw a connecting line to a missing target. 2012-09-11 15:01:43 +09:00
Bill Currie 154d08a9c7 Gracefully handle unknown entity classes.
Unfortunately, the classname gets lost to blender at this stage, but I have
an idea for how to handle that.
2012-09-11 14:58:56 +09:00
Bill Currie 54832740c8 Gracefully handle missing textures.
The texinfo still gets a material, but just an untextured one. The idea is
such textures can be fixed up at a later date.
2012-09-11 14:57:24 +09:00
Bill Currie 41004fd7c2 Remove specularity from the brush materials.
Specularity looks ghastly when there's nothing for it to highlight.
2012-09-10 19:24:47 +09:00
Bill Currie 7204f8d90d Minor robustness improvements to map importing.
Allow map parse errors to be reported propertly (the raise was for
debugging) and give up gracefully when the wad file can't be found.
2012-09-10 19:23:15 +09:00
Bill Currie 995547ae6f Display a message for entity class parsing errors.
It's hacky, but at least something shows up.
2012-09-10 16:14:32 +09:00
Bill Currie 25e545616a Create EntityClassError exception.
Much more useful than Python's SyntaxError (and much less confusing).
2012-09-10 15:57:50 +09:00
Bill Currie ae942afe5c Bind map_error to the script object.
This works much better :)
2012-09-10 14:59:43 +09:00
Bill Currie f525be0880 Implement Script.error properly.
It's not good to get an attirbute error when trying to raise another error.
2012-09-10 14:58:41 +09:00
Bill Currie dade60863e Move the entity class comment into its own box.
Blender doesn't support multiline text or word wrapping, so the tooltips
were rather ugly. The double spacing used by layout.label() is still a
little ugly, but the resulting text box just below the entity classname is
much more usable.
2012-09-10 13:19:38 +09:00
Bill Currie 198a49dfdf Ensure all files have the gpl block. 2012-09-10 12:40:55 +09:00
Bill Currie a75fe213a6 Make entity lines post rather than pre.
I'm not sure what visual difference it makes, but it is pretty much what
I'd intended in the first place.
2012-09-10 12:16:23 +09:00
Bill Currie 2905cb69bc Add entity relation lines.
It has many problems (eg, the lines won't update when target/targetname
change), but the basics are working.
2012-09-10 11:48:22 +09:00
Bill Currie 9dc1039686 Fix map parsing for quest format maps.
Bah, the one place a single char lex is needed :P
2012-09-10 08:08:37 +09:00
Bill Currie da6f57a23b Get entity field key/value pair editing working. 2012-09-10 08:08:11 +09:00
Bill Currie ea541b325d Set the map parser scripts to not lex single chars.
qbsp treats {foo as one token, not two.
2012-09-09 17:23:55 +09:00
Bill Currie c8be8c242a Don't use any single chars for maps.
The standard map format (original qbsp) doesn't use them.
2012-09-09 17:13:10 +09:00
Bill Currie 0c2818c038 Ensure the texture scaling is never 0. 2012-09-09 17:12:45 +09:00
Bill Currie 73cdd66c52 Set the entity properties as parsed from the map. 2012-09-09 17:11:57 +09:00
Bill Currie 825ce0dad6 Make the type of EntityClass.flagnames consistent.
Sometimes list and sometimes tuple makes for a mess.
2012-09-09 17:01:23 +09:00
Bill Currie 709ab05713 Add preliminary support for entity properties.
Only classname and flags are supported right now, and only classname gets
set when the entity is added (via the add menu).
2012-09-09 13:22:52 +09:00
Bill Currie 468f96902f Use a tetrahedron for the default brush entity.
It seems to be a reasonable shape to show that editing is needed.
2012-09-09 11:10:03 +09:00
Bill Currie 18fcdb0ce7 Implement the add_entity operator.
Doesn't work for brush entities yet.
2012-09-09 10:29:43 +09:00
Bill Currie fde8d29899 Use icons to distinquish brush ents from others.
Mesh-data icons indicate brush entities, object-data icons indicate the
others.
2012-09-09 09:29:55 +09:00
Bill Currie 06fd951a55 Build the add entity menu tree.
The menu tree is built from the parsed entity classes, with _ forming the
separator between menu levels.
2012-09-09 08:54:41 +09:00
Bill Currie a37c5465e1 First step for BSP2 support. DOES NOT WORK!
All of the nastiness is hidden in bspfile.c (including the old bsp29
specific data types). However, the conversions between bsp29 and bsp2 are
implemented but not yet hooked up properly. This commit just gets the data
structures in place and the obvious changes necessary to the rest of the
engine to get it to compile, plus a few obvious "make it work" changes.
2012-09-07 16:09:24 +09:00
Bill Currie 395a0eef78 Don't use targetname for entity names.
Proves to be rather non-useful (at this stage, anyway)
2012-09-04 20:29:00 +09:00
Bill Currie 1993ee8352 Remove some debug prints. 2012-09-04 19:40:07 +09:00
Bill Currie af37ae438e Fix the incorrectly rotated textures.
map uses degrees, blender uses radians. oops.
2012-09-04 19:39:10 +09:00
Bill Currie 7feec96b8d Texture the world :)
Such a simple statement for a sizable hunk of work.
2012-09-04 17:04:30 +09:00
Bill Currie b29f24e6d3 Add a wadpath scene property and load the wad files. 2012-09-04 17:04:00 +09:00
Bill Currie 95e2a5b21a Pre-process texture defs.
The st-vectors are now fully calculated as per qfbsp's algorithm.
The Texinfo class tries to create unique texture defintions.
2012-09-04 16:59:02 +09:00
Bill Currie 446016e84e Make wad contents searches case-insensitive. 2012-09-04 16:58:19 +09:00
Bill Currie 8587079c0d Fix a case&paste error. 2012-09-04 11:59:04 +09:00
Bill Currie 38facac7ce Add a very simple wad reader.
It supports only MipTex data (for automatic data conversion), and it's very
fragile, but it will do for now.
2012-09-03 19:37:04 +09:00
Bill Currie 125952d17d Un-hardcode the light distance. 2012-09-03 14:34:27 +09:00
Bill Currie dfaf28001a Create colored boxes for sized entity classes.
The data is taken from the parsed entity class data. No error checking is
done yet.
2012-09-03 14:33:32 +09:00
Bill Currie 16952ffbbb Support loading entity class data into blender.
The qc source path is specified via the dirpath property in the QF Entity
Classes panel of the scene data. The scanned entity classes are stored in a
plist in a blender text file for persistent storage (so the directory
doesn't need to be scanned every time). Also, so the data doesn't have to
be parsed every time, the data is stored in a normal python class hanging
off the properties class (evil hack?).
2012-09-03 13:38:28 +09:00
Bill Currie 3cad0f978b Revamp entity class loading for blender integration.
Slightly cleaner EntityClass building, and now the directory scanner is
part of the EntityClassDict class, which also supports reading/writing
plists (for persistent storage in blender).
2012-09-03 13:35:18 +09:00
Bill Currie b3e5083f60 Add a symlink to io_mesh_qfmdl's qfplist.py
The map editor addon needs to use it too, but I don't want to duplicate the
file in git.
2012-09-03 13:33:59 +09:00
Bill Currie c08fd08025 Write empty array and dictionary items on one line.
Makes for slightly tidier plist text.
2012-08-31 16:14:49 +09:00
Bill Currie 43abf8e3df Support writing int and float items to a plist.
They are written as normal string items, so anything using the plist later
on will need to know the context, but at least now there's no need to first
convert int or float data to strings before writing a plist.
2012-08-31 16:10:30 +09:00
Bill Currie 2b55687aa5 Correct a missed function rename.
Serves me right for not testing properly :P
2012-08-31 15:54:26 +09:00
Bill Currie ffcd78bc28 Add other entities as empties.
For now until I get entity class data importing sorted out. The empties are
set to display as size 8 cubes (+/-8bu).
2012-08-30 19:56:08 +09:00
Bill Currie 4b5242104a Add lights from the map to the scene.
Only the very basics are done at this stage, but things look reasonable.
The lamp energy might need tweaking.
2012-08-30 17:34:05 +09:00
Bill Currie 5d2b2639d0 Generate geometry for entities with brushes. 2012-08-30 14:50:19 +09:00
Bill Currie 15a906aadb Get map parsing pretty much working.
No geometry is created yet.
Both id and quest formats are supported.
e1m1.map parses in less than two seconds on my system.
2012-08-30 13:19:30 +09:00
Bill Currie 97c99de581 Create the entity class scanner.
It recursivly scans the QC source tree looking for QUAKED comments and
builds a dictionary of the found entity classes.
2012-08-29 15:43:53 +09:00
Bill Currie 08d7131c1b Create a python version of QF's script parser.
It's error handling is bogus, but it works for good input :)
2012-08-29 14:55:11 +09:00
Bill Currie 365f20bb95 Make the ps3 cross-build self-contained.
More or less.

This is a bit of an experiment (which seems to work nicely) in that qfcc
and pak are build natively in one build tree, then the full system is
cross-built in another tree using the natively build qfcc and pak. Both
trees are created by cross-configure.sh as sub-directories of the current
directory. However, cross-configure.sh still assumes it is being run in a
subdirectory of the main quakeforge directory.

cross-make.sh checks if the native tree is in the current directory and if
so, builds it, otherwise it just runs make for the cross-build tree (this
allows for running cross-make in a sub-directory for things like sorting
out build issues).
2012-08-20 10:56:09 +09:00
Bill Currie 0976ff8582 Nuke mentions of HOST_CC.
CC_FOR_BUILD is the recommended name these days (HOST_CC was from an old
gcc version, and is confusing anyway). Also, CC_FOR_BUILD should be set by
configure.
2012-08-20 10:51:46 +09:00
Bill Currie a2f2d4d949 "Check" for the availability of pthreads.
Unfortunately, just because the header is there doesn't mean anything will
actually work :(. Also, the check is based on the host vendor/os for now.
Yes, it's rather lame but it will do for now.

With this, QF will build on an almost fresh ps3toolchain install. Only two
"fixes" are needed:
 o  In $PS3DEV/ppu/powerpc64-ps3-elf: ln -s ../include sys-include
 o  libsamplerate cross-built and installed.
2012-08-19 13:40:42 +09:00
Bill Currie 9bfcdad35a Fix some type-size safety issues.
Expecting int to be 32 bits is a little dangerous, and the function
versions of swap/noswap should be unsigned rather than signed.
2012-08-19 13:37:06 +09:00
Bill Currie 358ea4ef9a Fall back to execve/wait when execvp and waitpid are unavailable. 2012-08-19 13:18:38 +09:00
Bill Currie 5684347088 Some fixes for mingw cross-builds.
The fixes came to light while getting ps3toolchain cross-building working.
2012-08-18 22:12:02 +09:00
Bill Currie cd1e3e5b6f Cross configure/make scripts for ps3toolchain based builds. 2012-08-18 21:33:58 +09:00
Bill Currie af0db29981 Add support for meshes with multiple UV maps.
One common use for a mesh having multiple UV maps is when combining several
mesh objects into one: the base UV map is the result of joining the meshes
(and will be a right mess of overlapping UV islands), but an additional UV
map is then setup as a copy of the first but with the islands re-packed so
nothing overlaps. The export script now searches for the active UV map and
uses that for both UV coordinates and the skin texture (when none is
specified).
2012-08-12 13:38:12 +09:00
Bill Currie 971e689d3d Fix a slew of whitespace issues. 2012-08-07 13:25:44 +09:00
Bill Currie a3c8209bdf Handle missing frame information a little more usefully.
If there's no export script, or the export script has no frame information,
animation data will be collected by running through blender frames 1 to the
current frame (inclusive). Each frame will be exported as a single frame
rather than as members of a frame group.
2012-08-07 13:23:19 +09:00
Bill Currie 39b2e80207 Optionally apply the object's transform to the mesh.
The default is to apply.
2012-08-07 11:49:08 +09:00
Bill Currie 634b3b043d Export non-triangular faces as triangle clusters.
It turns out this behavior is preferable (by at least one artist, anyway).
2012-08-07 10:49:32 +09:00
Bill Currie a4da11cdb5 Correctly handle multiple vertices sharing a UV coordinate.
Need to use both UV coordinate and vertex index to find unique
combinations. This should fix leileilol's broken meshes.
2012-08-07 10:26:35 +09:00
Bill Currie 78bfd30648 Export vertex normals.
I'd forgotten I hadn't implemented exporting vertex normals. While I've
modified things for making better use of blender's tools and avoiding the
unnecessary use of objects, the code is taken from the ajmdl blender 2.4
export script.
2012-08-07 09:52:47 +09:00
Bill Currie 5661e738ac Actually return the skin in null_skin()
Oops.
2012-08-07 09:50:38 +09:00
Bill Currie ff4c2cfb63 Add a todo list for the mdl addon. 2012-08-06 22:34:19 +09:00
Bill Currie 0e7e45b91d Redo the io_mesh_qfmdl packaging.
It is cross-platform, after all.
2012-07-17 17:30:16 +09:00
Bill Currie fa61d2def7 Delete old io_mesh_qfmdl zips too. 2012-07-17 17:21:56 +09:00
Bill Currie 087908adcd Link in the keys progs builtins. 2012-07-15 07:39:50 +09:00
Bill Currie 97c87cf996 Initial checkin of the qwaq mini-engine. 2012-07-15 07:39:50 +09:00
Bill Currie b6125276e4 Fix the mis-handling of the progs.dat line in preprogs.src
Gah, must have lost a line at some stage. Also, handle line number
directives.
2012-07-14 19:01:47 +09:00
Bill Currie 7444371162 Disable bolding for special chars.
If an escape sequence is used to access a char, the the programmer probably
wanted that char, regardless of the current bolding mode.
2012-07-14 17:47:34 +09:00
Bill Currie 3b8141691e Fix a bunch of continue vs break issues. 2012-07-14 17:26:13 +09:00
Bill Currie 1364bff91b Add an extended mode to qfcc.
Extended mode allows extra keywords (switch, for, etc) that are compatible
with v6 progs.
2012-07-14 17:16:33 +09:00
Bill Currie 4055d9a435 Add support for \s escapes to qfcc.
I guess \s is an fteqcc extention for toggling bold characters. At the
request of freewill.
2012-07-14 11:47:26 +09:00
Bill Currie e657390ab5 Undo a mv -> cp change.
Turns out it wasn't quite what I thought it was. *shrug* :)
2012-07-13 18:14:50 +09:00
Bill Currie fe26a55cc4 Package the mdl import/export addon. 2012-07-13 17:03:11 +09:00
Bill Currie 1100596431 Include the mdl import/export addon in the distribution.
A tad embarrasing...
2012-07-13 07:59:50 +09:00
Bill Currie f467e2de54 Use sed's in-place option. 2012-07-11 13:38:27 +09:00
Bill Currie 7573c38122 Create qfspritegen based on id's sprgen.
No guarantees it works, but it should be able to convert a bunch of pcx
images into a sprite.
2012-06-30 20:20:15 +09:00
Bill Currie 0d9d777086 Fix Win32 package building for recent changes. 2012-06-29 11:15:11 +09:00
Bill Currie dbc203b625 And a few more bits of whitespace. 2012-05-23 08:21:27 +09:00
Bill Currie 23a38738fc Massive whitespace cleanup.
Lots of trailing whitespace and otherwise blank lines.
2012-05-22 08:23:22 +09:00
Bill Currie 0036a5e113 Ensure edict_size is never 0.
Avoids division by / in NUM_FOR_EDICT
2012-05-06 21:35:42 +09:00
Bill Currie 1dd5cccda2 Correct some more error messages. 2012-05-06 18:52:05 +09:00
Bill Currie a0788c6cdf Implement constant folding for unary operators.
Including conversions between float and int :)
2012-05-06 18:49:07 +09:00
Bill Currie f781e9078c Correct some typos in error messages. 2012-05-06 18:43:18 +09:00
Bill Currie 954e03c3f7 Report the correct function name for the largest locals.
I must have been tired when I adapted that code.

* taniwha dons brown paper bag
2012-05-06 13:02:11 +09:00
Bill Currie 55ecf94f2d Don't draw arrows leaving return statements.
Return statements never flow to the next block (or any other block, for
that matter), so drawing arrows leaving them not only messes up dot's
graphs, but is quite missleading.
2012-05-05 18:04:10 +09:00
Bill Currie 56410ddc58 Prevent merged if/goto losing its way.
When mering if/goto (ie, if skipping a goto), the rest of the dead code
remover is used to delete the goto. That part of the code unuses the goto's
label. The if was getting the goto's label without the lable's used count
being incremented (the usaged temporarily increases by one). I have no idea
why the problem showed up randomly, but this seems to fix it (it fixes /a/
bug, anyway).
2012-05-04 22:35:20 +09:00
Bill Currie 953e789db2 Handle movement of the final block.
Moving a final block caused segfaults and weird flow graph corruptions.
2012-05-04 19:48:32 +09:00
Bill Currie e8c17c68e6 Fix a segfault when the switch expression errors. 2012-05-04 18:13:11 +09:00
Bill Currie 5df25133b3 Implement code movement for unconditional jumps.
That is, when the destination of the jump is reachable via only the jump.
2012-05-04 18:00:05 +09:00
Bill Currie 33bfac0508 Process all basic blocks for jump threading.
I'd copied the for loop from the dead block removal code, but jump
threading doesn't need to look at the following block...
2012-05-04 14:10:30 +09:00
Bill Currie f169a7732d Factor out label unuse.
I expect to need this more often in the future.
2012-05-04 14:01:39 +09:00
Bill Currie d2da3b8246 Update old test for new syntax. 2012-05-04 11:04:58 +09:00
Bill Currie 75aa28cfac Mark all subsequent blocks as reachable after if/goto merge.
If an if/goto merge is done in the first dead block pass, no blocks after
the merge have their rechable flag set because they've never been tested.
2012-05-04 10:58:18 +09:00
Bill Currie 8ddd58f951 Fix the dropping of the block after the merged if/goto.
The naive implementation of the if/goto merging was letting the old target
of the if get dropped because the block would lose its label and thus be
judged unreachable because the preceeding goto block was still in the list.
Instead, when the if/goto are "merged", mark the goto block as unreachable,
the following block as reachable, and break out of the analysis loop to
force the removal of the goto block. Since the dead block removal function
loops until no action is taken, all other dead blocks will be removed.
2012-05-04 10:07:55 +09:00
Bill Currie e866619de6 Output basic block flow diagrams to files.
The output can be controlled via --block-dot (not yet documented). The
files a named <sourcefile>.<function>.<stage>.dot. Currently, stage will be
one of "initial" (after expression to statement conversion), "thread"
(after jump threading), "dead" (after dead block removal), "final" (final
state before actual code emission).
2012-05-04 09:45:51 +09:00
Bill Currie 3da44ace52 Merge if and goto blocks when if only skips over the goto. 2012-05-03 22:21:32 +09:00
Bill Currie 6afdfb5fac Unuse label expressions that are no longer necessary. 2012-05-03 22:20:00 +09:00
Bill Currie 402a578bf8 Add some more helper functions.
Things were getting messy with the strcmps.
2012-05-03 22:17:23 +09:00
Bill Currie 88bed3644e Rename some helper functions. 2012-05-03 22:11:52 +09:00
Bill Currie 159f1bafea Add a little more info to statement flow diagrams.
The relative block number and the label user count are printed now.
2012-05-03 22:09:49 +09:00
Bill Currie 6900907129 Remove dead labels when jump threading.
This lets the dead block removal do a better job.
2012-05-03 19:32:44 +09:00
Bill Currie ab73a267cd Do not unconditionally remove labels from blocks.
Labels can be shared between multiple flow-control instructions, so use the
label's used counter to determine when to remove the label. This was
causing problems with the jump threading.
2012-05-03 19:22:57 +09:00
Bill Currie c79620f04c Make statement blocks more identifiable. 2012-05-03 19:10:44 +09:00
Bill Currie 43b5edf46b Implement jump threading.
First real optimization :)
2012-05-03 17:42:58 +09:00
Bill Currie 78a9ba2557 Make expression alias chains not-a-bug.
The common cause seems to be casting a cast (very common, and I'm not sure
just realiasing the expression would be right). It does't cause any harm
(particularly, it doesn't trigger alias def chains), so I won't worry about
it.
2012-05-03 13:57:31 +09:00
Bill Currie 006882407d Fix the source of alias def chains.
The actual bug might still be elsewhere, but at least now I know the alias
chains were coming from accessing .return and .param_N, which are unions
(not directly usable by the progs engine). Emitting a reference to a union
(or struct) would create an alias def, but an alias expression was created
in the expression tree to simplify return/param access. The double layer
(sometimes 3 or 4) alias isn't really neaded, so rather than layering the
aliases, just re-alias the alaised def.
2012-05-03 13:28:16 +09:00
Bill Currie ec98e3e206 Mark alias def chains as a bug. 2012-05-03 13:27:30 +09:00
Bill Currie 5f676c367f Add a non-error diagnostic that can't be silenced.
It is inteded for flagging buggy conditions in the compiler, particularly
after having fixed the original bug (in case something comes back from the
dead).
2012-05-03 13:24:24 +09:00
Bill Currie 3306039da2 Print the destination type for alias expression bubbles. 2012-05-03 11:55:19 +09:00
Bill Currie cb8fe4eb38 Correct a "spelling" error. 2012-05-03 11:54:36 +09:00
Bill Currie e267e0a664 Allow control of progdefs.h CRC writing.
CRC writing defaults to off for non-v6 progs, but on for v6 progs. The
--progdefs option forces CRC writing.
2012-05-03 00:22:24 +09:00
Bill Currie 44fcd76475 Add some missing command line option docs. 2012-05-03 00:03:13 +09:00
Bill Currie 15de69d868 Use dstring for progdefs.h writing.
And finally get qfcc into the thing :P
2012-05-02 23:39:49 +09:00
Bill Currie 04b9b3a11d Fix progdefs.h writing. 2012-05-02 22:44:45 +09:00