blob: ba9a44361a01aa654659cf6de9657e7f1582e784 (
plain) (
blame)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
#undef PROFILE
#include "compiledefines.h"
#include "types.t"
#include "system.h"
#include "settings.h"
#include "syntaxtr.t"
#include "comsupport.h"
#include "checker.h"
#include "compiler.h"
#include "codegen_types.h"
#include "codegen.h"
#include "statesgen.h"
#ifdef _PROFILE_
/* FROM profile IMPORT */
extern DumpProfile ();
#endif
char *CurrentFilePath;
static Bool RemoveExtension (char *name)
{
int len;
len = strlen (name);
if (len>=4 && name[len-4]=='.'){
name [len-4] = '\0';
return True;
} else
return False;
}
static void AddExtension (char *name)
{
name [strlen (name)] = '.';
}
static void ExecCompiler (char *fname,char *output_file_name)
{
ImpMod imod;
/* PrintVersion (); */
if (fname){
Bool hadext;
char *p;
CurrentFilePath = fname;
hadext = RemoveExtension (CurrentFilePath);
for (p=CurrentFilePath; *p!='\0'; ++p)
#if defined (_MAC_)
if (*p == ':')
#elif defined (_WINDOWS_) || defined (OS2)
if (*p == '\\')
#else
if (*p == '/')
#endif
fname = p+1;
/* Parse and check */
if (! (imod = ParseAndCheckImplementationModule (fname)))
return;
/* Code generation */
if (output_file_name!=NULL){
Bool hadext;
hadext = RemoveExtension (output_file_name);
#ifdef DUMP_AND_RESTORE
if (gDumpAndRestore){
if (!CompilerError)
CoclBackEnd (imod, output_file_name);
} else
#endif
CodeGeneration (imod,output_file_name);
if (hadext)
AddExtension (output_file_name);
} else
#ifdef DUMP_AND_RESTORE
if (gDumpAndRestore){
if (!CompilerError)
CoclBackEnd (imod, fname);
} else
#endif
CodeGeneration (imod, fname);
if (hadext)
AddExtension (CurrentFilePath);
} else
CmdError ("No source file specified");
}
#ifdef PROFILE
#include "profile.h"
#endif
#ifdef _MAC_
extern void GetInitialPathList (void);
#endif
Bool Compile (char *fname,char *output_file_name)
{
#ifdef PROFILE
InitProfile (900,300);
freopen ("Profile","w",stdout);
#endif
#ifdef _MAC_
GetInitialPathList();
#endif
if (setjmp (ExitEnv)==0){
InitCompiler ();
ExecCompiler (fname,output_file_name);
} else
CompilerError = True;
ExitCompiler ();
#ifdef PROFILE
DumpProfile();
#endif
return ! CompilerError;
}
|