cfad47cfa3/t3compiler/tads3/tctarg.h

4b825dc642cb6eb9a060e54bf8d69288fbee4904cfad47cfa334b206c65f22086bcc5d63e6f70944
1
/* $Header: d:/cvsroot/tads/tads3/TCTARG.H,v 1.3 1999/07/11 00:46:58 MJRoberts Exp $ */
2
3
/* 
4
 *   Copyright (c) 1999, 2002 Michael J. Roberts.  All Rights Reserved.
5
 *   
6
 *   Please see the accompanying license file, LICENSE.TXT, for information
7
 *   on using and copying this software.  
8
 */
9
/*
10
Name
11
  tctarg.h - TADS 3 Compiler Target Selector
12
Function
13
  
14
Notes
15
  
16
Modified
17
  04/30/99 MJRoberts  - Creation
18
*/
19
20
#ifndef TCTARG_H
21
#define TCTARG_H
22
23
/* ------------------------------------------------------------------------ */
24
/*
25
 *   Target Selection.
26
 *   
27
 *   SEE ALSO: tctargty.h - target type header selector
28
 *   
29
 *   As the parser scans the source stream, it constructs a parse tree
30
 *   that represent the parsed form of the source.  After the parsing
31
 *   pass, the parse tree contains all of the information necessary to
32
 *   generate code for the translation.
33
 *   
34
 *   The parse tree objects are actually the code generators.  So, as the
35
 *   scanner parses the source file, it must create parse tree objects for
36
 *   the appropriate target architecture.  However, we want to keep the
37
 *   scanner independent of the target architecture -- we want the same
38
 *   scanner to be usable for any target architecture for which we can
39
 *   provide a code generator.
40
 *   
41
 *   To accomplish this, we define a base class for parse tree nodes; the
42
 *   scanner is only interested in this base class interface.  Then, for
43
 *   each target architecture, we create a subclass of each parse tree
44
 *   node that contains the code generator for that node type for the
45
 *   target.
46
 *   
47
 *   However, the scanner must still know enough to create the appropriate
48
 *   subclass of each parse tree node.  This file contains the target
49
 *   selection switch that mediates the independence of the scanner from
50
 *   the target code generator, but still allows the scanner to create the
51
 *   correct type of parse tree nodes for the desired target.  For each
52
 *   parse tree node type that the scanner must create, we #define a
53
 *   generic symbol to a target-specific subclass.  The scanner uses the
54
 *   generic symbol, but we expand the macro when compiling the compiler
55
 *   to the correct target.
56
 *   
57
 *   Because the target selection is made through macros, the target
58
 *   architecture is fixed at compile time.  However, the same scanner
59
 *   source code can be compiled into multiple target compilers.  
60
 */
61
62
/*
63
 *   Before including this file, #define the appropriate target type.
64
 *   This should usually be done in the makefile, since this is a
65
 *   compile-time selection.
66
 *   
67
 *   To add a new code generator, define the appropriate subclasses in a
68
 *   new file.  Add a new #ifdef-#include sequence below that includes the
69
 *   subclass definitions for your code generator.
70
 *   
71
 *   Note that each target uses the same names for the final subclasses.
72
 *   We choose the target at link time when building the compiler
73
 *   executable, so we must compile and link only a single target
74
 *   architecture into a given build of the compiler.  
75
 */
76
77
/* 
78
 *   make sure TC_TARGET_DEFINED__ isn't defined, so we can use it to
79
 *   sense whether we defined a code generator or not
80
 */
81
#undef TCTARG_TARGET_DEFINED__
82
83
84
/* ------------------------------------------------------------------------ */
85
/*
86
 *   T3 Virtual Machine Code Generator 
87
 */
88
#ifdef TC_TARGET_T3
89
#include "tct3.h"
90
#define TCTARG_TARGET_DEFINED__
91
#endif
92
93
/* ------------------------------------------------------------------------ */
94
/*
95
 *   JavaScript code generator
96
 */
97
#ifdef TC_TARGET_JS
98
#include "tcjs.h"
99
#define TCTARG_TARGET_DEFINED__
100
#endif
101
102
103
/* ------------------------------------------------------------------------ */
104
/*
105
 *   ensure that a code generator was defined - if not, the compilation
106
 *   cannot proceed 
107
 */
108
#ifndef TCTARG_TARGET_DEFINED__
109
#error No code generator target is defined.  A code generator must be defined in your makefile.  See tctarg.h for details.
110
#endif
111
112
113
#endif /* TCTARG_H */
114