Skip to content

Commit

Permalink
thecl: Minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
xarnonymous committed Mar 13, 2011
1 parent dd45e48 commit 4a0b6a5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
8 changes: 1 addition & 7 deletions ecsparse.y
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "expr.h"
#include "file.h"
#include "list.h"
#include "program.h"
#include "thecl.h"
#include "value.h"

#include "expr.h"

typedef struct {
char* text;
} string_t;
Expand Down Expand Up @@ -416,8 +415,6 @@ Instruction_Parameters:
| Instruction_Parameters_List
;

/* Confirmed as correct, builds a sequential list, and is left-recursive for
* performance. */
Instruction_Parameters_List:
Instruction_Parameter {
$$ = list_new();
Expand Down Expand Up @@ -481,7 +478,6 @@ Instruction_Parameter:
| Cast_Target "(" Expression ")" {
list_prepend_new(&state->expressions, $3);

/* I must use $1 for this! */
$$ = param_new($1);
$$->stack = 1;
if ($1 == 'S') {
Expand Down Expand Up @@ -586,7 +582,6 @@ Load_Type:

%%

/* String list API: */
static list_t*
string_list_add(
list_t* list,
Expand All @@ -611,7 +606,6 @@ string_list_free(
free(list);
}

/* Instruction API: */
static thecl_instr_t*
instr_init(
parser_state_t* state)
Expand Down
5 changes: 2 additions & 3 deletions ecsscan.l
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
*/
#include <config.h>
}
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ecsparse.h"
#include "util.h"
#include "thecl.h"
#include "util.h"
void yyerror(parser_state_t*, const char*);
/* yylloc.first_column is initialized to 1. */
#define YY_USER_INIT yylloc.first_column = 0
Expand Down Expand Up @@ -172,7 +172,6 @@ C\" {
yylval.bytes.data = realloc(yylval.string, length + 4);
yylval.bytes.length = length;
memset(yylval.bytes.data + length, 0, 4);
// util_xor((unsigned char*)yylval.bytes.data, length + 4, 0x77, 7, 16);
BEGIN(INITIAL);
return CTEXT;
}
Expand Down
14 changes: 1 addition & 13 deletions thecl10.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,6 @@ th10_insert_labels(
}
}

/* XXX: Can't this be rewritten to support sequential reading?
* ... what is sequential reading? */
static thecl_t*
th10_open(
FILE* stream,
Expand All @@ -644,7 +642,6 @@ th10_open(
if (file_size == -1)
return NULL;

/* XXX: Is this freed? */
map = file_mmap(stream, file_size);
if (!map)
return NULL;
Expand Down Expand Up @@ -692,8 +689,6 @@ th10_open(

while ((ptrdiff_t)string_data % 4)
++string_data;
/* XXX: This might be wrong, depending on what it wants to do.
* I need to document good algorithms for performing padding. */
sub_offsets = (uint32_t*)(string_data + ((4 - (ptrdiff_t)string_data) % 4));

ecl->sub_count = header->sub_count;
Expand Down Expand Up @@ -983,7 +978,6 @@ th10_stringify_param(
abort();
}

/* XXX: The _f isn't parsed into the correct value in some cases. ... */
thecl_param_t temp_param = *param;
temp_param.type = new_value.type;
temp_param.value = new_value;
Expand Down Expand Up @@ -1152,18 +1146,15 @@ th10_dump(
size_t param_count = expr->param_format ? strlen(expr->param_format) : 0;
size_t stack_count = expr->stack_arity;

/* TODO: Display errors. */
if (th10_stack_size(node) < stack_count)
/* XXX: Display error? (Not in this case, I think.) */
goto normal;

if (instr->param_count != param_count)
/* XXX: Display error? */
goto normal;

for (size_t p = 0; p < param_count; ++p) {
/* XXX: Is this not already checked earlier? */
if (th10_param_index(instr, p)->type != expr->param_format[p])
/* XXX: Display error? */
goto normal;
}

Expand All @@ -1186,8 +1177,6 @@ th10_dump(
}
}

/* Is this done before or after stack replacement? I'm not
* sure it matters though. */
/* What matters is that the correct stack offset is grabbed
* ... I should do this before -1. */
for (size_t s = 0; s < expr->stack_arity; ++s) {
Expand All @@ -1199,7 +1188,6 @@ th10_dump(
for (size_t p = 0; p < param_count; ++p) {
size_t removed = 0;
sprintf(pat, "p%zu", p);
/* XXX: Uhh... this only does one param at the time, so ... I don't really need a count of how many are removed. */
char* rep_str = th10_stringify_param(sub, node, p, NULL, &removed, 0);
str_replace(temp, pat, rep_str);
free(rep_str);
Expand Down

0 comments on commit 4a0b6a5

Please sign in to comment.