Indentation

This commit is contained in:
Dale Weiler 2012-04-19 18:03:30 -04:00
parent 082caf61bd
commit 36ff87c130
3 changed files with 47 additions and 48 deletions

View file

@ -156,10 +156,10 @@ typedef struct {
VECTOR_MAKE(globals, assembly_constants);
void asm_clear() {
size_t i = 0;
for (; i < assembly_constants_elements; i++)
mem_d(assembly_constants_data[i].name);
mem_d(assembly_constants_data);
size_t i = 0;
for (; i < assembly_constants_elements; i++)
mem_d(assembly_constants_data[i].name);
mem_d(assembly_constants_data);
}
void asm_parse(FILE *fp) {
@ -210,7 +210,7 @@ void asm_parse(FILE *fp) {
/* FLOAT */
DECLTYPE(asm_keys[0], {
//util_debug("ASM", "Constant FLOAT\n");
//util_debug("ASM", "Constant FLOAT\n");
code_defs_add((prog_section_def){
.type = TYPE_FLOAT,
.offset = offset_globals, /* global table */
@ -222,7 +222,7 @@ void asm_parse(FILE *fp) {
});
/* VECTOR */
DECLTYPE(asm_keys[1], {
//util_debug("ASM", "Constant VECTOR\n");
//util_debug("ASM", "Constant VECTOR\n");
code_defs_add((prog_section_def){
.type = TYPE_FLOAT,
.offset = offset_globals, /* global table */
@ -239,7 +239,7 @@ void asm_parse(FILE *fp) {
/* FIELD */ DECLTYPE(asm_keys[3], {util_debug("ASM", "Constant FIELD\n");});
/* STRING */
DECLTYPE(asm_keys[4], {
//util_debug("ASM", "Constant STRING\n");
//util_debug("ASM", "Constant STRING\n");
code_defs_add((prog_section_def){
.type = TYPE_STRING,
.offset = offset_globals, /* offset to offset in string table (for data)*/
@ -249,7 +249,7 @@ void asm_parse(FILE *fp) {
});
/* FUNCTION */
DECLTYPE(asm_keys[5], {
//util_debug("ASM", "Constant FUNCTION\n");
//util_debug("ASM", "Constant FUNCTION\n");
/* TODO: parse */
if (state != ASM_NULL) {
printf("%li: Error unfinished function block, expected DONE or RETURN\n", line);

46
code.c
View file

@ -81,12 +81,12 @@ VECTOR_MAKE(int, code_globals );
VECTOR_MAKE(char, code_chars );
int code_strings_add(const char *src) {
size_t size = strlen(src);
size_t iter = 0;
while (iter < size)
code_chars_add(src[iter++]);
code_chars_add('\0');
return code_chars_elements;
size_t size = strlen(src);
size_t iter = 0;
while (iter < size)
code_chars_add(src[iter++]);
code_chars_add('\0');
return code_chars_elements;
}
void code_init() {
@ -179,24 +179,24 @@ void code_write() {
util_debug("GEN", "functions:\n");
size_t i = 0;
for (; i < code_functions_elements; i++) {
util_debug("GEN", " {.entry =% 5d, .firstlocal =% 5d, .locals =% 5d, .profile =% 5d, .name =% 5d, .file =% 5d, .nargs =% 5d, .argsize =%0X }\n",
code_functions_data[i].entry,
code_functions_data[i].firstlocal,
code_functions_data[i].locals,
code_functions_data[i].profile,
code_functions_data[i].name,
code_functions_data[i].file,
code_functions_data[i].nargs,
*((int32_t*)&code_functions_data[i].argsize)
);
util_debug("GEN", " {.entry =% 5d, .firstlocal =% 5d, .locals =% 5d, .profile =% 5d, .name =% 5d, .file =% 5d, .nargs =% 5d, .argsize =%0X }\n",
code_functions_data[i].entry,
code_functions_data[i].firstlocal,
code_functions_data[i].locals,
code_functions_data[i].profile,
code_functions_data[i].name,
code_functions_data[i].file,
code_functions_data[i].nargs,
*((int32_t*)&code_functions_data[i].argsize)
);
}
mem_d(code_statements_data);
mem_d(code_defs_data);
mem_d(code_fields_data);
mem_d(code_functions_data);
mem_d(code_globals_data);
mem_d(code_chars_data);
mem_d(code_statements_data);
mem_d(code_defs_data);
mem_d(code_fields_data);
mem_d(code_functions_data);
mem_d(code_globals_data);
mem_d(code_chars_data);
fclose(fp);
}

33
util.c
View file

@ -150,23 +150,22 @@ void util_debug(const char *area, const char *ms, ...) {
* certian-sized types like short or int.
*/
void util_endianswap(void *m, int s, int l) {
size_t w = 0;
size_t i = 0;
/* ignore if we're already LE */
if(*((char *)&s))
return;
for(; w < l; w++) {
for(; i < s << 1; i++) {
unsigned char *p = (unsigned char *)m+w*s;
unsigned char t = p[i];
p[i] = p[s-i-1];
p[s-i-1] = t;
}
}
}
size_t w = 0;
size_t i = 0;
/* ignore if we're already LE */
if(*((char *)&s))
return;
for(; w < l; w++) {
for(; i < s << 1; i++) {
unsigned char *p = (unsigned char *)m+w*s;
unsigned char t = p[i];
p[i] = p[s-i-1];
p[s-i-1] = t;
}
}
}
/*
* Implements libc getline for systems that don't have it, which is
@ -198,7 +197,7 @@ int util_getline(char **lineptr, size_t *n, FILE *stream) {
chr = *n + *lineptr - pos;
strcpy(tmp,*lineptr);
if (!(*lineptr = tmp)) {
mem_d (tmp);
mem_d (tmp);
return -1;
}
pos = *n - chr + *lineptr;