Allow returning something of type void in a function that returns void
[delight/core.git] / d-objfile.h
bloba84e3befc2be9f7b5fbd932d55610f5c28b7861d
1 /* GDC -- D front-end for GCC
2 Copyright (C) 2004 David Friedman
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef GCC_DCMPLR_OBFILE_H
20 #define GCC_DCMPLR_OBFILE_H
22 struct ModuleInfo {
23 Array classes; // Array of ClassDeclaration*
24 Array ctors; // Arrays of FuncDeclaration*
25 Array dtors;
26 Array unitTests;
29 typedef enum {
30 TEnone,
31 TEnormal,
32 TEall,
33 TEprivate,
34 TEauto
35 } TemplateEmission;
37 /* nearly everything is static for effeciency since there is
38 only one object per run of the backend */
39 struct ObjectFile {
40 static ModuleInfo * moduleInfo; // of ModuleInfo*
42 ObjectFile(); // constructor is *NOT* static
44 static void beginModule(Module * m);
45 static void endModule();
47 static void finish();
49 /* support for multiple modules per object file */
50 static Array modules;
51 static bool hasModule(Module *m);
52 private:
53 static unsigned moduleSearchIndex;
54 public:
56 static void doLineNote(const Loc & loc);
57 static void setLoc(const Loc & loc);
59 // ** Declaration maninpulation
60 static void setDeclLoc(tree t, const Loc & loc);
62 // Some DMD Declarations don't have the loc set, this searches decl's parents
63 // until a valid loc is found.
64 static void setDeclLoc(tree t, Dsymbol * decl);
66 static void giveDeclUniqueName(tree decl, const char * prefix = NULL);
67 public:
68 // Set a DECL's STATIC and EXTERN based on the decl's storage class
69 // and if it is to be emitted in this module.
70 static void setupSymbolStorage(Dsymbol * decl, tree decl_tree, bool force_static_public = false);
72 // Definitely in static data, but not neccessarily this module.
73 // Assumed to be public data.
74 static void setupStaticStorage(Dsymbol * dsym, tree decl_tree);
75 static void makeDeclOneOnly(tree decl_tree, Dsymbol * dsym = NULL);
77 static void outputStaticSymbol(tree t);
78 static void outputFunction(FuncDeclaration * f);
80 static void addAggMethods(tree rec_type, AggregateDeclaration * agg);
82 static void initTypeDecl(tree t, Dsymbol * d_sym);
84 static void declareType(tree t, Type * d_type);
85 static void declareType(tree t, Dsymbol * d_sym);
87 protected:
88 static void initTypeDecl(tree t, tree decl);
89 static void declareType(tree t, tree decl);
90 public:
92 // Hack for systems without linkonce support
93 static bool shouldEmit(Dsymbol * d_sym);
94 static bool shouldEmit(Symbol * sym);
96 static void doThunk(tree thunk_decl, tree target_decl, target_ptrdiff_t offset);
97 protected:
98 // Can't output thunks while a function is being compiled.
99 static Array deferredThunks;
100 static void outputThunk(tree thunk_decl, tree target_decl, target_ptrdiff_t offset);
101 public:
103 // Can't use VAR_DECLs for the DECL_INITIAL of static varibles or in CONSTRUCTORSs
104 static tree stripVarDecl(tree value);
106 static FuncDeclaration * doSimpleFunction(const char * name, tree expr, bool static_ctor, bool public_fn = false);
107 static FuncDeclaration * doFunctionToCallFunctions(const char * name, Array * functions, bool force_and_public = false);
109 // ** Module info. Assuming only one module per run of the compiler.
111 // ** static constructors (not D static constructors)
112 static Array staticCtorList; // of FuncDeclaration*. usually only one.
113 static Array staticDtorList; // of FuncDeclaration*. only if __attribute__(destructor) is used.
115 static void rodc(tree decl, int top_level)
117 #if D_GCC_VER < 40
118 rest_of_decl_compilation(decl, NULL, top_level, 0);
119 #else
120 rest_of_decl_compilation(decl, top_level, 0);
121 #endif
125 #endif