1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/* Test orc_parse() to make sure it handles both \r\n and \n line endings */
#include <orc/orc.h>
#include <orc-test/orctest.h>
#include <orc/orcparse.h>
#include <stdio.h>
#include <stdlib.h>
const char txt_unix[] = ".function orc_add_s16\n"
".dest 2 d1 orc_int16\n.source 2 s1 orc_int16\n.source 2 s2 orc_int16\n"
"\naddw d1, s1, s2\n";
const char txt_win32[] = ".function orc_add_s16\r\n"
".dest 2 d1 orc_int16\r\n.source 2 s1 orc_int16\r\n.source 2 s2 orc_int16\r\n"
"\r\naddw d1, s1, s2\r\n";
void output_code (OrcProgram * p, FILE * output);
void output_code_header (OrcProgram * p, FILE * output);
void output_code_test (OrcProgram * p, FILE * output);
int verbose = FALSE;
int error = FALSE;
int
main (int argc, char *argv[])
{
OrcProgram **programs = NULL;
OrcCompileResult cres;
int n, i;
orc_init ();
orc_test_init ();
/* 1 - unix */
n = orc_parse (txt_unix, &programs);
for (i = 0; i < n; i++) {
if (verbose)
printf ("%s\n", programs[i]->name);
orc_test_compare_output_full (programs[i], 0);
cres = orc_program_compile (programs[i]);
if (ORC_COMPILE_RESULT_IS_FATAL (cres)) {
fprintf (stderr, "compile error: %d\n", cres);
error = TRUE;
}
orc_program_free (programs[i]);
}
if (error || n == 0)
return 1;
free (programs);
programs = NULL;
/* 2 - windows */
n = orc_parse (txt_win32, &programs);
for (i = 0; i < n; i++) {
if (verbose)
printf ("%s\n", programs[i]->name);
orc_test_compare_output_full (programs[i], 0);
cres = orc_program_compile (programs[i]);
if (ORC_COMPILE_RESULT_IS_FATAL (cres)) {
fprintf (stderr, "compile error: %d\n", cres);
error = TRUE;
}
orc_program_free (programs[i]);
}
if (error || n == 0)
return 1;
free (programs);
return 0;
}
|