comparison dmd/expression/Util.d @ 79:43073c7c7769

updated to 2.035 also implemented a few missing functions still crashes in Import.importAll though
author Trass3r
date Mon, 30 Aug 2010 03:57:51 +0200
parents ef02e2e203c2
children be2ab491772e
comparison
equal deleted inserted replaced
78:b98fa8a4bf04 79:43073c7c7769
944 * Used to supply hidden _arguments[] value for variadic D functions. 944 * Used to supply hidden _arguments[] value for variadic D functions.
945 */ 945 */
946 946
947 Expression createTypeInfoArray(Scope sc, Expression* exps, int dim) 947 Expression createTypeInfoArray(Scope sc, Expression* exps, int dim)
948 { 948 {
949 static if (true) { 949 static if (true)
950 {
950 /* Get the corresponding TypeInfo_Tuple and 951 /* Get the corresponding TypeInfo_Tuple and
951 * point at its elements[]. 952 * point at its elements[].
952 */ 953 */
953 954
954 /* Create the TypeTuple corresponding to the types of args[] 955 /* Create the TypeTuple corresponding to the types of args[]
963 TypeTuple tup = new TypeTuple(args); 964 TypeTuple tup = new TypeTuple(args);
964 Expression e = tup.getTypeInfo(sc); 965 Expression e = tup.getTypeInfo(sc);
965 e = e.optimize(WANTvalue); 966 e = e.optimize(WANTvalue);
966 assert(e.op == TOKsymoff); // should be SymOffExp 967 assert(e.op == TOKsymoff); // should be SymOffExp
967 968
968 version (BREAKABI) { 969 version (BREAKABI)
970 {
969 /* 971 /*
970 * Should just pass a reference to TypeInfo_Tuple instead, 972 * Should just pass a reference to TypeInfo_Tuple instead,
971 * but that would require existing code to be recompiled. 973 * but that would require existing code to be recompiled.
972 * Source compatibility can be maintained by computing _arguments[] 974 * Source compatibility can be maintained by computing _arguments[]
973 * at the start of the called function by offseting into the 975 * at the start of the called function by offseting into the
974 * TypeInfo_Tuple reference. 976 * TypeInfo_Tuple reference.
975 */ 977 */
976 978
977 } else { 979 }
980 else
981 {
978 // Advance to elements[] member of TypeInfo_Tuple 982 // Advance to elements[] member of TypeInfo_Tuple
979 SymOffExp se = cast(SymOffExp)e; 983 SymOffExp se = cast(SymOffExp)e;
980 se.offset += PTRSIZE + PTRSIZE; 984 se.offset += PTRSIZE + PTRSIZE;
981 985
982 // Set type to TypeInfo[]* 986 // Set type to TypeInfo[]*
985 // Indirect to get the _arguments[] value 989 // Indirect to get the _arguments[] value
986 e = new PtrExp(Loc(0), se); 990 e = new PtrExp(Loc(0), se);
987 e.type = se.type.next; 991 e.type = se.type.next;
988 } 992 }
989 return e; 993 return e;
990 } else { 994 } // of static if (true)
995 else
996 {
991 /* Improvements: 997 /* Improvements:
992 * 1) create an array literal instead, 998 * 1) create an array literal instead,
993 * as it would eliminate the extra dereference of loading the 999 * as it would eliminate the extra dereference of loading the
994 * static variable. 1000 * static variable.
995 */ 1001 */
1034 1040
1035 t = Type.typeinfo.type.arrayOf(); 1041 t = Type.typeinfo.type.arrayOf();
1036 ai.type = t; 1042 ai.type = t;
1037 v = new VarDeclaration(0, t, id, ai); 1043 v = new VarDeclaration(0, t, id, ai);
1038 m.members.push(v); 1044 m.members.push(v);
1039 m.symtab.insert(v); 1045 m.symtabInsert(v);
1040 sc = sc.push(); 1046 sc = sc.push();
1041 sc.linkage = LINKc; 1047 sc.linkage = LINKc;
1042 sc.stc = STCstatic | STCcomdat; 1048 sc.stc = STCstatic | STCcomdat;
1043 ai.semantic(sc, t); 1049 ai.semantic(sc, t);
1044 v.semantic(sc); 1050 v.semantic(sc);
1113 { 1119 {
1114 // Type 'paint' operation 1120 // Type 'paint' operation
1115 e = e.copy(); 1121 e = e.copy();
1116 e.type = e1.type; 1122 e.type = e1.type;
1117 } 1123 }
1124 e.loc = e1.loc;
1118 } 1125 }
1119 else 1126 else
1120 { 1127 {
1121 e = e1; 1128 e = e1;
1122 } 1129 }