From 69d37b469f60b899b607b1de17a7cd1bd1bbced9 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 4 Nov 2010 02:14:51 -0400 Subject: [PATCH] Added a bunch of FIXMEs to accurately portray current technical debt. --- mojoshader.c | 13 +++++++++++++ mojoshader_assembler.c | 12 +++++++++++- mojoshader_compiler.c | 10 +++++++++- mojoshader_preprocessor.c | 4 +++- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/mojoshader.c b/mojoshader.c index 33d6417b..33e05e7a 100644 --- a/mojoshader.c +++ b/mojoshader.c @@ -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. @@ -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; @@ -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, ...) { @@ -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) @@ -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 diff --git a/mojoshader_assembler.c b/mojoshader_assembler.c index 0fa0abb5..99ee6406 100644 --- a/mojoshader_assembler.c +++ b/mojoshader_assembler.c @@ -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) @@ -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, ...) { @@ -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; @@ -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)) @@ -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)); diff --git a/mojoshader_compiler.c b/mojoshader_compiler.c index f66eaacf..6419ce6a 100644 --- a/mojoshader_compiler.c +++ b/mojoshader_compiler.c @@ -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) @@ -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 @@ -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; @@ -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. diff --git a/mojoshader_preprocessor.c b/mojoshader_preprocessor.c index d497077c..894f9e29 100644 --- a/mojoshader_preprocessor.c +++ b/mojoshader_preprocessor.c @@ -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) @@ -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. @@ -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);