{
OrcParser _parser;
OrcParser *parser = &_parser;
+ char *init_function = NULL;
memset (parser, 0, sizeof(*parser));
parser->programs[parser->n_programs] = parser->program;
parser->n_programs++;
parser->creg_index = 1;
+ } else if (strcmp (token[0], ".init") == 0) {
+ if (init_function) free (init_function);
+ if (n_tokens < 2) {
+ orc_parse_log (parser, "error: line %d: .init without function name\n",
+ parser->line_number);
+ } else {
+ init_function = strdup (token[1]);
+ }
} else if (strcmp (token[0], ".flags") == 0) {
int i;
for(i=1;i<n_tokens;i++){
} else {
free (parser->log);
}
+ parser->programs[0]->init_function = init_function;
*programs = parser->programs;
return parser->n_programs;
}
}
+const char *
+orc_parse_get_init_function (OrcProgram *program)
+{
+ return program->init_function;
+}
+
int orc_parse (const char *code, OrcProgram ***programs);
int orc_parse_full (const char *code, OrcProgram ***programs, char **log);
+const char * orc_parse_get_init_function (OrcProgram *program);
ORC_END_DECLS
int use_inline = FALSE;
-char *init_function = NULL;
+const char *init_function = NULL;
char *target = "sse";
n_programs = n;
printf("%s", log);
+ if (init_function == NULL) {
+ init_function = orc_parse_get_init_function (programs[0]);
+ }
+
output = fopen (output_file, "w");
if (!output) {
printf("Could not write output file: %s\n", output_file);