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) {
/* 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 */
});
/* 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 */
/* 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)*/
});
/* 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);
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() {
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);
}
* 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 */
+ size_t w = 0;
+ size_t i = 0;
+
+ /* ignore if we're already LE */
if(*((char *)&s))
- return;
-
+ 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;
- }
- }
+ 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
* assmed all. This works the same as getline().
chr = *n + *lineptr - pos;
strcpy(tmp,*lineptr);
if (!(*lineptr = tmp)) {
- mem_d (tmp);
+ mem_d (tmp);
return -1;
}
pos = *n - chr + *lineptr;