comparison dmd/FuncDeclaration.d @ 167:50a6d232176c

rewrite GlobalExpressions, moved DsymbolTable to Global, some cleanup
author korDen
date Thu, 30 Sep 2010 12:13:49 +0400
parents 80f4806ffa13
children af724d3510d7
comparison
equal deleted inserted replaced
166:d8565fbd755c 167:50a6d232176c
2208 * Determine if function is a builtin one that we can 2208 * Determine if function is a builtin one that we can
2209 * evaluate at compile time. 2209 * evaluate at compile time.
2210 */ 2210 */
2211 BUILTIN isBuiltin() 2211 BUILTIN isBuiltin()
2212 { 2212 {
2213 static string FeZe = "FNaNbeZe"; // pure nothrow real function(real) 2213 enum FeZe = "FNaNbeZe"; // pure nothrow real function(real)
2214 2214
2215 //printf("FuncDeclaration::isBuiltin() %s\n", toChars()); 2215 //printf("FuncDeclaration::isBuiltin() %s\n", toChars());
2216 if (builtin == BUILTIN.BUILTINunknown) 2216 if (builtin == BUILTIN.BUILTINunknown)
2217 { 2217 {
2218 builtin = BUILTIN.BUILTINnot; 2218 builtin = BUILTIN.BUILTINnot;
3099 static FuncDeclaration genCfunc(Type treturn, Identifier id) 3099 static FuncDeclaration genCfunc(Type treturn, Identifier id)
3100 { 3100 {
3101 FuncDeclaration fd; 3101 FuncDeclaration fd;
3102 TypeFunction tf; 3102 TypeFunction tf;
3103 Dsymbol s; 3103 Dsymbol s;
3104 static DsymbolTable st = null;
3105 3104
3106 //printf("genCfunc(name = '%s')\n", id.toChars()); 3105 //printf("genCfunc(name = '%s')\n", id.toChars());
3107 //printf("treturn\n\t"); treturn.print(); 3106 //printf("treturn\n\t"); treturn.print();
3108 3107
3109 // See if already in table 3108 // See if already in table
3110 if (!st) 3109 s = global.st.lookup(id);
3111 st = new DsymbolTable();
3112
3113 s = st.lookup(id);
3114 if (s) 3110 if (s)
3115 { 3111 {
3116 fd = s.isFuncDeclaration(); 3112 debug fd = s.isFuncDeclaration();
3117 assert(fd); 3113 debug assert(fd);
3118 assert(fd.type.nextOf().equals(treturn)); 3114 debug assert(fd.type.nextOf().equals(treturn));
3119 } 3115 }
3120 else 3116 else
3121 { 3117 {
3122 tf = new TypeFunction(null, treturn, 0, LINK.LINKc); 3118 tf = new TypeFunction(null, treturn, 0, LINK.LINKc);
3123 fd = new FuncDeclaration(Loc(0), Loc(0), id, STCstatic, tf); 3119 fd = new FuncDeclaration(Loc(0), Loc(0), id, STCstatic, tf);
3124 fd.protection = PROT.PROTpublic; 3120 fd.protection = PROT.PROTpublic;
3125 fd.linkage = LINK.LINKc; 3121 fd.linkage = LINK.LINKc;
3126 3122
3127 st.insert(fd); 3123 global.st.insert(fd);
3128 } 3124 }
3129 return fd; 3125 return fd;
3130 } 3126 }
3131 3127
3132 override Symbol* toSymbol() 3128 override Symbol* toSymbol()