Fix file mode.
[llvm-testsuite.git] / MultiSource / Applications / treecc / gen.h
blob9ba834616d875bc6b81feb7c05b218d570af7723
1 /*
2 * gen.h - Generate code to "treecc" output files.
4 * Copyright (C) 2001, 2002 Southern Storm Software, Pty Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef _TREECC_GEN_H
22 #define _TREECC_GEN_H
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
29 * Generate the source code output.
31 void TreeCCGenerate(TreeCCContext *context);
34 * Generate the source code output for specific languages.
36 void TreeCCGenerateC(TreeCCContext *context);
37 void TreeCCGenerateCPP(TreeCCContext *context);
38 void TreeCCGenerateJava(TreeCCContext *context);
39 void TreeCCGenerateCSharp(TreeCCContext *context);
40 void TreeCCGenerateRuby(TreeCCContext *context);
41 void TreeCCGeneratePHP(TreeCCContext *context);
44 * Control structure for generating the code for
45 * non-virtual operations.
47 typedef struct
49 /* Generate the start declarations for a non-virtual operation */
50 void (*genStart)(TreeCCContext *context, TreeCCStream *stream,
51 TreeCCOperation *oper);
53 /* Generate the entry point for a non-virtual operation */
54 void (*genEntry)(TreeCCContext *context, TreeCCStream *stream,
55 TreeCCOperation *oper);
57 /* Generate the entry point for a split-out function */
58 void (*genSplitEntry)(TreeCCContext *context, TreeCCStream *stream,
59 TreeCCOperation *oper, int number);
61 /* Generate the head of a "switch" statement */
62 void (*genSwitchHead)(TreeCCContext *context, TreeCCStream *stream,
63 char *paramName, int level, int isEnum);
65 /* Generate a selector for a "switch" case */
66 void (*genSelector)(TreeCCContext *context, TreeCCStream *stream,
67 TreeCCNode *node, int level);
69 /* Terminate the selectors and begin the body of a "switch" case */
70 void (*genEndSelectors)(TreeCCContext *context, TreeCCStream *stream,
71 int level);
73 /* Generate the code for a case within a function */
74 void (*genCaseFunc)(TreeCCContext *context, TreeCCStream *stream,
75 TreeCCOperationCase *operCase, int number);
77 /* Generate a call to a case function from within the "switch" */
78 void (*genCaseCall)(TreeCCContext *context, TreeCCStream *stream,
79 TreeCCOperationCase *operCase, int number, int level);
81 /* Generate the code for a case inline within the "switch" */
82 void (*genCaseInline)(TreeCCContext *context, TreeCCStream *stream,
83 TreeCCOperationCase *operCase, int level);
85 /* Generate the code for a call to a split function within the "switch" */
86 void (*genCaseSplit)(TreeCCContext *context, TreeCCStream *stream,
87 TreeCCOperationCase *operCase, int number, int level);
89 /* Terminate a "switch" case */
90 void (*genEndCase)(TreeCCContext *context, TreeCCStream *stream,
91 int level);
93 /* Terminate the "switch" statement */
94 void (*genEndSwitch)(TreeCCContext *context, TreeCCStream *stream,
95 int level);
97 /* Generate the exit point for a non-virtual operation */
98 void (*genExit)(TreeCCContext *context, TreeCCStream *stream,
99 TreeCCOperation *oper);
101 /* Generate the end declarations for a non-virtual operation */
102 void (*genEnd)(TreeCCContext *context, TreeCCStream *stream,
103 TreeCCOperation *oper);
105 } TreeCCNonVirtual;
108 * Generate the code for the non-virtual operations.
110 void TreeCCGenerateNonVirtuals(TreeCCContext *context,
111 const TreeCCNonVirtual *nonVirt);
114 * Common non-virtual operations that are used for C and C++.
116 extern TreeCCNonVirtual const TreeCCNonVirtualFuncsC;
119 * Common non-virtual operations that are used for Java and C#.
121 extern TreeCCNonVirtual const TreeCCNonVirtualFuncsJava;
123 #ifdef __cplusplus
125 #endif
127 #endif /* _TREECC_GEN_H */