* the `#` (pound sign).
*/
int args = 0;
+ int size = 0;
char *find = strchr(name, '#');
char *peek = find;
* invalid and shouldn't be allowed. The QuakeC VM only
* allows a maximum of eight arguments.
*/
- if (strlen(find) > 1 || *find == '9') {
+ if (*find == '9') {
printf("invalid number of arguments, must be a valid number from 0-8\n");
mem_d(copy);
mem_d(name);
case '2': args++; case '1': args++;
}
}
+ /*
+ * We need to parse the argument size now by determining
+ * the argument identifer list used after the amount of
+ * arguments.
+ */
+ memset(function.argsize, 0, sizeof(function.argsize));
+ find ++; /* skip the number */
+ while (*find == ' ' || *find == '\t') find++;
+ while (size < args) {
+ switch (*find) {
+ case 'V': case 'v': function.argsize[size]=3; break;
+ case 'S': case 's':
+ case 'F': case 'f':
+ case 'E': case 'e': function.argsize[size]=1; break;
+ case '\0':
+ printf("missing argument identifer, expected %d\n", args);
+ return false;
+ default:
+ printf("error invalid function argument identifier\n");
+ return false;
+ }
+ size++,find++;
+ }
+ while (*find == ' ' || *find == '\t') find++;
+ if (*find != '\0') {
+ printf("too many function argument identifers expected %d\n", args);
+ return false;
+ }
} else {
printf("missing number of argument count in function %s\n", name);
+ return false;
}
/*
def.type = TYPE_FUNCTION;
def.offset = code_globals_elements;
def.name = code_chars_elements;
- memset(function.argsize, 0, sizeof(function.argsize));
code_functions_add(function);
code_globals_add(code_statements_elements);
code_chars_put (name, strlen(name));
util_debug("GEN", "FUNCTIONS:\n");
for (; it < code_functions_elements; it++) {
size_t j = code_functions_data[it].entry;
- util_debug("GEN", " {.entry =% 5d, .firstlocal =% 5d, .locals =% 5d, .profile =% 5d, .name =% 5d, .file =% 5d, .nargs =% 5d, .argsize =%0X }\n",
+ util_debug("GEN", " {.entry =% 5d, .firstlocal =% 5d, .locals =% 5d, .profile =% 5d, .name =% 5d, .file =% 5d, .nargs =% 5d, .argsize ={%d,%d,%d,%d,%d,%d,%d,%d} }\n",
code_functions_data[it].entry,
code_functions_data[it].firstlocal,
code_functions_data[it].locals,
code_functions_data[it].name,
code_functions_data[it].file,
code_functions_data[it].nargs,
- *((int32_t*)&code_functions_data[it].argsize)
+ code_functions_data[it].argsize[0],
+ code_functions_data[it].argsize[1],
+ code_functions_data[it].argsize[2],
+ code_functions_data[it].argsize[3],
+ code_functions_data[it].argsize[4],
+ code_functions_data[it].argsize[5],
+ code_functions_data[it].argsize[6],
+ code_functions_data[it].argsize[7]
+
);
util_debug("GEN", " NAME: %s\n", &code_chars_data[code_functions_data[it].name]);
/* Internal functions have no code */