Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added a bunch of FIXMEs to accurately portray current technical debt.
  • Loading branch information
icculus committed Nov 4, 2010
1 parent 2c660e9 commit 69d37b4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
13 changes: 13 additions & 0 deletions mojoshader.c
Expand Up @@ -13,6 +13,9 @@
#define __MOJOSHADER_INTERNAL__ 1
#include "mojoshader_internal.h"

// !!! FIXME: replace this with BufferList from the preprocessor.
// !!! FIXME: we don't need these as a list of strings, we just need a
// !!! FIXME: growable buffer we can flatten at the end.
// A simple linked list of strings, so we can build the final output without
// realloc()ing for each new line, and easily insert lines into the middle
// of the output without much trouble.
Expand Down Expand Up @@ -275,6 +278,11 @@ MOJOSHADER_parseData MOJOSHADER_out_of_mem_data = {
MOJOSHADER_TYPE_UNKNOWN, 0, 0, 0, 0
};


// !!! FIXME: cut and paste between every damned source file follows...
// !!! FIXME: We need to make some sort of ContextBase that applies to all
// !!! FIXME: files and move this stuff to mojoshader_common.c ...

static inline void out_of_memory(Context *ctx)
{
ctx->isfail = ctx->out_of_memory = 1;
Expand Down Expand Up @@ -383,6 +391,8 @@ static inline char *get_scratch_buffer(Context *ctx)
} // get_scratch_buffer


// !!! FIXME: move the errpos calculation into Context, and we can move this
// !!! FIXME: to mojoshader_common.c
static void failf(Context *ctx, const char *fmt, ...) ISPRINTF(2,3);
static void failf(Context *ctx, const char *fmt, ...)
{
Expand Down Expand Up @@ -530,6 +540,7 @@ static inline uint32 reg_to_ui32(const RegisterType regtype, const int regnum)
return ( ((uint32) regtype) | (((uint32) regnum) << 16) );
} // reg_to_uint32

// !!! FIXME: ditch this for a hash table.
static RegisterList *reglist_insert(Context *ctx, RegisterList *prev,
const RegisterType regtype,
const int regnum)
Expand Down Expand Up @@ -824,6 +835,8 @@ static const char *get_D3D_register_string(Context *ctx,
} // get_D3D_register_string


// !!! FIXME: can we split the profile code out to separate source files?

#define AT_LEAST_ONE_PROFILE 0

#if !SUPPORT_PROFILE_D3D
Expand Down
12 changes: 11 additions & 1 deletion mojoshader_assembler.c
Expand Up @@ -64,6 +64,10 @@ typedef struct Context
} Context;


// !!! FIXME: cut and paste between every damned source file follows...
// !!! FIXME: We need to make some sort of ContextBase that applies to all
// !!! FIXME: files and move this stuff to mojoshader_common.c ...

// Convenience functions for allocators...

static inline void out_of_memory(Context *ctx)
Expand Down Expand Up @@ -102,6 +106,9 @@ static void FreeBridge(void *ptr, void *data)
Free((Context *) data, ptr);
} // FreeBridge


// !!! FIXME: move the errpos calculation into Context, and we can move this
// !!! FIXME: to mojoshader_common.c
static void failf(Context *ctx, const char *fmt, ...) ISPRINTF(2,3);
static void failf(Context *ctx, const char *fmt, ...)
{
Expand Down Expand Up @@ -221,7 +228,7 @@ static Token nexttoken(Context *ctx)
return ctx->tokenval;
} // nexttoken


// !!! FIXME: hashmap?
static inline void add_token_sourcepos(Context *ctx, const size_t idx)
{
unsigned int pos = 0;
Expand All @@ -231,6 +238,7 @@ static inline void add_token_sourcepos(Context *ctx, const size_t idx)
} // add_token_sourcepos


// !!! FIXME: use BufferList.
static void output_token_noswap(Context *ctx, const uint32 token)
{
if (isfail(ctx))
Expand Down Expand Up @@ -281,6 +289,8 @@ static void output_comment_bytes(Context *ctx, const uint8 *buf, size_t len)
{
const uint32 tokencount = (len / 4) + ((len % 4) ? 1 : 0);
output_token(ctx, 0xFFFE | (tokencount << 16));
// !!! FIXME: we can probably just use use modulo and do this without
// !!! FIXME: a tight loop with BufferList.
while (len >= 4)
{
output_token_noswap(ctx, *((const uint32 *) buf));
Expand Down
10 changes: 9 additions & 1 deletion mojoshader_compiler.c
Expand Up @@ -123,6 +123,10 @@ typedef struct Context
} Context;


// !!! FIXME: cut and paste between every damned source file follows...
// !!! FIXME: We need to make some sort of ContextBase that applies to all
// !!! FIXME: files and move this stuff to mojoshader_common.c ...

// Convenience functions for allocators...

static inline void out_of_memory(Context *ctx)
Expand Down Expand Up @@ -308,6 +312,9 @@ static void destroy_symbolmap(Context *ctx, SymbolMap *map)
} // destroy_symbolmap


// !!! FIXME: move this to to mojoshader_ast.c
// !!! FIXME: new_* and delete_* should take an allocator, not a context.

// These functions are mostly for construction and cleanup of nodes in the
// parse tree. Mostly this is simple allocation and initialization, so we
// can do as little in the lemon code as possible, and then sort it all out
Expand Down Expand Up @@ -1906,7 +1913,7 @@ static inline void semantic_analysis(Context *ctx)
// !!! FIXME: do everything else. :)
} // semantic_analysis


// !!! FIXME: isn't this a cut-and-paste of somewhere else?
static inline int64 strtoi64(const char *str, unsigned int len)
{
int64 retval = 0;
Expand Down Expand Up @@ -1944,6 +1951,7 @@ static inline int64 strtoi64(const char *str, unsigned int len)
return retval;
} // strtoi64

// !!! FIXME: isn't this a cut-and-paste of somewhere else?
static inline double strtodouble(const char *_str, unsigned int len)
{
// !!! FIXME: laziness prevails.
Expand Down
4 changes: 3 additions & 1 deletion mojoshader_preprocessor.c
Expand Up @@ -284,6 +284,7 @@ void MOJOSHADER_internal_include_close(const char *data, MOJOSHADER_malloc m,
#endif // !MOJOSHADER_FORCE_INCLUDE_CALLBACKS


// !!! FIXME: move this stuff to mojoshader_common.c ...
// data buffer stuff...

#define BUFFER_LEN (64 * 1024)
Expand Down Expand Up @@ -375,6 +376,7 @@ static void free_buffer(Buffer *buffer, MOJOSHADER_free f, void *d)


// !!! FIXME: maybe use these pool magic elsewhere?
// !!! FIXME: maybe just get rid of this? (maybe the fragmentation isn't a big deal?)

// Pool stuff...
// ugh, I hate this macro salsa.
Expand Down Expand Up @@ -820,7 +822,7 @@ static int require_newline(IncludeState *state)
(token == ((Token) '\n')) || (token == TOKEN_EOI) );
} // require_newline


// !!! FIXME: didn't we implement this by hand elsewhere?
static int token_to_int(IncludeState *state)
{
assert(state->tokenval == TOKEN_INT_LITERAL);
Expand Down

0 comments on commit 69d37b4

Please sign in to comment.