1
/* $Header: d:/cvsroot/tads/tads3/TCTARG.H,v 1.3 1999/07/11 00:46:58 MJRoberts Exp $ */
4
* Copyright (c) 1999, 2002 Michael J. Roberts. All Rights Reserved.
6
* Please see the accompanying license file, LICENSE.TXT, for information
7
* on using and copying this software.
11
tctarg.h - TADS 3 Compiler Target Selector
17
04/30/99 MJRoberts - Creation
23
/* ------------------------------------------------------------------------ */
27
* SEE ALSO: tctargty.h - target type header selector
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.
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.
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
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.
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.
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.
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.
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.
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
81
#undef TCTARG_TARGET_DEFINED__
84
/* ------------------------------------------------------------------------ */
86
* T3 Virtual Machine Code Generator
90
#define TCTARG_TARGET_DEFINED__
93
/* ------------------------------------------------------------------------ */
95
* JavaScript code generator
99
#define TCTARG_TARGET_DEFINED__
103
/* ------------------------------------------------------------------------ */
105
* ensure that a code generator was defined - if not, the compilation
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.
113
#endif /* TCTARG_H */